get deputy title / object name from its names
This commit is contained in:
parent
f7c6723738
commit
202e46de52
|
@ -18,4 +18,8 @@
|
|||
directory="profiles/default"
|
||||
provides="Products.GenericSetup.interfaces.EXTENSION"
|
||||
/>
|
||||
|
||||
<adapter for="themis.datatypes.deputy.IDeputy"
|
||||
provides="themis.datatypes.deputy.INameFromPersonNames"
|
||||
factory="themis.datatypes.deputy.NameFromPersonNames" />
|
||||
</configure>
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
from five import grok
|
||||
from zope import schema
|
||||
from zope.interface import implements
|
||||
from zope.component import adapts, provideAdapter
|
||||
|
||||
from z3c.relationfield.schema import RelationChoice
|
||||
from plone.formwidget.contenttree import ObjPathSourceBinder
|
||||
from plone.dexterity.content import Item
|
||||
|
||||
from plone.app.content.interfaces import INameFromTitle
|
||||
from plone.directives import form, dexterity
|
||||
|
||||
from themis.datatypes.interfaces import MessageFactory as _
|
||||
|
@ -19,3 +23,28 @@ class IDeputy(form.Schema):
|
|||
title=_(u"Political Group"),
|
||||
source=ObjPathSourceBinder(object_provides=IPolGroup.__identifier__),
|
||||
required=False)
|
||||
|
||||
class INameFromPersonNames(INameFromTitle):
|
||||
def title():
|
||||
'''Return a processed title'''
|
||||
|
||||
class NameFromPersonNames(object):
|
||||
implements(INameFromPersonNames)
|
||||
|
||||
def __init__(self, context):
|
||||
self.context = context
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
return self.context.firstname + ' ' + self.context.lastname
|
||||
|
||||
class Deputy(Item):
|
||||
implements(IDeputy)
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
return self.firstname + ' ' + self.lastname
|
||||
|
||||
def setTitle(self, value):
|
||||
pass
|
||||
|
||||
|
|
|
@ -15,13 +15,14 @@
|
|||
<property name="schema">themis.datatypes.deputy.IDeputy</property>
|
||||
|
||||
<!-- class used for content items -->
|
||||
<property name="klass">plone.dexterity.content.Item</property>
|
||||
<property name="klass">themis.datatypes.deputy.Deputy</property>
|
||||
|
||||
<!-- add permission -->
|
||||
<property name="add_permission">cmf.AddPortalContent</property>
|
||||
|
||||
<!-- enabled behaviors -->
|
||||
<property name="behaviors">
|
||||
<element value="plone.app.content.interfaces.INameFromTitle" />
|
||||
</property>
|
||||
|
||||
<!-- View information -->
|
||||
|
|
Reference in New Issue