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
|
||||
|
||||
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)
|
||||
if hideRoles is not None:
|
||||
principal = self.request.principal
|
||||
|
|
|
@ -69,12 +69,20 @@
|
|||
|
||||
|
||||
<metal:email define-macro="display_email">
|
||||
<a href="#"
|
||||
tal:attributes="href string:mailto:$value"
|
||||
<a tal:attributes="href string:mailto:$value"
|
||||
tal:content="value"></a>
|
||||
</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">
|
||||
<div tal:attributes="class string:content-$level;
|
||||
ondblclick python: item.openEditWindow('configure.html')">
|
||||
|
@ -107,7 +115,6 @@
|
|||
<tal:items repeat="related children">
|
||||
<tal:item define="class python: repeat['related'].odd() and 'even' or 'odd';
|
||||
description related/description;
|
||||
xx_predicate related/predicate/title|string:;
|
||||
predicate related/predicateTitle;
|
||||
info python: ' | '.join(
|
||||
t for t in (description, predicate) if t)">
|
||||
|
|
|
@ -219,7 +219,8 @@ class EditObjectForm(ObjectForm):
|
|||
def assignments(self):
|
||||
for c in self.target.getConceptRelations():
|
||||
r = ConceptRelationView(c, self.request)
|
||||
if r.isProtected: continue
|
||||
if r.isProtected:
|
||||
continue
|
||||
yield r
|
||||
|
||||
|
||||
|
@ -242,7 +243,9 @@ class EditConceptForm(EditObjectForm):
|
|||
def assignments(self):
|
||||
for c in self.target.getParentRelations():
|
||||
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
|
||||
|
||||
|
||||
|
|
|
@ -130,6 +130,10 @@ fulfill the position offered:
|
|||
>>> [list(d)[0].title for k, d in prov]
|
||||
['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
|
||||
-------------------------------------------------------
|
||||
|
|
|
@ -79,6 +79,8 @@
|
|||
|
||||
<!-- other adapters -->
|
||||
|
||||
<zope:adapter factory="loops.knowledge.schema.PersonSchemaFactory" />
|
||||
|
||||
<zope:adapter factory="loops.knowledge.setup.SetupManager"
|
||||
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
|
||||
# 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.organize.interfaces import IPerson as IBasePerson
|
||||
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!
|
||||
|
||||
|
@ -42,6 +43,12 @@ class IPerson(IBasePerson, IKnowing, ILoopsAdapter):
|
|||
""" 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):
|
||||
""" 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.knowledge.interfaces import IKnowledgeElement, IKnowledgeProvider
|
||||
from cybertools.knowledge.knowing import Knowing
|
||||
from loops.common import ParentRelationSetProperty, ChildRelationSetProperty
|
||||
from loops.interfaces import IConcept, IResource
|
||||
from loops.i18n.common import I18NAdapterBase
|
||||
from loops.knowledge.interfaces import IPerson, ITask, ITopic
|
||||
|
@ -82,6 +83,11 @@ class Person(BasePerson, Knowing, KnowledgeAdapterMixin):
|
|||
knowledge/learning management features.
|
||||
"""
|
||||
|
||||
_adapterAttributes = BasePerson._adapterAttributes + ('knowledge',)
|
||||
_noexportAttributes = ('knowledge',)
|
||||
|
||||
knowledge = ParentRelationSetProperty('knows')
|
||||
|
||||
implements(IPerson)
|
||||
|
||||
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'))
|
||||
|
||||
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)
|
||||
|
||||
|
||||
|
@ -73,10 +73,11 @@ class RelationSet(List):
|
|||
__typeInfo__ = ('relationset',
|
||||
FieldType('relationset', 'relationset',
|
||||
u'A field representing a sequence of related objects.',
|
||||
instanceName='relationset'))
|
||||
instanceName='relationset',
|
||||
displayRenderer='display_relationset'))
|
||||
|
||||
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)
|
||||
super(RelationSet, self).__init__(*args, **kw)
|
||||
|
||||
|
|
|
@ -76,7 +76,10 @@ class RelationSetFieldInstance(ListFieldInstance, BaseRelationFieldInstance):
|
|||
for v in 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):
|
||||
return [util.getObjectForUid(v) for v in value]
|
||||
|
|
Loading…
Add table
Reference in a new issue