Add a RelatedDocs type (not editable ttw at the moment)
This commit is contained in:
parent
04943cf4ed
commit
a56d578fef
|
@ -26,6 +26,7 @@ from themis.fields.interfaces import IDateOnly
|
|||
from themis.fields.interfaces import IRadioChoice
|
||||
from themis.fields.interfaces import ISubjects, ILegisSession, IList
|
||||
from themis.fields.interfaces import IRelatedDoc
|
||||
from themis.fields.interfaces import IRelatedDocs
|
||||
from themis.fields.interfaces import IMailId
|
||||
from themis.fields.interfaces import IMailRefId
|
||||
|
||||
|
@ -33,7 +34,7 @@ from themis.fields.vocabs import SubjectsSource
|
|||
from themis.fields.vocabs import LegislativeSessionsSource
|
||||
|
||||
from plone.formwidget.contenttree import ObjPathSourceBinder
|
||||
from z3c.relationfield.schema import Relation
|
||||
from z3c.relationfield.schema import Relation, RelationList
|
||||
|
||||
|
||||
class Commission(Field):
|
||||
|
@ -355,6 +356,15 @@ class RelatedDoc(Relation):
|
|||
return clone
|
||||
|
||||
|
||||
class RelatedDocs(RelationList):
|
||||
implements(IRelatedDocs)
|
||||
|
||||
def __init__(self, value_type=None, unique=False, **kw):
|
||||
if value_type is None:
|
||||
value_type = RelatedDoc()
|
||||
super(RelatedDocs, self).__init__(value_type=value_type, unique=unique, **kw)
|
||||
|
||||
|
||||
class MailId(TextLine):
|
||||
implements(IMailId, IFromUnicode)
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ from themis.fields import Deputy, Deputies
|
|||
from themis.fields import Ministry, Ministries
|
||||
from themis.fields import DeputyOrMinistry, DeputiesOrMinistries
|
||||
from themis.fields import RelatedDoc
|
||||
from themis.fields import RelatedDocs
|
||||
from themis.fields import MailId
|
||||
from themis.fields import MailRefId
|
||||
from plone.schemaeditor.fields import FieldFactory
|
||||
|
@ -47,6 +48,8 @@ RadioChoiceFactory = FieldFactory(RadioChoice, u'Choice (radio)', values=[])
|
|||
|
||||
RelatedDocFactory = FieldFactory(RelatedDoc, u'Related Document')
|
||||
|
||||
RelatedDocsFactory = FieldFactory(RelatedDocs, u'Related Documents')
|
||||
|
||||
MailRefIdFactory = FieldFactory(MailRefId, u'Mail Reference')
|
||||
|
||||
MailIdFactory = FieldFactory(MailId, u'Mail Number')
|
||||
|
|
|
@ -77,6 +77,11 @@
|
|||
component=".editors.RelatedDocFactory"
|
||||
/>
|
||||
|
||||
<utility
|
||||
name="themis.fields.RelatedDocs"
|
||||
component=".editors.RelatedDocsFactory"
|
||||
/>
|
||||
|
||||
<utility
|
||||
name="themis.fields.MailId"
|
||||
component=".editors.MailIdFactory"
|
||||
|
|
|
@ -22,6 +22,7 @@ if HAVE_SUPERMODEL:
|
|||
from themis.fields import Contact, Contacts
|
||||
from themis.fields import LegisSession
|
||||
from themis.fields import RelatedDoc
|
||||
from themis.fields import RelatedDocs
|
||||
from themis.fields import MailId
|
||||
from themis.fields import MailRefId
|
||||
|
||||
|
@ -100,6 +101,11 @@ if HAVE_SUPERMODEL:
|
|||
|
||||
RelatedDocHandler = RelatedDocHandler_(RelatedDoc)
|
||||
|
||||
class RelatedDocsHandler_(BaseHandler):
|
||||
pass
|
||||
|
||||
RelatedDocsHandler = RelatedDocsHandler_(RelatedDocs)
|
||||
|
||||
class MailIdHandler_(BaseHandler):
|
||||
pass
|
||||
|
||||
|
|
|
@ -79,6 +79,11 @@
|
|||
name="themis.fields.RelatedDoc"
|
||||
/>
|
||||
|
||||
<utility
|
||||
component=".handlers.RelatedDocsHandler"
|
||||
name="themis.fields.RelatedDocs"
|
||||
/>
|
||||
|
||||
<utility
|
||||
component=".handlers.MailIdHandler"
|
||||
name="themis.fields.MailId"
|
||||
|
|
|
@ -3,7 +3,7 @@ from zope.interface import Interface
|
|||
from zope.schema.interfaces import IChoice, IField, IList, IDate
|
||||
from zope import schema
|
||||
from z3c.form.interfaces import IOrderedSelectWidget, ITextWidget
|
||||
from z3c.relationfield.interfaces import IRelation
|
||||
from z3c.relationfield.interfaces import IRelation, IRelationList
|
||||
|
||||
class ICommission(IField):
|
||||
'''Field containing a unicode string without newlines that is a commission.'''
|
||||
|
@ -94,6 +94,21 @@ class IRelatedDoc(IRelation):
|
|||
description=IField['missing_value'].description,
|
||||
required=False)
|
||||
|
||||
|
||||
class IRelatedDocs(IRelationList):
|
||||
default = schema.Text(
|
||||
title=IField['default'].title,
|
||||
description=IField['default'].description,
|
||||
required=False)
|
||||
|
||||
missing_value = schema.Text(
|
||||
title=IField['missing_value'].title,
|
||||
description=IField['missing_value'].description,
|
||||
required=False)
|
||||
|
||||
|
||||
|
||||
|
||||
class IMailId(IField):
|
||||
default = schema.Text(
|
||||
description=IField['default'].description,
|
||||
|
|
|
@ -21,6 +21,7 @@ from themis.fields.interfaces import IMinistry, IMinistries
|
|||
from themis.fields.interfaces import IDeputyOrMinistry, IDeputiesOrMinistries
|
||||
from themis.fields.interfaces import IOrderedSelectAndAddWidget
|
||||
from themis.fields.interfaces import IRelatedDoc
|
||||
from themis.fields.interfaces import IRelatedDocs
|
||||
from themis.fields.interfaces import IMailId, IMailIdWidget
|
||||
from themis.fields.interfaces import IMailRefId, IMailRefIdWidget
|
||||
|
||||
|
@ -33,7 +34,7 @@ from z3c.form.browser.checkbox import CheckBoxWidget
|
|||
from z3c.form.browser.select import SelectWidget
|
||||
from z3c.form.browser.text import TextWidget
|
||||
from z3c.form.browser.radio import RadioWidget
|
||||
from plone.formwidget.contenttree.widget import ContentTreeWidget
|
||||
from plone.formwidget.contenttree.widget import ContentTreeWidget, MultiContentTreeWidget
|
||||
|
||||
@adapter(ICommission, IFormLayer)
|
||||
@implementer(IFieldWidget)
|
||||
|
@ -188,6 +189,7 @@ class OrderedSelectAndAddWidget(OrderedSelectWidget):
|
|||
self._bound_source = source
|
||||
return self._bound_source
|
||||
|
||||
|
||||
@adapter(IRelatedDoc, IFormLayer)
|
||||
@implementer(IFieldWidget)
|
||||
def RelatedDocFieldWidget(field, request):
|
||||
|
@ -195,6 +197,14 @@ def RelatedDocFieldWidget(field, request):
|
|||
return FieldWidget(field, ContentTreeWidget(request))
|
||||
|
||||
|
||||
@adapter(IRelatedDocs, IFormLayer)
|
||||
@implementer(IFieldWidget)
|
||||
def RelatedDocsFieldWidget(field, request):
|
||||
'''IFieldWidget factory for RelatedDocsWidget'''
|
||||
return FieldWidget(field, MultiContentTreeWidget(request))
|
||||
|
||||
|
||||
|
||||
class MailIdWidget(TextWidget):
|
||||
implements(IMailIdWidget)
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
<adapter factory=".widgets.DateFieldWidget"/>
|
||||
<adapter factory=".widgets.RadioChoiceFieldWidget"/>
|
||||
<adapter factory=".widgets.RelatedDocFieldWidget"/>
|
||||
<adapter factory=".widgets.RelatedDocsFieldWidget"/>
|
||||
<adapter factory=".widgets.MailIdFieldWidget"/>
|
||||
<adapter factory=".widgets.MailRefIdFieldWidget"/>
|
||||
|
||||
|
|
Reference in New Issue