From a56d578fefb46eec88caf5a9f9517a003165a73f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 28 Jul 2011 15:48:04 +0200 Subject: [PATCH] Add a RelatedDocs type (not editable ttw at the moment) --- themis/fields/__init__.py | 12 +++++++++++- themis/fields/editors.py | 3 +++ themis/fields/editors.zcml | 5 +++++ themis/fields/handlers.py | 6 ++++++ themis/fields/handlers.zcml | 5 +++++ themis/fields/interfaces.py | 17 ++++++++++++++++- themis/fields/widgets.py | 12 +++++++++++- themis/fields/widgets.zcml | 1 + 8 files changed, 58 insertions(+), 3 deletions(-) diff --git a/themis/fields/__init__.py b/themis/fields/__init__.py index 0a17998..83d7951 100644 --- a/themis/fields/__init__.py +++ b/themis/fields/__init__.py @@ -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) diff --git a/themis/fields/editors.py b/themis/fields/editors.py index b7d8460..51206ad 100644 --- a/themis/fields/editors.py +++ b/themis/fields/editors.py @@ -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') diff --git a/themis/fields/editors.zcml b/themis/fields/editors.zcml index fc65989..2ba160f 100644 --- a/themis/fields/editors.zcml +++ b/themis/fields/editors.zcml @@ -77,6 +77,11 @@ component=".editors.RelatedDocFactory" /> + + + + +