def __call__(self, context):
     self.context = context
     vocab = wrap_vocabulary(
         ContactsVocabulary.create_with_provider(
             self.key_value_provider))(context)
     vocab.hidden_terms = self.hidden_terms
     return vocab
 def __call__(self, context):
     self.context = context
     vocab = wrap_vocabulary(
         ContactsVocabulary.create_with_provider(
             self.key_value_provider))(context)
     vocab.hidden_terms = self.hidden_terms
     return vocab
 def __call__(self, context):
     """Build a vocabulary of user attributes. Get them from the
     IUserDataSchemaProvider utility and add additional ones to support
     extra functionality.
     """
     return wrap_vocabulary(
             'plone.app.vocabularies.Groups',
             hidden_terms_from_registry='collective.listusers.interfaces.IListUsersSettings.exclude_groups',
         )(context)
Beispiel #4
0
 def __call__(self, context):
     """Build a vocabulary of user attributes. Get them from the
     IUserDataSchemaProvider utility and add additional ones to support
     extra functionality.
     """
     return wrap_vocabulary(
         'plone.app.vocabularies.Groups',
         hidden_terms_from_registry=
         'collective.listusers.interfaces.IListUsersSettings.exclude_groups',
     )(context)
Beispiel #5
0
def getTaskTypeVocabulary(context):
    terms = []
    for category in TASK_TYPE_CATEGORIES:
        reg_key = 'opengever.task.interfaces.ITaskSettings.%s' % (category)

        key = 'opengever.task.%s' % (category)
        for term in wrap_vocabulary(
                key, visible_terms_from_registry=reg_key)(context):

            terms.append(term)

    return SimpleVocabulary(terms)
def translate_document_type(document_type):
    portal = getSite()
    voc = wrap_vocabulary(
        'opengever.document.document_types',
        visible_terms_from_registry='opengever.document.interfaces.'
        'IDocumentType.document_types')(portal)
    try:
        term = voc.getTerm(document_type)
    except LookupError:
        return document_type
    else:
        return term.title
Beispiel #7
0
def getTaskTypeVocabulary(context):
    terms = []
    for category in TASK_TYPE_CATEGORIES:
        reg_key = 'opengever.task.interfaces.ITaskSettings.%s' % (
            category)

        key = 'opengever.task.%s' % (category)
        for term in wrap_vocabulary(
                key, visible_terms_from_registry=reg_key)(context):

            terms.append(term)

    return SimpleVocabulary(terms)
 def __call__(self, context):
     vocab = super(SelectedOrganizationsElephantVocabulary,
                   self).__call__(context)
     terms = vocab.by_value
     ordered_terms = []
     for uid in get_registry_organizations():
         if uid in terms:
             ordered_terms.append(terms[uid])
             del terms[uid]
     extra_uids = terms.keys()
     extra_terms = terms.values()
     # ordered_vocab = SearchableSimpleVocabulary(ordered_terms + extra_terms)  # bug in widget, trac #15186
     ordered_vocab = SimpleVocabulary(ordered_terms + extra_terms)
     wrapped_vocab = wrap_vocabulary(ordered_vocab,
                                     hidden_terms=extra_uids)(context)
     return wrapped_vocab
Beispiel #9
0
def getTaskTypeVocabulary(context):
    terms = []
    for task_type in [
            'unidirectional_by_reference', 'unidirectional_by_value',
            'bidirectional_by_reference', 'bidirectional_by_value'
    ]:

        reg_key = 'opengever.task.interfaces.ITaskSettings.%s' % (task_type)

        for term in wrap_vocabulary(
                'opengever.task.%s' % (task_type),
                visible_terms_from_registry=reg_key)(context):

            terms.append(term)

    return SimpleVocabulary(terms)
Beispiel #10
0
def getTaskTypeVocabulary(context):
    terms = []
    for task_type in ['unidirectional_by_reference',
                      'unidirectional_by_value',
                      'bidirectional_by_reference',
                      'bidirectional_by_value']:

        reg_key = 'opengever.task.interfaces.ITaskSettings.%s' % (
            task_type)

        for term in wrap_vocabulary(
            'opengever.task.%s' % (task_type),
            visible_terms_from_registry=reg_key)(context):

            terms.append(term)

    return SimpleVocabulary(terms)
Beispiel #11
0
def AvailableTimezones(context, query=None):
    """Vocabulary for available timezones, as set by in the controlpanel.

    This vocabulary is based on collective.elephantvocabulary. The reason is,
    that if timezones are used in events or in user's settings and later
    retracted by the portal manager, they should still be usable for those
    objects but not selectable in forms.

    Note: after setting available_timezones, this vocabulary must be
    reinstantiated to reflect the changes.
    """
    # TODO: if the portal_timezone is not in available_timezones, also put it
    #       in AvailableTimezone vocab.
    tzvocab = getUtility(IVocabularyFactory,
                         'plone.app.event.Timezones')(context, query)
    return wrap_vocabulary(
        tzvocab,
        visible_terms_from_registry='plone.app.event.available_timezones'
    )(context)
Beispiel #12
0
def AvailableTimezones(context, query=None):
    """Vocabulary for available timezones, as set by in the controlpanel.

    This vocabulary is based on collective.elephantvocabulary. The reason is,
    that if timezones are used in events or in user's settings and later
    retracted by the portal manager, they should still be usable for those
    objects but not selectable in forms.

    Note: after setting available_timezones, this vocabulary must be
    reinstantiated to reflect the changes.
    """
    # TODO: if the portal_timezone is not in available_timezones, also put it
    #       in AvailableTimezone vocab.
    tzvocab = getUtility(IVocabularyFactory,
                         'plone.app.event.Timezones')(context, query)
    return wrap_vocabulary(
        tzvocab,
        visible_terms_from_registry='plone.app.event.available_timezones')(
            context)
Beispiel #13
0
class IParticipation(model.Schema):
    """ Participation Form schema
    """

    contact = schema.Choice(
        title=_(u'label_contact', default=u'Contact'),
        source=ContactsSourceBinder(),
        required=True,
    )

    roles = schema.List(
        title=_(u'label_roles', default=u'Roles'),
        value_type=schema.Choice(source=wrap_vocabulary(
            'opengever.dossier.participation_roles',
            visible_terms_from_registry='opengever.dossier'
            '.interfaces.IDossierParticipants.roles'), ),
        required=True,
        missing_value=[],
    )
Beispiel #14
0
class IArchiveFormSchema(model.Schema):

    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,
        defaultFactory=filing_prefix_default,
    )

    dossier_enddate = schema.Date(
        title=_(u'label_end', default=u'Closing Date'),
        required=True,
        defaultFactory=dossier_enddate_default,
    )

    filing_year = schema.TextLine(
        title=_(u'filing_year', default="filing Year"),
        constraint=valid_filing_year,
        required=False,
        defaultFactory=filing_year_default,
    )

    filing_action = schema.Choice(
        title=_(u'filing_action', default="Action"),
        source=get_filing_actions,
        required=True,
    )

    @invariant
    def validate_field_requirement(data):
        # validat if all required fields, depends on the selectied action
        # are filled
        if data.filing_action in [METHOD_RESOLVING_AND_FILING,
                                  METHOD_FILING]:
            if not data.filing_prefix or not data.filing_year:
                raise Invalid(
                    _(u"When the Action give filing number is selected, \
                        all fields are required."))
Beispiel #15
0
class IParticipation(form.Schema):
    """ Participation Form schema
    """

    contact = schema.Choice(
        title=_(u'label_contact', default=u'Contact'),
        description=_(u'help_contact', default=u''),
        vocabulary=u'opengever.ogds.base.ContactsAndUsersVocabulary',
        required=True,
    )

    roles = schema.List(
        title=_(u'label_roles', default=u'Roles'),
        description=_(u'help_roles', default=u''),
        value_type=schema.Choice(source=wrap_vocabulary(
            'opengever.dossier.participation_roles',
            visible_terms_from_registry='opengever.dossier'
            '.interfaces.IDossierParticipants.roles'), ),
        required=True,
        missing_value=[],
    )
Beispiel #16
0
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,
    )
Beispiel #17
0
class IDocumentSchema(form.Schema):
    """ Document Schema Interface
    """

    form.fieldset(
        u'common',
        label=_(u'fieldset_common', u'Common'),
        fields=[
            u'title',
            u'description',
            u'keywords',
            u'foreign_reference',
            u'document_date',
            u'receipt_date',
            u'delivery_date',
            u'document_type',
            u'document_author',
            u'file',
            u'digitally_available',
            u'preserved_as_paper',
            u'archival_file',
            u'thumbnail',
        ],
    )

    dexteritytextindexer.searchable('title')
    title = schema.TextLine(title=_(u'label_title', default=u'Title'),
                            required=False)

    dexteritytextindexer.searchable('description')
    description = schema.Text(
        title=_(u'label_description', default=u'Description'),
        description=_(u'help_description', default=u''),
        required=False,
    )

    dexteritytextindexer.searchable('keywords')
    keywords = schema.Tuple(
        title=_(u'label_keywords', default=u'Keywords'),
        description=_(u'help_keywords', default=u''),
        value_type=schema.TextLine(),
        required=False,
        missing_value=(),
    )
    form.widget(keywords=TextLinesFieldWidget)

    foreign_reference = schema.TextLine(
        title=_(u'label_foreign_reference', default='Foreign Reference'),
        description=_('help_foreign_reference', default=''),
        required=False,
    )

    document_date = schema.Date(
        title=_(u'label_document_date', default='Document Date'),
        description=_(u'help_document_date', default=''),
        required=False,
    )

    #workaround because ftw.datepicker wasn't working
    form.widget(document_date=DatePickerFieldWidget)

    document_type = schema.Choice(
        title=_(u'label_document_type', default='Document Type'),
        description=_(u'help_document_type', default=''),
        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,
    )

    #    dexteritytextindexer.searchable('file')
    form.primary('file')
    file = NamedBlobFile(
        title=_(u'label_file', default='File'),
        description=_(u'help_file', default=''),
        required=False,
    )

    form.mode(digitally_available='hidden')
    digitally_available = schema.Bool(
        title=_(u'label_digitally_available', default='Digital Available'),
        description=_(u'help_digitally_available',
                      default='Is the Document Digital Availabe'),
        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,
        default=True,
    )

    form.omitted('archival_file')
    archival_file = NamedBlobFile(
        title=_(u'label_archival_file', default='Archival File'),
        description=_(u'help_archival_file', default=''),
        required=False,
    )

    form.omitted('thumbnail')
    thumbnail = NamedBlobFile(
        title=_(u'label_thumbnail', default='Thumbnail'),
        description=_(u'help_thumbnail', default=''),
        required=False,
    )

    form.omitted('preview')
    preview = NamedBlobFile(
        title=_(u'label_preview', default='Preview'),
        description=_(u'help_preview', default=''),
        required=False,
    )

    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(receipt_date=DatePickerFieldWidget)

    delivery_date = schema.Date(
        title=_(u'label_delivery_date', default='Date of delivery'),
        description=_(u'help_delivery_date', default=''),
        required=False,
    )
    #workaround because ftw.datepicker wasn't working
    form.widget(delivery_date=DatePickerFieldWidget)

    @invariant
    def title_or_file_required(data):
        if not data.title and not data.file:
            raise Invalid(
                _(u'error_title_or_file_required',
                  default=u'Either the title or the file is '
                  'required.'))

    @invariant
    def file_or_preserved_as_paper(data):
        """ When no digital file exist, the document must be
        preserved in paper.
        """
        if not data.file and not data.preserved_as_paper:
            raise Invalid(
                _(u'error_file_and_preserved_as_paper',
                  default=u"You don't select a file and document is also not \
                preserved in paper_form, please correct it."))
Beispiel #18
0
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."))