provide 'knowledge' attribute (as relation set field) for person; remove corresponding relations from parents portlet and assignment part of form if approprieate (configured via corresponding options); display relation set field as links
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@4158 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
063c831be9
commit
3a65566beb
10 changed files with 92 additions and 11 deletions
|
@ -326,6 +326,9 @@ class ConceptView(BaseView):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def isHidden(self, pr):
|
def isHidden(self, pr):
|
||||||
|
if (getName(pr.second.conceptType) in
|
||||||
|
IOptions(adapted(pr.predicate))('hide_parents_for', [])):
|
||||||
|
return True
|
||||||
hideRoles = IOptions(adapted(pr.first.conceptType))('hide_for', None)
|
hideRoles = IOptions(adapted(pr.first.conceptType))('hide_for', None)
|
||||||
if hideRoles is not None:
|
if hideRoles is not None:
|
||||||
principal = self.request.principal
|
principal = self.request.principal
|
||||||
|
|
|
@ -69,12 +69,20 @@
|
||||||
|
|
||||||
|
|
||||||
<metal:email define-macro="display_email">
|
<metal:email define-macro="display_email">
|
||||||
<a href="#"
|
<a tal:attributes="href string:mailto:$value"
|
||||||
tal:attributes="href string:mailto:$value"
|
|
||||||
tal:content="value"></a>
|
tal:content="value"></a>
|
||||||
</metal:email>
|
</metal:email>
|
||||||
|
|
||||||
|
|
||||||
|
<metal:email define-macro="display_relationset">
|
||||||
|
<span tal:repeat="elem value">
|
||||||
|
<a tal:attributes="href elem/url"
|
||||||
|
tal:content="elem/label"></a>
|
||||||
|
<tal:separator condition="not:repeat/elem/end"> | </tal:separator>
|
||||||
|
</span>
|
||||||
|
</metal:email>
|
||||||
|
|
||||||
|
|
||||||
<metal:parents define-macro="conceptparents">
|
<metal:parents define-macro="conceptparents">
|
||||||
<div tal:attributes="class string:content-$level;
|
<div tal:attributes="class string:content-$level;
|
||||||
ondblclick python: item.openEditWindow('configure.html')">
|
ondblclick python: item.openEditWindow('configure.html')">
|
||||||
|
@ -107,7 +115,6 @@
|
||||||
<tal:items repeat="related children">
|
<tal:items repeat="related children">
|
||||||
<tal:item define="class python: repeat['related'].odd() and 'even' or 'odd';
|
<tal:item define="class python: repeat['related'].odd() and 'even' or 'odd';
|
||||||
description related/description;
|
description related/description;
|
||||||
xx_predicate related/predicate/title|string:;
|
|
||||||
predicate related/predicateTitle;
|
predicate related/predicateTitle;
|
||||||
info python: ' | '.join(
|
info python: ' | '.join(
|
||||||
t for t in (description, predicate) if t)">
|
t for t in (description, predicate) if t)">
|
||||||
|
|
|
@ -219,7 +219,8 @@ class EditObjectForm(ObjectForm):
|
||||||
def assignments(self):
|
def assignments(self):
|
||||||
for c in self.target.getConceptRelations():
|
for c in self.target.getConceptRelations():
|
||||||
r = ConceptRelationView(c, self.request)
|
r = ConceptRelationView(c, self.request)
|
||||||
if r.isProtected: continue
|
if r.isProtected:
|
||||||
|
continue
|
||||||
yield r
|
yield r
|
||||||
|
|
||||||
|
|
||||||
|
@ -242,7 +243,9 @@ class EditConceptForm(EditObjectForm):
|
||||||
def assignments(self):
|
def assignments(self):
|
||||||
for c in self.target.getParentRelations():
|
for c in self.target.getParentRelations():
|
||||||
r = ConceptRelationView(c, self.request)
|
r = ConceptRelationView(c, self.request)
|
||||||
if not r.isProtected and r.context != self.target:
|
if r.isProtected or r.isHidden(r.relation):
|
||||||
|
continue
|
||||||
|
if r.context != self.target:
|
||||||
yield r
|
yield r
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -130,6 +130,10 @@ fulfill the position offered:
|
||||||
>>> [list(d)[0].title for k, d in prov]
|
>>> [list(d)[0].title for k, d in prov]
|
||||||
['Objectorienting Programming', 'oopython.pdf']
|
['Objectorienting Programming', 'oopython.pdf']
|
||||||
|
|
||||||
|
Controlling knowledge-related form fields via a schema factory
|
||||||
|
--------------------------------------------------------------
|
||||||
|
|
||||||
|
>>> from loops.knowledge.schema import PersonSchemaFactory
|
||||||
|
|
||||||
Views that make use of the knowledge management modules
|
Views that make use of the knowledge management modules
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
|
|
|
@ -79,6 +79,8 @@
|
||||||
|
|
||||||
<!-- other adapters -->
|
<!-- other adapters -->
|
||||||
|
|
||||||
|
<zope:adapter factory="loops.knowledge.schema.PersonSchemaFactory" />
|
||||||
|
|
||||||
<zope:adapter factory="loops.knowledge.setup.SetupManager"
|
<zope:adapter factory="loops.knowledge.setup.SetupManager"
|
||||||
name="knowledge" />
|
name="knowledge" />
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2011 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -32,8 +32,9 @@ from cybertools.knowledge.interfaces import IKnowledgeElement
|
||||||
from loops.interfaces import IConceptSchema, ILoopsAdapter
|
from loops.interfaces import IConceptSchema, ILoopsAdapter
|
||||||
from loops.organize.interfaces import IPerson as IBasePerson
|
from loops.organize.interfaces import IPerson as IBasePerson
|
||||||
from loops.organize.interfaces import ITask as IBaseTask
|
from loops.organize.interfaces import ITask as IBaseTask
|
||||||
|
from loops.schema.base import Relation, RelationSet
|
||||||
|
|
||||||
_ = MessageFactory('zope')
|
_ = MessageFactory('loops')
|
||||||
|
|
||||||
# TODO: separate interfaces for viewing and changing methods!
|
# TODO: separate interfaces for viewing and changing methods!
|
||||||
|
|
||||||
|
@ -42,6 +43,12 @@ class IPerson(IBasePerson, IKnowing, ILoopsAdapter):
|
||||||
""" A person, including knowledge/learning management features.
|
""" A person, including knowledge/learning management features.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
knowledge = RelationSet(
|
||||||
|
title=_(u'Knowledge'),
|
||||||
|
description=_(u'The knowledge elements for this person.'),
|
||||||
|
#target_types=('topic',), # set via global option knowledge.element
|
||||||
|
required=False)
|
||||||
|
|
||||||
|
|
||||||
class ITask(IBaseTask, IRequirementProfile, ILoopsAdapter):
|
class ITask(IBaseTask, IRequirementProfile, ILoopsAdapter):
|
||||||
""" A task, also acting as a knowledge requirement profile.
|
""" A task, also acting as a knowledge requirement profile.
|
||||||
|
|
|
@ -32,6 +32,7 @@ from zope.cachedescriptors.property import Lazy
|
||||||
from cybertools.typology.interfaces import IType
|
from cybertools.typology.interfaces import IType
|
||||||
from cybertools.knowledge.interfaces import IKnowledgeElement, IKnowledgeProvider
|
from cybertools.knowledge.interfaces import IKnowledgeElement, IKnowledgeProvider
|
||||||
from cybertools.knowledge.knowing import Knowing
|
from cybertools.knowledge.knowing import Knowing
|
||||||
|
from loops.common import ParentRelationSetProperty, ChildRelationSetProperty
|
||||||
from loops.interfaces import IConcept, IResource
|
from loops.interfaces import IConcept, IResource
|
||||||
from loops.i18n.common import I18NAdapterBase
|
from loops.i18n.common import I18NAdapterBase
|
||||||
from loops.knowledge.interfaces import IPerson, ITask, ITopic
|
from loops.knowledge.interfaces import IPerson, ITask, ITopic
|
||||||
|
@ -82,6 +83,11 @@ class Person(BasePerson, Knowing, KnowledgeAdapterMixin):
|
||||||
knowledge/learning management features.
|
knowledge/learning management features.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_adapterAttributes = BasePerson._adapterAttributes + ('knowledge',)
|
||||||
|
_noexportAttributes = ('knowledge',)
|
||||||
|
|
||||||
|
knowledge = ParentRelationSetProperty('knows')
|
||||||
|
|
||||||
implements(IPerson)
|
implements(IPerson)
|
||||||
|
|
||||||
def getKnowledge(self):
|
def getKnowledge(self):
|
||||||
|
|
45
knowledge/schema.py
Normal file
45
knowledge/schema.py
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2011 Helmut Merz helmutm@cy55.de
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
|
||||||
|
"""
|
||||||
|
Specialized schema factories
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
"""
|
||||||
|
|
||||||
|
from zope.component import adapts
|
||||||
|
|
||||||
|
from cybertools.meta.interfaces import IOptions
|
||||||
|
from loops.knowledge.interfaces import IPerson
|
||||||
|
from loops.organize.schema import PersonSchemaFactory as BasePersonSchemaFactory
|
||||||
|
|
||||||
|
|
||||||
|
class PersonSchemaFactory(BasePersonSchemaFactory):
|
||||||
|
|
||||||
|
adapts(IPerson)
|
||||||
|
|
||||||
|
def __call__(self, interface, **kw):
|
||||||
|
schema = super(PersonSchemaFactory, self).__call__(interface, **kw)
|
||||||
|
if 'knowledge' in schema.fields.keys():
|
||||||
|
kelements = IOptions(self.context.getLoopsRoot())('knowledge.element')
|
||||||
|
if kelements:
|
||||||
|
schema.fields['knowledge'].target_types = kelements
|
||||||
|
else:
|
||||||
|
del schema.fields['knowledge']
|
||||||
|
return schema
|
||||||
|
|
|
@ -62,7 +62,7 @@ class Relation(Field):
|
||||||
instanceName='relation'))
|
instanceName='relation'))
|
||||||
|
|
||||||
def __init__(self, *args, **kw):
|
def __init__(self, *args, **kw):
|
||||||
self.target_types = kw.pop('target_types')
|
self.target_types = kw.pop('target_types', ())
|
||||||
super(Relation, self).__init__(*args, **kw)
|
super(Relation, self).__init__(*args, **kw)
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,10 +73,11 @@ class RelationSet(List):
|
||||||
__typeInfo__ = ('relationset',
|
__typeInfo__ = ('relationset',
|
||||||
FieldType('relationset', 'relationset',
|
FieldType('relationset', 'relationset',
|
||||||
u'A field representing a sequence of related objects.',
|
u'A field representing a sequence of related objects.',
|
||||||
instanceName='relationset'))
|
instanceName='relationset',
|
||||||
|
displayRenderer='display_relationset'))
|
||||||
|
|
||||||
def __init__(self, *args, **kw):
|
def __init__(self, *args, **kw):
|
||||||
self.target_types = kw.pop('target_types')
|
self.target_types = kw.pop('target_types', ())
|
||||||
self.selection_view = kw.pop('selection_view', None)
|
self.selection_view = kw.pop('selection_view', None)
|
||||||
super(RelationSet, self).__init__(*args, **kw)
|
super(RelationSet, self).__init__(*args, **kw)
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,10 @@ class RelationSetFieldInstance(ListFieldInstance, BaseRelationFieldInstance):
|
||||||
for v in value]
|
for v in value]
|
||||||
|
|
||||||
def display(self, value):
|
def display(self, value):
|
||||||
return ' | '.join([v.title for v in value])
|
nodeView = self.clientInstance.view.nodeView
|
||||||
|
return [dict(url=nodeView.getUrlForTarget(baseObject(v)),
|
||||||
|
label=v.title) for v in value]
|
||||||
|
#return ' | '.join([v.title for v in value])
|
||||||
|
|
||||||
def unmarshall(self, value):
|
def unmarshall(self, value):
|
||||||
return [util.getObjectForUid(v) for v in value]
|
return [util.getObjectForUid(v) for v in value]
|
||||||
|
|
Loading…
Add table
Reference in a new issue