51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
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 _
|
|
|
|
from themis.datatypes.polgroup import IPolGroup
|
|
|
|
class IDeputy(form.Schema):
|
|
firstname = schema.TextLine(title=_(u'First Name'))
|
|
lastname = schema.TextLine(title=_(u'Last Name'))
|
|
active = schema.Bool(title=_(u'Active'), default=True)
|
|
|
|
polgroup = RelationChoice(
|
|
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
|
|
|