Beispiel #1
0
class IOGMail(form.Schema):
    """Opengever specific behavior,
    which add a title Field to the form.
    """

    form.fieldset(
        u'common',
        label=base_mf(u'fieldset_common', u'Common'),
        fields=[u'title', 'original_message', 'message_source'])

    form.order_before(title='message')
    dexteritytextindexer.searchable('title')
    title = schema.TextLine(
        title=dossier_mf(u'label_title', default=u'Title'),
        required=False,
    )

    form.mode(original_message=DISPLAY_MODE)
    form.read_permission(original_message='cmf.ManagePortal')
    form.write_permission(original_message='cmf.ManagePortal')
    original_message = field.NamedBlobFile(
        title=_(u'label_original_message',
                default=u'Raw *.msg message before conversion'),
        required=False,
    )

    form.mode(message_source=DISPLAY_MODE)
    form.read_permission(message_source='cmf.ManagePortal')
    form.write_permission(message_source='cmf.ManagePortal')
    message_source = schema.Choice(
        title=_('label_message_source',
                default='Message source'),
        vocabulary=get_message_source_vocabulary(),
        required=False,
    )
Beispiel #2
0
class ICustomScript(IAction):
    """Executes a Python script for form data"""
    form.read_permission(ProxyRole=MODIFY_PORTAL_CONTENT)
    form.write_permission(ProxyRole=EDIT_PYTHON_PERMISSION)
    ProxyRole = Choice(
        title=_(u'label_script_proxy', default=u'Proxy role'),
        description=_(u'help_script_proxy',
                      default=u'Role under which to run the script.'),
        default=u'none',
        required=True,
        vocabulary=getProxyRoleChoices,
    )
    form.read_permission(ScriptBody=MODIFY_PORTAL_CONTENT)
    form.write_permission(ScriptBody=EDIT_PYTHON_PERMISSION)
    ScriptBody = Text(
        title=_(u'label_script_body', default=u'Script body'),
        description=_(u'help_script_body', default=u'Write your script here.'),
        default=DEFAULT_SCRIPT,
        required=False,
        missing_value=u'',
    )
        class IDummy(form.Schema):

            form.omitted('foo')
            form.omitted('bar')
            form.widget(foo='some.dummy.Widget')
            form.widget(baz='other.Widget')
            form.mode(bar='hidden')
            form.mode(foo='display')
            form.order_before(baz='title')
            form.order_after(baz='qux')
            form.order_after(qux='bar')
            form.order_before(foo='body')
            form.read_permission(foo='zope2.View', bar='zope2.View')
            form.read_permission(baz='random.Permission')
            form.write_permission(foo='cmf.ModifyPortalContent')
            form.write_permission(baz='another.Permission')

            foo = zope.schema.TextLine(title=u"Foo")
            bar = zope.schema.TextLine(title=u"Bar")
            baz = zope.schema.TextLine(title=u"Baz")
            qux = zope.schema.TextLine(title=u"Qux")
class IActionExtender(form.Schema):
    form.fieldset(u'overrides', label=_('Overrides'), fields=['execCondition'])
    form.read_permission(execCondition=MODIFY_PORTAL_CONTENT)
    form.write_permission(execCondition=EDIT_TALES_PERMISSION)
    execCondition = TextLine(
        title=_(u'label_execcondition_text', default=u'Execution Condition'),
        description=(_(u'help_execcondition_text', default=u''
                       u'A TALES expression that will be evaluated to determine whether '
                       u'or not to execute this action. Leave empty if unneeded, and '
                       u'the action will be executed. Your expression should evaluate '
                       u'as a boolean; return True if you wish the action to execute. '
                       u'PLEASE NOTE: errors in the evaluation of this expression will '
                       u'cause an error on form display.')
                     ),
        default=u'',
        constraint=isTALES,
        required=False,
    )
Beispiel #5
0
class IEnhancedUserDataSchema(model.Schema):
    """ Use all the fields from the default user data schema, and add various
    extra fields.
    """
    tipoUsuario = schema.Set(
        title=u'Tipo de usuario',
        description=u'Si desea marcar más de una opcion, oprima CTRL+Click',
        value_type=schema.Choice(values=[
            'Seleccione una opcion',
            'Alumno',
            'Docente',
            'Investigador',
            'Otro',
        ], ),
        required=True,
    )

    form.write_permission(participaEn='cmf.ManagePortal')
    participaEn = schema.Set(
        title=u'Colecciones de su interés',
        description=
        u"Elija la o las Colecciones en las que desea participar. Si desea marcar más de una opcion, oprima CTRL+Click",
        value_type=schema.Choice(source="ColeccionesVocab"),
        required=False,
    )

    enlaceCV = schema.Text(
        title=_(u'Enlace a su Perfil', default=u'Enlace al perfil de memoria'),
        description=_(
            u'enlace_perfil',
            default=u"Copie la URL de su perfil en Memoria Académica."),
        required=False,
    )
    form.status = u"Ud está asignado a "
    accept = schema.Bool(
        title=_(u'label_accept', default=u'Accept terms of use'),
        description=_(u'help_accept',
                      default=u"Tick this box to indicate that you have found,"
                      " read and accepted the terms of use for this site. "),
        required=True,
        constraint=validateAccept,
    )
Beispiel #6
0
class IMailer(IAction):
    """A form action adapter that will e-mail form input."""
    #     default_method='getDefaultRecipientName',
    form.write_permission(recipient_name=EDIT_ADDRESSING_PERMISSION)
    form.read_permission(recipient_name=MODIFY_PORTAL_CONTENT)
    recipient_name = TextLine(
        title=_(u'label_formmailer_recipient_fullname',
                default=u"Recipient's full name"),
        description=_(
            u'help_formmailer_recipient_fullname',
            default=u'The full name of the recipient of the mailed form.'),
        default=u'',
        missing_value=u'',
        required=False,
    )
    #     default_method='getDefaultRecipient',
    #     validators=('isEmail',),
    #     TODO defaultFactory
    #     TODO IContextAwareDefaultFactory
    form.write_permission(recipient_email=EDIT_ADDRESSING_PERMISSION)
    form.read_permission(recipient_email=MODIFY_PORTAL_CONTENT)
    recipient_email = TextLine(
        title=_(u'label_formmailer_recipient_email',
                default=u"Recipient's e-mail address"),
        description=_(u'help_formmailer_recipient_email',
                      default=u'The recipients e-mail address.'),
        default=u'',
        missing_value=u'',
        required=False,
    )
    form.fieldset(u'addressing',
                  label=_('Addressing'),
                  fields=[
                      'to_field', 'cc_recipients', 'bcc_recipients',
                      'replyto_field'
                  ])
    form.write_permission(to_field=EDIT_ADVANCED_PERMISSION)
    form.read_permission(to_field=MODIFY_PORTAL_CONTENT)
    to_field = Choice(
        title=_(u'label_formmailer_to_extract',
                default=u'Extract Recipient From'),
        description=_(
            u'help_formmailer_to_extract',
            default=u''
            u'Choose a form field from which you wish to extract '
            u'input for the To header. If you choose anything other '
            u'than "None", this will override the "Recipient\'s e-mail address" '
            u'setting above. Be very cautious about allowing unguarded user '
            u'input for this purpose.'),
        required=False,
        vocabulary=fieldsFactory,
    )
    #     default_method='getDefaultCC',
    form.write_permission(cc_recipients=EDIT_ADDRESSING_PERMISSION)
    form.read_permission(cc_recipients=MODIFY_PORTAL_CONTENT)
    cc_recipients = Text(
        title=_(u'label_formmailer_cc_recipients', default=u'CC Recipients'),
        description=_(
            u'help_formmailer_cc_recipients',
            default=u'E-mail addresses which receive a carbon copy.'),
        default=u'',
        missing_value=u'',
        required=False,
    )
    #     default_method='getDefaultBCC',
    form.write_permission(bcc_recipients=EDIT_ADDRESSING_PERMISSION)
    form.read_permission(bcc_recipients=MODIFY_PORTAL_CONTENT)
    bcc_recipients = Text(
        title=_(u'label_formmailer_bcc_recipients', default=u'BCC Recipients'),
        description=_(
            u'help_formmailer_bcc_recipients',
            default=u'E-mail addresses which receive a blind carbon copy.'),
        default=u'',
        missing_value=u'',
        required=False,
    )
    form.write_permission(replyto_field=EDIT_ADVANCED_PERMISSION)
    form.read_permission(replyto_field=MODIFY_PORTAL_CONTENT)
    replyto_field = Choice(
        title=_(u'label_formmailer_replyto_extract',
                default=u'Extract Reply-To From'),
        description=_(
            u'help_formmailer_replyto_extract',
            default=u''
            u'Choose a form field from which you wish to extract '
            u'input for the Reply-To header. NOTE: You should '
            u'activate e-mail address verification for the designated '
            u'field.'),
        required=False,
        vocabulary=fieldsFactory,
    )
    form.fieldset(u'message',
                  label=PMF('Message'),
                  fields=[
                      'msg_subject', 'subject_field', 'body_pre', 'body_post',
                      'body_footer', 'showAll', 'showFields', 'includeEmpties'
                  ])
    form.read_permission(msg_subject=MODIFY_PORTAL_CONTENT)
    msg_subject = TextLine(
        title=_(u'label_formmailer_subject', default=u'Subject'),
        description=_(u'help_formmailer_subject',
                      default=u''
                      u'Subject line of message. This is used if you '
                      u'do not specify a subject field or if the field '
                      u'is empty.'),
        default=u'Form Submission',
        missing_value=u'',
        required=False,
    )
    form.write_permission(subject_field=EDIT_ADVANCED_PERMISSION)
    form.read_permission(subject_field=MODIFY_PORTAL_CONTENT)
    subject_field = Choice(
        title=_(u'label_formmailer_subject_extract',
                default=u'Extract Subject From'),
        description=_(u'help_formmailer_subject_extract',
                      default=u''
                      u'Choose a form field from which you wish to extract '
                      u'input for the mail subject line.'),
        required=False,
        vocabulary=fieldsFactory,
    )
    #     accessor='getBody_pre',
    form.read_permission(body_pre=MODIFY_PORTAL_CONTENT)
    body_pre = Text(
        title=_(u'label_formmailer_body_pre', default=u'Body (prepended)'),
        description=_(u'help_formmailer_body_pre',
                      default=u'Text prepended to fields listed in mail-body'),
        default=u'',
        missing_value=u'',
        required=False,
    )
    form.read_permission(body_post=MODIFY_PORTAL_CONTENT)
    body_post = Text(
        title=_(u'label_formmailer_body_post', default=u'Body (appended)'),
        description=_(u'help_formmailer_body_post',
                      default=u'Text appended to fields listed in mail-body'),
        default=u'',
        missing_value=u'',
        required=False,
    )
    form.read_permission(body_footer=MODIFY_PORTAL_CONTENT)
    body_footer = Text(
        title=_(u'label_formmailer_body_footer', default=u'Body (signature)'),
        description=_(u'help_formmailer_body_footer',
                      default=u'Text used as the footer at '
                      u'bottom, delimited from the body by a dashed line.'),
        default=u'',
        missing_value=u'',
        required=False,
    )
    form.read_permission(showAll=MODIFY_PORTAL_CONTENT)
    showAll = Bool(
        title=_(u'label_mailallfields_text', default=u'Include All Fields'),
        description=_(u'help_mailallfields_text',
                      default=u''
                      u'Check this to include input for all fields '
                      u'(except label and file fields). If you check '
                      u'this, the choices in the pick box below '
                      u'will be ignored.'),
        default=True,
        required=False,
    )
    form.read_permission(showFields=MODIFY_PORTAL_CONTENT)
    showFields = List(
        title=_(u'label_mailfields_text', default=u'Show Responses'),
        description=_(
            u'help_mailfields_text',
            default=
            u'Pick the fields whose inputs you\'d like to include in the e-mail.'
        ),
        unique=True,
        required=False,
        value_type=Choice(vocabulary=fieldsFactory),
    )
    form.read_permission(includeEmpties=MODIFY_PORTAL_CONTENT)
    includeEmpties = Bool(
        title=_(u'label_mailEmpties_text', default=u'Include Empties'),
        description=_(u'help_mailEmpties_text',
                      default=u''
                      u'Check this to include titles '
                      u'for fields that received no input. Uncheck '
                      u'to leave fields with no input out of the e-mail.'),
        default=True,
        required=False,
    )
    form.fieldset(u'template',
                  label=PMF('Template'),
                  fields=['body_pt', 'body_type'])
    #     ZPTField('body_pt',
    #     default_method='getMailBodyDefault',
    #     validators=('zptvalidator',),
    form.write_permission(body_pt=EDIT_TALES_PERMISSION)
    form.read_permission(body_pt=MODIFY_PORTAL_CONTENT)
    body_pt = Text(
        title=_(u'label_formmailer_body_pt', default=u'Mail-Body Template'),
        description=_(
            u'help_formmailer_body_pt',
            default=u''
            u'This is a Zope Page Template '
            u'used for rendering of the mail-body. You don\'t need to modify '
            u'it, but if you know TAL (Zope\'s Template Attribute Language) '
            u'you have the full power to customize your outgoing mails.'),
        default=MAIL_BODY_DEFAULT,
        missing_value=u'',
    )
    #     default_method='getMailBodyTypeDefault',
    form.write_permission(body_type=EDIT_ADVANCED_PERMISSION)
    form.read_permission(body_type=MODIFY_PORTAL_CONTENT)
    body_type = Choice(
        title=_(u'label_formmailer_body_type', default=u'Mail Format'),
        description=_(
            u'help_formmailer_body_type',
            default=u''
            u'Set the mime-type of the mail-body. '
            u'Change this setting only if you know exactly what you are doing. '
            u'Leave it blank for default behaviour.'),
        default=u'html',
        vocabulary=MIME_LIST,
    )
    form.fieldset(u'headers',
                  label=_('Headers'),
                  fields=['xinfo_headers', 'additional_headers'])
    form.widget(xinfo_headers=CheckBoxFieldWidget)
    #     default_method='getDefaultXInfo',
    form.write_permission(xinfo_headers=EDIT_ADVANCED_PERMISSION)
    form.read_permission(xinfo_headers=MODIFY_PORTAL_CONTENT)
    xinfo_headers = List(
        title=_(u'label_xinfo_headers_text', default=u'HTTP Headers'),
        description=_(u'help_xinfo_headers_text',
                      default=u''
                      u'Pick any items from the HTTP headers that '
                      u'you\'d like to insert as X- headers in the message.'),
        unique=True,
        required=False,
        default=[u'HTTP_X_FORWARDED_FOR', u'REMOTE_ADDR', u'PATH_INFO'],
        missing_value=[u'HTTP_X_FORWARDED_FOR', u'REMOTE_ADDR', u'PATH_INFO'],
        value_type=Choice(vocabulary=XINFO_HEADERS),
    )
    #     default_method='getDefaultAddHdrs',
    form.write_permission(additional_headers=EDIT_ADVANCED_PERMISSION)
    form.read_permission(additional_headers=MODIFY_PORTAL_CONTENT)
    additional_headers = List(
        title=_(u'label_formmailer_additional_headers',
                default=u'Additional Headers'),
        description=_(
            u'help_formmailer_additional_headers',
            default=
            u'Additional e-mail-header lines. Only use RFC822-compliant headers.'
        ),
        unique=True,
        required=False,
        value_type=TextLine(title=_(u'extra_header',
                                    default=u'${name} Header',
                                    mapping={u'name': u'HTTP'}), ),
    )
    #     if gpg is not None:
    #         formMailerAdapterSchema = formMailerAdapterSchema + Schema((
    #             StringField('gpg_keyid',
    #                 schemata='encryption',
    #                 accessor='getGPGKeyId',
    #                 mutator='setGPGKeyId',
    #                 write_permission=USE_ENCRYPTION_PERMISSION,
    #                 read_permission=ModifyPortalContent,
    #                 widget=StringWidget(
    #                     description=_(u'help_gpg_key_id', default=u"""
    #                         Give your key-id, e-mail address or
    #                         whatever works to match a public key from current keyring.
    #                         It will be used to encrypt the message body (not attachments).
    #                         Contact the site administrator if you need to
    #                         install a new public key.
    #                         Note that you will probably wish to change your message
    #                         template to plain text if you're using encryption.
    #                         TEST THIS FEATURE BEFORE GOING PUBLIC!
    #                        """),
    #                    label=_(u'label_gpg_key_id', default=u'Key-Id'),
    #                    ),
    #                ),
    #            ))
    form.fieldset(u'overrides',
                  label=_('Overrides'),
                  fields=[
                      'subjectOverride', 'senderOverride', 'recipientOverride',
                      'ccOverride', 'bccOverride'
                  ])
    form.write_permission(subjectOverride=EDIT_TALES_PERMISSION)
    form.read_permission(subjectOverride=MODIFY_PORTAL_CONTENT)
    subjectOverride = TextLine(
        title=_(u'label_subject_override_text', default=u'Subject Expression'),
        description=
        _(u'help_subject_override_text',
          default=u''
          u'A TALES expression that will be evaluated to override any value '
          u'otherwise entered for the e-mail subject header. '
          u'Leave empty if unneeded. Your expression should evaluate as a string. '
          u'PLEASE NOTE: errors in the evaluation of this expression will cause '
          u'an error on form display.'),
        required=False,
        default=u'',
        missing_value=u'',
        constraint=isTALES,
    )
    form.write_permission(senderOverride=EDIT_TALES_PERMISSION)
    form.read_permission(senderOverride=MODIFY_PORTAL_CONTENT)
    senderOverride = TextLine(
        title=_(u'label_sender_override_text', default=u'Sender Expression'),
        description=
        _(u'help_sender_override_text',
          default=u''
          u'A TALES expression that will be evaluated to override the "From" header. '
          u'Leave empty if unneeded. Your expression should evaluate as a string. '
          u'PLEASE NOTE: errors in the evaluation of this expression will cause '
          u'an error on form display.'),
        required=False,
        default=u'',
        missing_value=u'',
        constraint=isTALES,
    )
    form.write_permission(recipientOverride=EDIT_TALES_PERMISSION)
    form.read_permission(recipientOverride=MODIFY_PORTAL_CONTENT)
    recipientOverride = TextLine(
        title=_(u'label_recipient_override_text',
                default=u'Recipient Expression'),
        description=
        _(u'help_recipient_override_text',
          default=u''
          u'A TALES expression that will be evaluated to override any value '
          u'otherwise entered for the recipient e-mail address. You are strongly '
          u'cautioned against using unvalidated data from the request for this purpose. '
          u'Leave empty if unneeded. Your expression should evaluate as a string. '
          u'PLEASE NOTE: errors in the evaluation of this expression will cause '
          u'an error on form display.'),
        required=False,
        default=u'',
        missing_value=u'',
        constraint=isTALES,
    )
    form.write_permission(ccOverride=EDIT_TALES_PERMISSION)
    form.read_permission(ccOverride=MODIFY_PORTAL_CONTENT)
    ccOverride = TextLine(
        title=_(u'label_cc_override_text', default=u'CC Expression'),
        description=
        _(u'help_cc_override_text',
          default=u''
          u'A TALES expression that will be evaluated to override any value '
          u'otherwise entered for the CC list. You are strongly '
          u'cautioned against using unvalidated data from the request for this purpose. '
          u'Leave empty if unneeded. Your expression should evaluate as a sequence of strings. '
          u'PLEASE NOTE: errors in the evaluation of this expression will cause '
          u'an error on form display.'),
        required=False,
        default=u'',
        missing_value=u'',
        constraint=isTALES,
    )
    form.write_permission(bccOverride=EDIT_TALES_PERMISSION)
    form.read_permission(bccOverride=MODIFY_PORTAL_CONTENT)
    bccOverride = TextLine(
        title=_(u'label_bcc_override_text', default=u'BCC Expression'),
        description=
        _(u'help_bcc_override_text',
          default=u''
          u'A TALES expression that will be evaluated to override any value '
          u'otherwise entered for the BCC list. You are strongly '
          u'cautioned against using unvalidated data from the request for this purpose. '
          u'Leave empty if unneeded. Your expression should evaluate as a sequence of strings. '
          u'PLEASE NOTE: errors in the evaluation of this expression will cause '
          u'an error on form display.'),
        required=False,
        default=u'',
        missing_value=u'',
        constraint=isTALES,
    )
Beispiel #7
0
class IFieldExtender(form.Schema):
    field_widget = Choice(
        title=_(u'label_field_widget', default=u'Field Widget'),
        description=_(u'help_field_widget', default=u''),
        required=False,
        source=widgetsFactory,
    )
    form.fieldset(u'overrides',
                  label=_('Overrides'),
                  fields=['TDefault', 'TEnabled', 'TValidator', 'serverSide'])
    form.write_permission(TDefault=EDIT_TALES_PERMISSION)
    TDefault = TextLine(
        title=_(u'label_tdefault_text', default=u'Default Expression'),
        description=
        (_(u'help_tdefault_text',
           default=u''
           u'A TALES expression that will be evaluated when the form is displayed '
           u'to get the field default value. '
           u'Leave empty if unneeded. Your expression should evaluate as a string. '
           u'PLEASE NOTE: errors in the evaluation of this expression will cause '
           u'an error on form display.')),
        default=u'',
        constraint=isTALES,
        required=False,
    )
    form.write_permission(TEnabled=EDIT_TALES_PERMISSION)
    TEnabled = TextLine(
        title=_(u'label_tenabled_text', default=u'Enabling Expression'),
        description=
        (_(u'help_tenabled_text',
           default=u''
           u'A TALES expression that will be evaluated when the form is displayed '
           u'to determine whether or not the field is enabled. '
           u'Your expression should evaluate as True if '
           u'the field should be included in the form, False if it should be omitted. '
           u'Leave this expression field empty if unneeded: the field will be included. '
           u'PLEASE NOTE: errors in the evaluation of this expression will cause '
           u'an error on form display.')),
        default=u'',
        constraint=isTALES,
        required=False,
    )
    form.write_permission(TValidator=EDIT_TALES_PERMISSION)
    TValidator = TextLine(
        title=_(u'label_tvalidator_text', default=u'Custom Validator'),
        description=
        (_(u'help_tvalidator_text',
           default=u''
           u'A TALES expression that will be evaluated when the form is validated. '
           u'Validate against \'value\', which will contain the field input. '
           u'Return False if valid; if not valid return a string error message. '
           u'E.G., "python: test(value==\'eggs\', False, \'input must be eggs\')" will '
           u'require "eggs" for input. '
           u'PLEASE NOTE: errors in the evaluation of this expression will cause '
           u'an error on form display.')),
        default=u'',
        constraint=isTALES,
        required=False,
    )
    form.write_permission(serverSide=EDIT_TALES_PERMISSION)
    serverSide = Bool(
        title=_(u'label_server_side_text', default=u'Server-Side Variable'),
        description=_(u'description_server_side_text',
                      default=u''
                      u'Mark this field as a value to be injected into the '
                      u'request form for use by action adapters and is not '
                      u'modifiable by or exposed to the client.'),
        default=False,
        required=False,
    )
    validators = List(
        title=_('Validators'),
        description=_(u'help_userfield_validators',
                      default=u'Select the validators to use on this field'),
        unique=True,
        required=False,
        value_type=Choice(vocabulary='collective.easyform.validators'),
    )
Beispiel #8
0
class IEasyForm(form.Schema):
    """Forms for Plone"""

    #     form.fieldset(u'models', label=_('Models'),
    #                   fields=['fields_model', 'actions_model'])
    form.omitted('fields_model', 'actions_model')
    fields_model = Text(
        title=_(u'Fields Model'),
        default=FIELDS_DEFAULT,
    )
    actions_model = Text(
        title=_(u'Actions Model'),
        default=ACTIONS_DEFAULT,
    )
    submitLabel = TextLine(
        title=_(u'label_submitlabel_text', default=u'Submit Button Label'),
        description=_(u'help_submitlabel_text', default=u''),
        default=u'Submit',
        required=False,
    )
    useCancelButton = Bool(
        title=_(u'label_showcancel_text', default=u'Show Reset Button'),
        description=_(u'help_showcancel_text', default=u''),
        default=False,
        required=False,
    )
    resetLabel = TextLine(
        title=_(u'label_reset_button', default=u'Reset Button Label'),
        description=_(u'help_reset_button', default=u''),
        default=u'Reset',
        required=False,
    )
    method = Choice(
        title=_(u'label_method', default=u'Form method'),
        description=_(u'help_method', default=u''),
        default=u'post',
        required=False,
        vocabulary=FORM_METHODS,
    )
    form_tabbing = Bool(
        title=_(u'label_form_tabbing', default=u'Turn fieldsets to tabs'),
        description=_(u'help_form_tabbing', default=u''),
        default=True,
        required=False,
    )
    default_fieldset_label = TextLine(
        title=_(u'label_default_fieldset_label_text',
                default=u'Custom Default Fieldset Label'),
        description=_(
            u'help_default_fieldset_label_text',
            default=u'This field allows you to change default fieldset label.'
        ),
        required=False,
        default=u'',
    )
    unload_protection = Bool(
        title=_(u'label_unload_protection', default=u'Unload protection'),
        description=_(u'help_unload_protection', default=u''),
        default=True,
        required=False,
    )
    CSRFProtection = Bool(
        title=_(u'label_csrf', default=u'CSRF Protection'),
        description=_(u'help_csrf',
                      default=u'Check this to employ Cross-Site '
                      u'Request Forgery protection. Note that only HTTP Post '
                      u'actions will be allowed.'),
        default=True,
        required=False,
    )
    form.write_permission(forceSSL=EDIT_ADVANCED_PERMISSION)
    forceSSL = Bool(
        title=_(u'label_force_ssl', default=u'Force SSL connection'),
        description=_(
            u'help_force_ssl',
            default=u''
            u'Check this to make the form redirect to an SSL-enabled '
            u'version of itself (https://) if accessed via a non-SSL '
            u'URL (http://).  In order to function properly, '
            u'this requires a web server that has been configured to '
            u'handle the HTTPS protocol on port 443 and forward it to Zope.'),
        default=False,
        required=False,
    )
    formPrologue = RichText(
        title=_(u'label_prologue_text', default=u'Form Prologue'),
        description=_(
            u'help_prologue_text',
            default=u'This text will be displayed above the form fields.'),
        required=False,
    )
    formEpilogue = RichText(
        title=_(u'label_epilogue_text', default=u'Form Epilogue'),
        description=_(
            u'help_epilogue_text',
            default=u'The text will be displayed after the form fields.'),
        required=False,
    )
    form.fieldset(u'overrides',
                  label=_('Overrides'),
                  fields=[
                      'thanksPageOverrideAction', 'thanksPageOverride',
                      'formActionOverride', 'onDisplayOverride',
                      'afterValidationOverride', 'headerInjection',
                      'submitLabelOverride'
                  ])
    form.write_permission(thanksPageOverrideAction=EDIT_TALES_PERMISSION)
    thanksPageOverrideAction = Choice(
        title=_(u'label_thankspageoverrideaction_text',
                default=u'Custom Success Action Type'),
        description=_(
            u'help_thankspageoverrideaction_text',
            default=u''
            u'Use this field in place of a thanks-page designation '
            u'to determine final action after calling '
            u'your action adapter (if you have one). You would usually use '
            u'this for a custom success template or script. '
            u'Leave empty if unneeded. Otherwise, specify as you would a '
            u'CMFFormController action type and argument, '
            u'complete with type of action to execute '
            u'(e.g., "redirect_to" or "traverse_to") '
            u'and a TALES expression. For example, '
            u'"Redirect to" and "string:thanks-page" would redirect to '
            u'"thanks-page".'),
        default=u'redirect_to',
        required=False,
        vocabulary=customActions,
    )
    form.write_permission(thanksPageOverride=EDIT_TALES_PERMISSION)
    thanksPageOverride = TextLine(
        title=_(u'label_thankspageoverride_text',
                default=u'Custom Success Action'),
        description=_(
            u'help_thankspageoverride_text',
            default=u''
            u'Use this field in place of a thanks-page designation '
            u'to determine final action after calling '
            u'your action adapter (if you have one). You would usually use '
            u'this for a custom success template or script. '
            u'Leave empty if unneeded. Otherwise, specify as you would a '
            u'CMFFormController action type and argument, '
            u'complete with type of action to execute '
            u'(e.g., "redirect_to" or "traverse_to") '
            u'and a TALES expression. For example, '
            u'"Redirect to" and "string:thanks-page" would redirect to '
            u'"thanks-page".'),
        default=u'',
        constraint=isTALES,
        required=False,
    )
    form.write_permission(formActionOverride=EDIT_TALES_PERMISSION)
    formActionOverride = TextLine(
        title=_(u'label_formactionoverride_text',
                default=u'Custom Form Action'),
        description=_(u'help_formactionoverride_text',
                      default=u''
                      u'Use this field to override the form action attribute. '
                      u'Specify a URL to which the form will post. '
                      u'This will bypass form validation, success action '
                      u'adapter and thanks page.'),
        default=u'',
        required=False,
        constraint=isTALES,
    )
    form.write_permission(onDisplayOverride=EDIT_TALES_PERMISSION)
    onDisplayOverride = TextLine(
        title=_(u'label_OnDisplayOverride_text', default=u'Form Setup Script'),
        description=_(
            u'help_OnDisplayOverride_text',
            default=u''
            u'A TALES expression that will be called when the form is '
            u'displayed. '
            u'Leave empty if unneeded. '
            u'The most common use of this field is to call a python script '
            u'that sets defaults for multiple fields by pre-populating '
            u'request.form. '
            u'Any value returned by the expression is ignored. '
            u'PLEASE NOTE: errors in the evaluation of this expression '
            u'will cause an error on form display.'),
        constraint=isTALES,
        required=False,
        default=u'',
    )
    form.write_permission(afterValidationOverride=EDIT_TALES_PERMISSION)
    afterValidationOverride = TextLine(
        title=_(u'label_AfterValidationOverride_text',
                default=u'After Validation Script'),
        description=_(
            u'help_AfterValidationOverride_text',
            default=u''
            u'A TALES expression that will be called after the form is'
            u'successfully validated, but before calling an action adapter'
            u'(if any) or displaying a thanks page.'
            u'Form input will be in the request.form dictionary.'
            u'Leave empty if unneeded.'
            u'The most common use of this field is to call a python script'
            u'to clean up form input or to script an alternative action.'
            u'Any value returned by the expression is ignored.'
            u'PLEASE NOTE: errors in the evaluation of this expression will'
            u'cause an error on form display.'),
        constraint=isTALES,
        required=False,
        default=u'',
    )
    form.write_permission(headerInjection=EDIT_TALES_PERMISSION)
    headerInjection = TextLine(
        title=_(u'label_headerInjection_text', default=u'Header Injection'),
        description=_(
            u'help_headerInjection_text',
            default=u''
            u'This override field allows you to insert content into the xhtml '
            u'head. The typical use is to add custom CSS or JavaScript. '
            u'Specify a TALES expression returning a string. The string will '
            u'be inserted with no interpretation. '
            u'PLEASE NOTE: errors in the evaluation of this expression will '
            u'cause an error on form display.'),
        constraint=isTALES,
        required=False,
        default=u'',
    )
    form.write_permission(submitLabelOverride=EDIT_TALES_PERMISSION)
    submitLabelOverride = TextLine(
        title=_(u'label_submitlabeloverride_text',
                default=u'Custom Submit Button Label'),
        description=_(
            u'help_submitlabeloverride_text',
            default=u''
            u'This override field allows you to change submit button label. '
            u'The typical use is to set label with request parameters. '
            u'Specify a TALES expression returning a string. '
            u'PLEASE NOTE: errors in the evaluation of this expression will '
            u'cause an error on form display.'),
        constraint=isTALES,
        required=False,
        default=u'',
    )
    form.fieldset(u'thankyou',
                  label=_('Thanks Page'),
                  fields=[
                      'thankstitle', 'thanksdescription', 'showAll',
                      'showFields', 'includeEmpties', 'thanksPrologue',
                      'thanksEpilogue'
                  ])
    thankstitle = TextLine(title=_(u'label_thankstitle',
                                   default=u'Thanks title'),
                           default=u'Thank You',
                           required=True)
    thanksdescription = Text(
        title=_(u'label_thanksdescription', default=u'Thanks summary'),
        description=_(u'help_thanksdescription',
                      default=u'Used in thanks page.'),
        default=u'Thanks for your input.',
        required=False,
        missing_value=u'',
    )
    #     TODO
    #     obj.setTitle(_(u'pfg_thankyou_title', u'Thank You'))
    #     obj.setDescription(_(u'pfg_thankyou_description', u'Thanks for your input.'))
    showAll = Bool(
        title=_(u'label_showallfields_text', default=u'Show All Fields'),
        description=_(u'help_showallfields_text',
                      default=u''
                      u'Check this to display input for all fields '
                      u'(except label and file fields). If you check '
                      u'this, the choices in the pick box below '
                      u'will be ignored.'),
        default=True,
        required=False,
    )
    showFields = List(
        title=_(u'label_showfields_text', default=u'Show Responses'),
        description=_(
            u'help_showfields_text',
            default=
            u'Pick the fields whose inputs you\'d like to display on the success page.'
        ),
        unique=True,
        required=False,
        value_type=Choice(vocabulary=fieldsFactory),
    )
    includeEmpties = Bool(
        title=_(u'label_includeEmpties_text', default=u'Include Empties'),
        description=_(u'help_includeEmpties_text',
                      default=u''
                      u'Check this to display field titles '
                      u'for fields that received no input. Uncheck '
                      u'to leave fields with no input off the list.'),
        default=True,
        required=False,
    )
    thanksPrologue = RichText(
        title=_(u'label_thanksprologue_text', default=u'Thanks Prologue'),
        description=_(
            u'help_thanksprologue_text',
            default=
            u'This text will be displayed above the selected field inputs.'),
        required=False,
    )
    thanksEpilogue = RichText(
        title=_(u'label_thanksepilogue_text', default=u'Thanks Epilogue'),
        description=_(
            u'help_thanksepilogue_text',
            default=u'The text will be displayed after the field inputs.'),
        required=False,
    )
class Ilaureando(form.Schema, IImageScaleTraversable):
    """
    studente laureando
    """

    # If you want a schema-defined interface, delete the form.model
    # line below and delete the matching file in the models sub-directory.
    # If you want a model-based interface, edit
    # models/laureando.xml to define the content type
    # and add directives here as necessary.

    laureando_name = schema.TextLine(
        title=_(u'Nome'),
        description=_(u'Inserire nome dello studente.'),
        required=True)

    laureando_surname = schema.TextLine(
        title=_(u'Cognome'),
        description=_(u'Inserire cognome dello studente.'),
        required=True)

    laureando_matricola = schema.TextLine(title=_(u'Matricola'),
                                          constraint=validatore_matricola,
                                          required=True)

    #form.read_permission(laureando_avg='laureando.privilegi_segreteria')
    form.write_permission(laureando_avg='laureando.privilegi_segreteria')
    laureando_avg = schema.Float(title=_(u'Media'), required=True)

    #form.read_permission(laureando_nlodi='laureando.privilegi_segreteria')
    #form.write_permission(laureando_nlodi='laureando.privilegi_segreteria')
    laureando_nlodi = schema.Choice(
        title=_(u'N. lodi'),
        description=_(u'Inserisci il numero di lodi.'),
        source=lista_possibili_nlodi,
        required=False)

    #form.read_permission(laureando_anno_immatricolazione='laureando.privilegi_segreteria')
    #form.write_permission(laureando_anno_immatricolazione='laureando.privilegi_segreteria')
    laureando_anno_immatricolazione = schema.Choice(
        title=_(u'Anno immatricolazione'),
        description=_(u'Seleziona anno di immatricolazione.'),
        source=years_voc,
        required=False)

    laureando_relatore = schema.Choice(
        title=_(u'Relatore'),
        description=_(u'Seleziona il relatore.'),
        source=lista_relatori,
        required=True)

    laureando_project = schema.TextLine(title=_(u'Progetto'),
                                        description=_(u'Titolo della tesi.'),
                                        required=False)

    laureando_project_description = schema.Text(
        title=_(u'Descrizione progetto'),
        description=_(u'Dettagli aggiuntivi.'),
        required=False)

    laureando_project_file = NamedFile(title=_(u'Upload della tesi.'),
                                       required=False)

    #form.read_permission(laureando_valutazione='laureando.privilegi_commissione')
    form.write_permission(
        laureando_valutazione='laureando.privilegi_commissione')
    laureando_valutazione = schema.Choice(
        title=_(u'Valutazione progetto'),
        description=_(u'Valutazione del progetto (relatore).'),
        source=lista_possibili_valutazioni,
        required=False)

    #form.omitted('laureando_voto_di_laurea')
    #form.read_permission(laureando_voto_di_laurea='laureando.privilegi_presidente')
    form.write_permission(
        laureando_voto_di_laurea='laureando.privilegi_presidente')
    laureando_voto_di_laurea = schema.Int(title=_(u'Voto di laurea'),
                                          required=False)

    #form.read_permission(laureando_lode='laureando.privilegi_presidente')
    form.write_permission(laureando_lode='laureando.privilegi_presidente')
    laureando_lode = schema.Bool(title=_(u'Lode'), required=False)
Beispiel #10
0
class IDocumentMetadata(form.Schema):
    """Schema behavior for common GEVER document metadata
    """

    form.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',
            ],
        )

    form.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,
        )