class IMoveItemsSchema(Interface): destination_folder = RelationChoice( title=_('label_destination', default="Destination"), description=_('help_destination', default="Live Search: search the Plone Site"), source=RepositoryPathSourceBinder( object_provides=[ 'opengever.dossier.behaviors.dossier.IDossierMarker', 'opengever.repository.repositoryfolder.IRepositoryFolderSchema' ], navigation_tree_query={ 'object_provides': [ 'opengever.repository.repositoryroot.IRepositoryRoot', 'opengever.repository.repositoryfolder.IRepositoryFolderSchema', 'opengever.dossier.behaviors.dossier.IDossierMarker', ], 'review_state': DOSSIER_STATES_OPEN + [ 'repositoryfolder-state-active', 'repositoryroot-state-active' ] }, review_state=DOSSIER_STATES_OPEN + [ 'repositoryfolder-state-active', 'repositoryroot-state-active', ], ), required=True, ) # We Use TextLine here because Tuple and List have no hidden_mode. request_paths = schema.TextLine(title=u"request_paths")
class ISaveAsPdfSchema(Interface): destination_folder = RelationChoice( title=_('label_destination', default="Destination"), description=_('help_destination', default="Live Search: search for the dossier"), 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', ], 'review_state': DOSSIER_STATES_OPEN + [ 'repositoryfolder-state-active', 'repositoryroot-state-active' ] }), required=True, ) version_id = Int( title=_('version_id', default='Document Version'), required=False, )
class IChooseDossierSchema(Schema): dossier = RelationChoice( title=_(u'label_accept_select_dossier', default=u'Target dossier'), description=_(u'help_accept_select_dossier', default=u'Select the target dossier where you like to ' 'handle the task.'), required=True, source=RepositoryPathSourceBinder( object_provides='opengever.dossier.behaviors.dossier.' 'IDossierMarker', review_state=DOSSIER_STATES_OPEN, navigation_tree_query={ 'object_provides': [ 'opengever.repository.repositoryroot.IRepositoryRoot', 'opengever.repository.repositoryfolder.' 'IRepositoryFolderSchema', 'opengever.dossier.behaviors.dossier.IDossierMarker', ], 'review_state': [ 'repositoryroot-state-active', 'repositoryfolder-state-active' ] + DOSSIER_STATES_OPEN, }))
class IRelatedDocuments(model.Schema): """The 'Related documents' behvavior is an opengever.document specific 'Related items' behavior. Only allows references to opengever.documents. """ form.order_after(relatedItems='IDocumentMetadata.preserved_as_paper') relatedItems = RelationList( title=_(u'label_related_documents', default=u'Related Documents'), default=[], missing_value=[], value_type=RelationChoice( title=u"Related", source=RepositoryPathSourceBinder( portal_type=("opengever.document.document", "ftw.mail.mail"), navigation_tree_query={ 'object_provides': ['opengever.repository.repositoryroot.IRepositoryRoot', 'opengever.repository.repositoryfolder.' + 'IRepositoryFolderSchema', 'opengever.dossier.behaviors.dossier.IDossierMarker', 'opengever.document.document.IDocumentSchema', 'ftw.mail.mail.IMail', ] }), ), required=False, ) model.fieldset( u'common', label=_(u'fieldset_common', default=u'Common'), fields=[ u'relatedItems', ], )
class IRelatedDocuments(form.Schema): """The relatedDocument behvavior is a opengever.document specific relateditems behavior. Only allows opengever.documents """ relatedItems = RelationList( title=_(u'label_related_documents', default=u'Related Documents'), default=[], value_type=RelationChoice( title=u"Related", source=RepositoryPathSourceBinder( portal_type=("opengever.document.document", "ftw.mail.mail"), navigation_tree_query={ 'object_provides': [ 'opengever.repository.repositoryroot.IRepositoryRoot', 'opengever.repository.repositoryfolder.' + 'IRepositoryFolderSchema', 'opengever.dossier.behaviors.dossier.IDossierMarker', 'opengever.document.document.IDocumentSchema', 'ftw.mail.mail.IMail', ] }), ), required=False, ) form.fieldset( u'common', label=_(u'fieldset_common', default=u'Common'), fields=[ u'relatedItems', ], )
def test_navigation_tree_query_is_limited_to_current_repository(self): source_binder = RepositoryPathSourceBinder() source = source_binder(self.repofolder1_1) self.assertEqual({'query': '/plone/ordnungssystem1'}, source.navigation_tree_query['path']) source = source_binder(self.repofolder1) self.assertEqual({'query': '/plone/ordnungssystem1'}, source.navigation_tree_query['path'])
def test_sourcebinder(self): """ Check if SourceBinder works correctly without a querymodificator """ query = RepositoryPathSourceBinder()(self.repofolder2_1) self.assertEqual(query.navigation_tree_query['path'], {'query': '/plone/ordnungssystem1'}) self.assertEqual( len(query.catalog.searchResults(query.navigation_tree_query)), 5)
def test_navigation_tree_query_is_limited_to_current_repository(self): self.login(self.regular_user) source_binder = RepositoryPathSourceBinder() source = source_binder(self.branch_repofolder) self.assertEqual({'query': '/plone/ordnungssystem'}, source.navigation_tree_query['path']) source = source_binder(self.leaf_repofolder) self.assertEqual({'query': '/plone/ordnungssystem'}, source.navigation_tree_query['path'])
class IChooseDossierSchema(Schema): dossier = RelationChoice( title=_(u'label_dossier', default=u'Dossier'), 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)
class ISelectRepositoryfolderSchema(Schema): repositoryfolder = RelationChoice( title=_(u'label_accept_select_repositoryfolder', default=u'Repository folder'), description=_(u'help_accept_select_repositoryfolder', default=u'Select the repository folder within the ' 'dossier should be created.'), required=True, source=RepositoryPathSourceBinder( object_provides='opengever.repository.repositoryfolder.' 'IRepositoryFolderSchema', navigation_tree_query={ 'object_provides': [ 'opengever.repository.repositoryroot.IRepositoryRoot', 'opengever.repository.repositoryfolder.' 'IRepositoryFolderSchema', ] }))
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."))
sablon_template_source = ObjPathSourceBinder( portal_type=("opengever.meeting.sablontemplate"), navigation_tree_query={ 'object_provides': [ 'opengever.dossier.templatefolder.interfaces.ITemplateFolder', 'opengever.meeting.sablontemplate.ISablonTemplate', ], }) all_open_dossiers_source = RepositoryPathSourceBinder( object_provides='opengever.dossier.behaviors.dossier.IDossierMarker', review_state=DOSSIER_STATES_OPEN, navigation_tree_query={ 'object_provides': [ 'opengever.repository.repositoryroot.IRepositoryRoot', 'opengever.repository.repositoryfolder.' 'IRepositoryFolderSchema', 'opengever.dossier.behaviors.dossier.IDossierMarker', ], 'review_state': ['repositoryroot-state-active', 'repositoryfolder-state-active'] + DOSSIER_STATES_OPEN, }) repository_folder_source = RepositoryPathSourceBinder( object_provides= 'opengever.repository.repositoryfolder.IRepositoryFolderSchema', review_state='repositoryfolder-state-active', navigation_tree_query={ 'object_provides': [ 'opengever.repository.repositoryroot.IRepositoryRoot', 'opengever.repository.repositoryfolder.IRepositoryFolderSchema',