class IDocumentMetadata(model.Schema): """Schema behavior for common GEVER document metadata """ model.fieldset( u'common', label=_(u'fieldset_common', u'Common'), fields=[ u'description', u'keywords', u'foreign_reference', u'document_date', u'receipt_date', u'delivery_date', u'document_type', u'document_author', u'digitally_available', u'preserved_as_paper', u'thumbnail', u'preview', ], ) model.fieldset(u'archive_file', label=_(u'fieldset_archive_file', u'Archive file'), fields=[u'archival_file']) dexteritytextindexer.searchable('description') description = schema.Text( title=_(u'label_description', default=u'Description'), required=False, missing_value=u'', ) form.widget('keywords', KeywordFieldWidget, new_terms_as_unicode=True) keywords = schema.Tuple( title=_(u'label_keywords', default=u'Keywords'), description=_(u'help_keywords', default=u''), value_type=ChoicePlus(vocabulary='plone.app.vocabularies.Keywords'), required=False, missing_value=(), default=(), ) foreign_reference = schema.TextLine( title=_(u'label_foreign_reference', default='Foreign Reference'), description=_('help_foreign_reference', default=''), required=False, ) # workaround because ftw.datepicker wasn't working form.widget(document_date=DatePickerFieldWidget) document_date = schema.Date( title=_(u'label_document_date', default='Document Date'), description=_(u'help_document_date', default=''), required=False, defaultFactory=document_date_default, ) # workaround because ftw.datepicker wasn't working form.widget(receipt_date=DatePickerFieldWidget) receipt_date = schema.Date( title=_(u'label_receipt_date', default='Date of receipt'), description=_(u'help_receipt_date', default=''), required=False, ) # workaround because ftw.datepicker wasn't working form.widget(delivery_date=DatePickerFieldWidget) delivery_date = schema.Date( title=_(u'label_delivery_date', default='Date of delivery'), description=_(u'help_delivery_date', default=''), required=False, ) document_type = schema.Choice( title=_(u'label_document_type', default='Document Type'), source=wrap_vocabulary( 'opengever.document.document_types', visible_terms_from_registry='opengever.document' + '.interfaces.IDocumentType.document_types'), required=False, ) dexteritytextindexer.searchable('document_author') document_author = schema.TextLine( title=_(u'label_author', default='Author'), description=_(u'help_author', default="Surname firstname or a userid" "(would be automatically resolved to fullname)"), required=False, ) form.mode(digitally_available='hidden') digitally_available = schema.Bool( title=_(u'label_digitally_available', default='Digital Available'), required=False, ) form.widget(preserved_as_paper=checkbox.SingleCheckBoxFieldWidget) preserved_as_paper = schema.Bool( title=_(u'label_preserved_as_paper', default='Preserved as paper'), description=_(u'help_preserved_as_paper', default=''), required=False, defaultFactory=preserved_as_paper_default, ) form.read_permission(archival_file='opengever.document.ModifyArchivalFile') form.write_permission( archival_file='opengever.document.ModifyArchivalFile') archival_file = NamedBlobFile( title=_(u'label_archival_file', default='Archival File'), description=_(u'help_archival_file', default=''), required=False, ) form.omitted('archival_file_state') archival_file_state = schema.Int( title=_(u'label_archival_file_state', default='Archival file state'), required=False, ) form.omitted('thumbnail') thumbnail = NamedBlobFile( title=_(u'label_thumbnail', default='Thumbnail'), required=False, ) form.omitted('preview') preview = NamedBlobFile( title=_(u'label_preview', default='Preview'), description=_(u'help_preview', default=''), required=False, )
class IDossier(model.Schema): """Behaviour interface for dossier types providing common properties/fields. """ model.fieldset( u'common', label=_(u'fieldset_common', u'Common'), fields=[ u'keywords', u'start', u'end', u'comments', u'external_reference', u'responsible', u'relatedDossier', ], ) form.widget('keywords', KeywordFieldWidget, new_terms_as_unicode=True, async=True) keywords = schema.Tuple( title=_(u'label_keywords', default=u'Keywords'), description=_(u'help_keywords', default=u''), value_type=ChoicePlus(source=KeywordAddableRestrictableSourceBinder()), required=False, missing_value=(), default=(), ) # workaround because ftw.datepicker wasn't working on the edit form form.widget(start=DatePickerFieldWidget) start = schema.Date( title=_(u'label_start', default=u'Opening Date'), required=False, defaultFactory=start_date_default, ) # workaround because ftw.datepicker wasn't working on the edit form form.widget(end=DatePickerFieldWidget) end = schema.Date( title=_(u'label_end', default=u'Closing Date'), required=False, ) comments = schema.Text( title=_(u'label_comments', default=u'Comments'), required=False, ) form.widget('responsible', KeywordFieldWidget, async=True) responsible = schema.Choice( title=_(u"label_responsible", default="Responsible"), source=AssignedUsersSourceBinder(), required=True, ) external_reference = schema.TextLine( title=_(u'label_external_reference', default=u'External Reference'), required=False, ) model.fieldset( u'filing', label=_(u'fieldset_filing', default=u'Filing'), fields=[ u'filing_prefix', u'container_type', u'number_of_containers', u'container_location', u'reference_number', u'former_reference_number', ], ) filing_prefix = schema.Choice( title=_(u'filing_prefix', default="filing prefix"), source=wrap_vocabulary( 'opengever.dossier.type_prefixes', visible_terms_from_registry="opengever.dossier" '.interfaces.IDossierContainerTypes.type_prefixes'), required=False, ) # needed for temporarily storing current reference number when # moving this dossier form.omitted('temporary_former_reference_number') temporary_former_reference_number = schema.TextLine( title=_(u'temporary_former_reference_number', default="Temporary former reference number"), required=False, ) container_type = schema.Choice( title=_(u'label_container_type', default=u'Container Type'), description=_(u'help_container_type', default=u''), source=wrap_vocabulary( 'opengever.dossier.container_types', visible_terms_from_registry="opengever.dossier" '.interfaces.IDossierContainerTypes.container_types'), required=False, ) number_of_containers = schema.Int( title=_(u'label_number_of_containers', default=u'Number of Containers'), description=_(u'help_number_of_containers', default=u''), required=False, ) container_location = schema.TextLine( title=_(u'label_container_location', default=u'Container Location'), description=_(u'help_container_location', default=u''), required=False, ) relatedDossier = RelationList( title=_(u'label_related_dossier', default=u'Related Dossier'), default=[], missing_value=[], value_type=RelationChoice( title=u"Related", source=RepositoryPathSourceBinder( object_provides='opengever.dossier.behaviors.dossier.' 'IDossierMarker', navigation_tree_query={ 'object_provides': [ 'opengever.repository.repositoryroot.IRepositoryRoot', 'opengever.repository.repositoryfolder.' 'IRepositoryFolderSchema', 'opengever.dossier.behaviors.dossier.IDossierMarker', ] }), ), required=False, ) form.mode(former_reference_number='display') former_reference_number = schema.TextLine( title=_(u'label_former_reference_number', default=u'Reference Number'), required=False, ) form.widget(reference_number=referenceNumberWidgetFactory) form.mode(reference_number='display') reference_number = schema.TextLine( title=_(u'label_reference_number', default=u'Reference Number'), required=False, readonly=True, ) @invariant def validate_start_end(data): # Do not get the data from the context when it is not in the current # fields / z3cform group data = data._Data_data___ if 'start' not in data or 'end' not in data: return if data['start'] is not None and data['end'] is not None: if data['start'] > data['end']: raise StartBeforeEnd( _(u"The start date must be before the end date."))