예제 #1
0
class IAnalyticBudget(model.Schema):
    """Budget field"""

    analytic_budget = schema.List(
        title=_(u"Analytic budget"),
        required=False,
        readonly=True,
        value_type=DictRow(title=_("Analytic budget"),
                           schema=IAnalyticBudgetSchema,
                           required=False),
    )
    form.widget("analytic_budget",
                AnalyticBudgetDataGridFieldFactory,
                display_table_css_class="listing nosort")

    projection = schema.List(
        title=_(u"Projection"),
        required=False,
        readonly=True,
        value_type=DictRow(title=_("Projection"),
                           schema=IProjectionSchema,
                           required=False),
    )
    form.widget("projection",
                ProjectionDataGridFieldFactory,
                display_table_css_class="listing nosort")

    form.order_before(projection='budget')
    form.order_before(analytic_budget='budget')
예제 #2
0
class ICheckliste(model.Schema):
    """ Marker interface and Dexterity Python Schema for Checkliste
    """

    text = RichText(
        title=u'Text',
        required=False
    )

    form.widget('aussagen', DataGridFieldFactory)
    aussagen = schema.List(title=u'Aussagen für die Checkliste',
        description=u'Gib hier die Aussagen ein, die der Lernende mit den nachfolgenden Optionen beantworten soll und wähle aus, ob dazu eine\
                      Notiz angefertigt werden soll. Du kannst zwischen Eingabe-Zeile und Text-Feld wählen.',
        value_type = DictRow(title=u'Aussagen', schema=IAussagen))

    summe = schema.Bool(title=u"Auswertung der Checkliste",
                        description=u"Nur bei gesetztem Haken findet eine Punkte Auswertung der Checkliste statt.",
                        default=True)

    form.widget('optionen', DataGridFieldFactory)
    optionen = schema.List(title=u'Antwortoptionen für die Checkliste',
        description=u'Gib hier die Antwortoptionen und die entsprechende Punktzahl ein. Die Punkte werden ignoriert wenn die Auswertung der\
                      Checkliste deaktiviert wurde.',
        value_type = DictRow(title=u'Antwortoptionen', schema=IOptionen))

    table = schema.Bool(title=u"Spalten mit Checkbox oder Radio-Button",
                        description=u"Bei einer Option erfolgt die Anzeige als Checkbox. Bei 2-4 Optionen besteht die Möglichkeit,\
                                      die Auswahl als Radio-Button anzuzeigen.")

    @invariant
    def table_invariant(data):
        if data.table and len(data.optionen) > 4:
            raise Invalid(u'Die Auswahl Spalten mit Checkbox oder Radio-Button darf nur bis maximal 4 Optionen aktiviert werden.')
class IFormSchema(form.Schema):
    """
    An example form with two tree selections.


    - One nested inside another datagridfield

    """

    form.widget(table=DataGridFieldFactory)
    table = schema.List(
        title=u"Tree select",
        value_type=DictRow(title=u"tablerow", schema=ITableRowSchema),
        description=u"Normal decision tree. The last columns are independent of decision tree values."
        )

    foobar = schema.Bool(title=u"Just another field")

    # Insert yo dawg joke here

    form.widget(table2=DeviceModelRowFactory)
    table2 = schema.List(
        title=u"Feature matrix: nested fixed DGF inside a DataGridField",
        value_type=DictRow(title=u"devicerow", schema=IDeviceModelRow),
        description=u"A decision tree nested inside a DGF cell. Very useful for products' feature sets' kind of data input",
        )
예제 #4
0
class IChurchBody(form.Schema, IImageScaleTraversable):
    """
    A Church Body
    """

    member_of = RelationChoice(
        title=_(u"Member Of"),
        source=ObjPathSourceBinder(
            object_provides='wcc.churchbody.churchbody.IChurchBody'),
        required=False)

    assoc_member_of = RelationChoice(
        title=_(u"Associate Member Of"),
        source=ObjPathSourceBinder(
            object_provides='wcc.churchbody.churchbody.IChurchBody'),
        required=False)

    form.widget(other_members=DataGridFieldFactory)
    other_members = schema.List(title=_(u'Other Members'),
                                value_type=DictRow(title=_(u'Member'),
                                                   schema=IOtherChurchSchema),
                                required=False)

    form.widget(other_assoc_members=DataGridFieldFactory)
    other_assoc_members = schema.List(title=_(u'Other Associate Members'),
                                      value_type=DictRow(
                                          title=_(u'Member'),
                                          schema=IOtherChurchSchema),
                                      required=False)
예제 #5
0
class IAttendee(model.Schema):
    """A conference attendee.
    """

    title = schema.TextLine(
        title=_(u"Full name"),
    )

    # Simple choice based on uuid.
    form.widget(program=ContentTreeFieldWidget)
    program = schema.Choice(
        title=_(u"Chosen Program"),
        source=UUIDSourceBinder(portal_type='example.conference.program'),
        required=False,
        )

    # Multiple choice.
    form.widget(sessions=MultiContentTreeFieldWidget)
    sessions = schema.List(
        title=_(u"Sessions you wish to attend"),
        value_type=schema.Choice(
            title=_(u"Selection"),
            source=UUIDSourceBinder(portal_type='example.conference.session')),
        required=False,
        )

    # Data grid
    if DataGridFieldFactory is not None:
        form.widget(presenters=DataGridFieldFactory)
    presenters = schema.List(
        title=_(u'Questions for presenters'),
        description=_(u"Write down a question for a presenter."),
        value_type=DictRow(title=_(u'Presenters'), schema=IPresenterInfo),
        required=False,
       )

    # Another data grid, this time we will put it in a fieldset.
    form.fieldset('remarks', label=_(u"Remarks"), fields=['remarkables'])
    if DataGridFieldFactory is not None:
        form.widget(remarkables=DataGridFieldFactory)
    remarkables = schema.List(
        title=_(u'Remarkable content'),
        description=_(u"Select a remarkable piece of content on this site "
                      u"and add a remark about it. Fine for reporting "
                      u"typos as well."),
        value_type=DictRow(title=_(u'Remarkable'), schema=IRemarkable),
        required=False,
        )
예제 #6
0
class IKermitTile(Interface):

    form.widget(value=DataGridFieldFactory)

    title = schema.TextLine(
        title=_(u"Title"),
        required=False
    )

    image = NamedBlobImage(
        title=_(u"Image"),
        description=_(u""),
        required=False,
    )

    image_alt = schema.TextLine(
        title=_(u'Image Alt Text'),
        required=False,
    )

    value = schema.List(
        title=u"Buttons",
        value_type=DictRow(title=u"Button", schema=IButtonBlockTileRowSchema),
        required=False
    )

    full_width = schema.Bool(
        title=_(u"Full Width?"),
        description=_(u""),
        required=False,
        default=True,
    )
예제 #7
0
class ICTATileBase(Interface):

    form.widget(value=DataGridFieldFactory)

    title = schema.TextLine(
        title=_(u'Title'),
        default=u'CTA Buttons',
        required=False,
    )

    background = schema.Choice(
        title=_(u"Background"),
        vocabulary='agsci.common.tiles.cta_background',
        default=u'light',
        required=True,
    )

    value = schema.List(
        title=u"Buttons",
        description=u"Default order: Orange, Green, Purple",
        value_type=DictRow(title=u"Button", schema=ICTATileRowSchema),
        required=False
    )

    full_width = schema.Bool(
        title=_(u"Full Width?"),
        description=_(u""),
        required=False,
        default=True,
    )
예제 #8
0
class IPloneRelease(Schema):
    """ A Plone release """

    version = schema.TextLine(title=_(u'Version'), required=True)
    description = schema.Text(
        title=_(u"Description"),
        required=False,
    )
    release_date = schema.Date(title=_(u'Release date'),
                               required=False,
                               default=datetime.date.today())
    release_notes = RichText(
        title=_(u'Release notes'),
        default_mime_type='text/html',
        output_mime_type='text/html',
        allowed_mime_types=('text/plain', 'text/html', 'text/restructured',
                            'text/x-web-markdown'),
        required=False,
    )
    changelog = RichText(
        title=_(u"Changelog"),
        default_mime_type='text/restructured',
        output_mime_type='text/html',
        allowed_mime_types=('text/plain', 'text/html', 'text/restructured',
                            'text/x-web-markdown'),
        required=False,
    )

    form.widget(files=DataGridFieldFactory)
    files = schema.List(title=_(u'Files'),
                        value_type=DictRow(title=_(u'Uploads'),
                                           schema=IReleaseUpload),
                        required=False)
예제 #9
0
class INewsletter(model.Schema):

    form.widget(value=DataGridFieldFactory)

    target = RelationChoice(
        title=_(u"Target Collection"),
        source=CatalogSource(object_provides=ICollection.__identifier__),
        required=False,
    )

    show_summary = schema.Choice(
        title=_(u"Enabled"),
        required=False,
        values=['yes', 'no', 'auto'],
        default='auto',
    )

    limit = schema.Choice(
        title=_(u"Months to Limit"),
        required=False,
        values=[1, 3, 6, 9, 12],
        default=1,
    )

    value = schema.List(title=u"News Items",
                        value_type=DictRow(title=u"News Item",
                                           schema=INewsletterItemsRowSchema),
                        required=False)

    listserv_email = schema.TextLine(
        title=_(u"Listserv Email"),
        description=_(u"[Listserv Name]@lists.psu.edu"),
        required=False,
    )
예제 #10
0
class IFrage(model.Schema):
    """ Marker interface and Dexterity Python Schema for Frage
    """

    fbid = schema.TextLine(title=u"Kürzel oder Nummer des Fragebogens")

    frage = RichText(
        title=u"Fragestellung",
        description=u"Bitte bearbeiten Sie hier die Frage für die Checkliste")

    thema = schema.Choice(title=u"Auswahl des Themas für die Frage",
                          source=possibleThemen,
                          required=False)

    form.widget('optionen', DataGridFieldFactory)
    optionen = schema.List(title=u"Antwortoptionen",
                           required=True,
                           value_type=DictRow(title=u"Optionen",
                                              schema=IAnswerOptions),
                           default=listdefault)

    tipp = RichText(
        title=u"Hinweis zur Fragestellung",
        description=u"Bitte bearbeiten Sie hier einen Hinweis zur Frage",
        required=False)
class ILyrisNewsletterFolder(form.Schema, IImageScaleTraversable):
    """
    Description of the Example Type
    """

    pam.languageindependent('mlid')
    mlid = schema.TextLine(title=_(u'Lyris Mailing list ID'))
    
    pam.languageindependent('siteid')
    siteid = schema.TextLine(title=_(u'Lyris Site ID'))

    form.widget(newsletter_types='collective.z3cform.datagridfield.DataGridFieldFactory')

    pam.languageindependent('newsletter_types')
    newsletter_types = schema.List(
            title=_(u'Newsletter types'), required=False,
            description=_(u'Available newsletter types'),
            value_type=DictRow(schema=INewsletterTypeSchema), default=[])

    form.widget(subscribed_message="plone.app.z3cform.wysiwyg.WysiwygFieldWidget")
    subscribed_message = schema.Text(
        title=_(u'Message to new subscribers'),
        description=_(u'Text to display to new subscribers')
    )

    form.widget(unsubscribed_message="plone.app.z3cform.wysiwyg.WysiwygFieldWidget")
    unsubscribed_message = schema.Text(
        title=_(u'Message to unsubscribed user'),
        description=_(u'Text to display to user who just unsubscribed')
    )
class IComingSoonSettings(Interface):

    delay = schema.Int(title=_('label_comingsoon_delay',
                               default=u"Rule handle delay"),
                       description=_("help_comingsoon_delay",
                                     default=u"Type here delay (in days) the coming soon "
                                          "rule will be handled "
                                          "before which an event will start. "
                                          "For example, a delay of 1 significates "
                                          "the event will be handled the day before "
                                          "the event content start date"))

    delays = schema.List(
        title=_("Delays"),
        value_type=DictRow(title=_(u'Per content types delays'),
                           schema=IDelayTableRowSchema),
        description=_("help_comingsoon_contenttypes_delay",
                      default=u"For each content type, type here delay "
                               "(in days) the coming soon "
                               "rule will be handled "
                               "before which an event will start. "
                               "For example, a delay of 1 signify "
                               "the event will be handled the day before "
                               "the event content start date")
        )
    widget(delays=DataGridFieldFactory)
예제 #13
0
class IFullpageBehavior(form.Schema):
    """Adds fields """

    form.widget(text_pairs=DataGridFieldFactory)
    text_pairs = schema.List(title=_(u"text_pairs", default=u"Text pairs"),
                             value_type=DictRow(schema=IPair),
                             required=False)
예제 #14
0
class IRICOrganization(model.Schema):

    citizen = schema.Int(
        title=_(u"Nombre d'habitants"),
        required=True,
        min=1
    )

    #servers = schema.TextLine(
    #    title=_(u"Serveurs"),
    #    required=True
    #)

    #softwares = schema.TextLine(
    #    title=_(u"Logiciels"),
    #    required=True
    #)

    subscriptions = schema.List(
        title=_(u"Cotisations"),
        value_type=DictRow(title=_(u"Cotisation"),
                           schema=ICotisationRow),
        required=False,
    )
    form.read_permission(subscriptions='RIC.ActualOrganizationMember')
    form.write_permission(subscriptions='RIC.Administrator')
    form.widget('subscriptions', DataGridField)
class IDocumentGeneratorSearchReplacePanelSchema(interface.Interface):
    """
    Schema for DocumentGeneratorSearchReplacePanel
    """

    selected_templates = schema.List(
        title=_(u"heading_selected_templates", default=u"Selected templates"),
        description=_(u"description_selected_templates", default=u""),
        required=False,
        default=[],
        missing_value=[],
        value_type=schema.Choice(
            source="collective.documentgenerator.AllPODTemplateWithFile"),
    )
    directives.widget("replacements", DataGridFieldFactory)
    replacements = schema.List(
        title=_(u"Replacements"),
        description=_("The replacements that will be made."),
        required=False,
        value_type=DictRow(schema=IReplacementRowSchema, required=True),
    )

    @invariant
    def has_valid_regexes(data):
        if hasattr(data, 'replacements'):
            for i, row in enumerate(data.replacements):
                if row["is_regex"]:
                    try:
                        re.compile(row["search_expr"])
                    except re.error:
                        raise Invalid(
                            _(u"Incorrect regex at row #{0} : \"{1}\"").format(
                                i + 1, row["search_expr"]))
예제 #16
0
class IStatlerTile(Interface):

    form.widget(value=DataGridFieldFactory)

    title = schema.TextLine(
        title=_(u"Title"),
        required=False
    )

    show_title = schema.Bool(
        title=_(u"Show Title?"),
        description=_(u""),
        required=False,
        default=True,
    )

    value = schema.List(
        title=u"Buttons",
        value_type=DictRow(title=u"Cards", schema=IButtonBlockTileRowSchema),
        required=False
    )

    count = schema.Choice(
        title=_(u"Count"),
        values=[1,2,3,4],
        default=1,
        required=True,
    )
예제 #17
0
class ISyncSettings(model.Schema):
    """Configure content syncing."""

    model.fieldset(
        "collective.contentsync",
        label=_("Content Sync"),
        fields=[
            "sync_disabled",
            "sync_settings",
        ],
    )

    sync_disabled = schema.Bool(
        default=False,
        description=_(
            "When activated synchronization of sub content will stop at this "
            u"content item for all sync targets.", ),
        required=False,
        title=_("Exclude item from content sync"),
    )

    directives.widget(sync_settings=DataGridFieldFactory)
    sync_settings = schema.List(
        default=[],
        required=False,
        title=_("Sync Settings"),
        value_type=DictRow(title=_("Sync Setting"), schema=ISyncSettingRow),
    )
예제 #18
0
class IFozzieBearTile(IBorderTile):

    form.widget(value=DataGridFieldFactory)

    title = schema.TextLine(
        title=_(u"Title"),
        required=False
    )

    style = schema.Choice(
        title=_(u"Style"),
        vocabulary='agsci.common.tiles.cta_background',
        default=u'light',
        required=True,
    )

    value = schema.List(
        title=u"Items",
        value_type=DictRow(title=u"Items", schema=IItemBlockTileRowSchema),
        required=False
    )

    count = schema.Choice(
        title=_(u"Count"),
        values=[1,2,3,4],
        required=False,
        default=4,
    )
    def fields(self):
        self.init()  # second init with user recognized
        fields = []
        description = _(
            u'You can <span class="cross_icon">remove</span> an assignment with the '
            u'<span class="cross_icon">cross icon</span>. '
            u'You can <span class="auto_append">add</span> a new assignment with the '
            u'<span class="auto_append">blue line</span>. '
            u'You can <span class="new_line">complete</span> it on the '
            u'<span class="new_line">brown line</span>.')
        self.get_user_manageable_functions()
        for function in self.functions_orgs:
            fld = DGFListField(
                __name__=function,
                title=_(
                    u"Assignments for groups related to '${function}' function",
                    mapping={'function': self.functions[function]}),
                description=description,
                required=False,
                value_type=DictRow(title=u"org_users",
                                   schema=IOrganisationsUsers,
                                   required=False))
            fields.append(fld)
        fields = sorted(fields, key=lambda x: x.title)

        self.get_user_manageable_groups()
        if self.groupids:
            fld = DGFListField(__name__='_groups_',
                               title=_('Global groups assignments.'),
                               description=description,
                               required=False,
                               value_type=DictRow(title=u"users",
                                                  schema=IGroupsUsers,
                                                  required=False))
            fields.insert(0, fld)

        fld = schema.TextLine(
            __name__='_old_values_',
            title=u'not_showed',
            required=False,
        )
        fields.append(fld)

        self.fieldnames = [afield.__name__ for afield in fields]
        return field.Fields(*fields)
예제 #20
0
class IKlassenliste(model.Schema):
    """ Marker interface and Dexterity Python Schema for Klassenliste
    """

    directives.widget(traineelist = DataGridFieldFactory)
    traineelist = schema.List(title=u"Ihre Klassenliste. Bitte vergeben Sie jedem Schüler einen Namen oder Nickname und einen PIN für den Zutritt\
                            zum Chatroom",
                            required=True,
                            value_type=DictRow(title=u"Schüler/Schülerin", schema=ITrainee))
class ISponsors(model.Schema):

    sponsors = schema.List(title=_(u'Event Sponsors'),
                           value_type=DictRow(title=u"sponsors",
                                              schema=ISponsor),
                           required=False)
    directives.widget('sponsors', BlockDataGridFieldFactory)

    model.fieldset('event_sponsors', label=_(u"Sponsors"), fields=['sponsors'])
예제 #22
0
class IRolloverPanelsTile(Interface):

    form.widget(value=DataGridFieldFactory)

    value = schema.List(
        title=u"Items",
        value_type=DictRow(title=u"Items", schema=IDropdownAccordionRowSchema),
        required=False
    )

    image_0 = NamedBlobImage(
        title=_(u"Image 1"),
        description=_(u""),
        required=False,
    )

    image_alt_0 = schema.TextLine(
        title=_(u"Image 1 Alt Text"),
        description=_(u""),
        required=False,
    )

    image_1 = NamedBlobImage(
        title=_(u"Image 2"),
        description=_(u""),
        required=False,
    )

    image_alt_1 = schema.TextLine(
        title=_(u"Image 2 Alt Text"),
        description=_(u""),
        required=False,
    )

    image_2 = NamedBlobImage(
        title=_(u"Image 3"),
        description=_(u""),
        required=False,
    )

    image_alt_2 = schema.TextLine(
        title=_(u"Image 3 Alt Text"),
        description=_(u""),
        required=False,
    )

    image_3 = NamedBlobImage(
        title=_(u"Image 4"),
        description=_(u""),
        required=False,
    )

    image_alt_3 = schema.TextLine(
        title=_(u"Image 4 Alt Text"),
        description=_(u""),
        required=False,
    )
예제 #23
0
class ISimpleNoteTable(model.Schema):
    """
    """

    widget(simple_group=DataGridFieldFactory)
    simple_group = schema.List(
        title=u"Table fields",
        value_type=DictRow(title=u"Note Table Fields", schema=ITableColumns),
        required=False,
    )
예제 #24
0
class IFormSchema(IPLandFile):
    shortname = schema.TextLine(
        title=u'Shortname',
        description=u'Used by the edit form to identify the land file.')
    fileCategories = schema.List(
        title=u'Categorization of this file',
        description=u'Enter, for each category, its value',
        value_type=DictRow(title=u"tablerow", schema=ITableRowSchema),
        required=False,
    )
class IBasicstuff(model.Schema):
    """
    Here we use the fields defined in ISomefields
    """

    widget(simple_group=DataGridFieldFactory)
    simple_group = schema.List(
        title=u"Some simple fields",
        value_type=DictRow(title=u"My simple fields", schema=ISomefields),
        required=False,
    )
class IPerson(Interface):
    """
    Note: when using a dict, it is still an object - A schema.Dict would be
    expected to contain some schemas. We are using an object implemented
    as a dict
    """
    name = schema.TextLine(title=u'Name', required=True)
    address = schema.List(title=u'Addresses',
                          value_type=DictRow(title=u'Address',
                                             schema=IAddress),
                          required=True)
예제 #27
0
class IDirectory(model.Schema):
    """Interface for Directory content type"""

    position_types = schema.List(title=_("Position types"),
                                 value_type=DictRow(
                                     title=_(u'Position'),
                                     schema=INameTokenTableRowSchema))
    widget(position_types=DataGridFieldFactory)

    organization_types = schema.List(title=_("Organization types"),
                                     value_type=DictRow(
                                         title=_(u'Organization'),
                                         schema=INameTokenTableRowSchema))
    widget(organization_types=DataGridFieldFactory)

    organization_levels = schema.List(title=_("Organization levels"),
                                      value_type=DictRow(
                                          title=_(u'Organization level'),
                                          schema=INameTokenTableRowSchema))
    widget(organization_levels=DataGridFieldFactory)
예제 #28
0
class IConfigurablePODTemplate(IPODTemplate):
    """
    ConfigurablePODTemplate dexterity schema.
    """
    def pod_formats_constraint(value):
        """
        By default, it seems that 'required' is not correctly validated
        so we double check that the field is not empty...
        """
        if not value:
            raise zope.interface.Invalid(
                zope_message_factory(u'Required input is missing.'))
        return True

    pod_formats = schema.List(
        title=_(u'Available formats'),
        description=_(
            u'Select format in which the template will be generable.'),
        value_type=schema.Choice(
            source='collective.documentgenerator.Formats'),
        required=True,
        default=[
            'odt',
        ],
        constraint=pod_formats_constraint,
    )

    form.widget('pod_portal_types', SelectWidget, multiple='multiple', size=15)
    pod_portal_types = schema.List(
        title=_(u'Allowed portal types'),
        description=_(
            u'Select for which content types the template will be available.'),
        value_type=schema.Choice(
            source='collective.documentgenerator.PortalTypes'),
        required=False,
    )

    form.widget('style_template', SelectWidget)
    style_template = schema.List(
        title=_(u'Style template'),
        description=_(
            u'Choose the style template to apply for this template.'),
        value_type=schema.Choice(
            source='collective.documentgenerator.StyleTemplates'),
        required=True,
    )

    form.widget('merge_templates', DataGridFieldFactory)
    merge_templates = schema.List(
        title=_(u'Templates to merge.'),
        required=False,
        value_type=DictRow(schema=IMergeTemplatesRowSchema, required=False),
        default=[],
    )
예제 #29
0
class IPSTAction(IProject):
    """
        PSTAction schema, field ordering
    """

    representative_responsible = LocalRolesField(
        title=_(u"Representative responsible"),
        description=_(u"Choose principals that will be representative responsible for this project. "
                      u"If nothing choosed, the oo value is used for searches."),
        value_type=schema.Choice(
            vocabulary=u'imio.project.pst.content.operational.representative_responsible_vocabulary',
        ),
        required=False,
    )
    form.widget('representative_responsible', AjaxChosenMultiFieldWidget, populate_select=True)

    responsible = schema.Choice(
        title=_(u'Responsible'),
        vocabulary=u'imio.project.pst.ActionEditorsVocabulary',
        required=False,
    )
    form.widget('responsible', AjaxChosenFieldWidget, populate_select=True)

    health_indicator = schema.Choice(
        title=_(u'Health indicator'),
        # description=_(u"Choose a health level."),
        vocabulary=u'imio.project.pst.content.action.health_indicator_vocabulary',
    )

    health_indicator_details = schema.Text(
        title=_(u'Health indicator_details'),
        # description=_(u"Details concerning the action health."),
        required=False,
    )

    # change label
    form.widget('result_indicator', DataGridFieldFactory, display_table_css_class='listing nosort',
                label=_(u'Realisation indicator'))

    budget_split = schema.List(
        title=_(u"Budget split"),
        required=False,
        value_type=DictRow(
            title=_("Budget split"), schema=IBudgetSplitSchema, required=False
        ),
    )

    @invariant
    def budget_split_total_invariant(data):
        budget_split = getattr(data, 'budget_split', [])
        if budget_split and sum([line.get('percentage') for line in budget_split]) != 100.0:
            raise Invalid(_(u'The sum of all percentages must amount to 100 %.'))
예제 #30
0
class IBoaPraticaForm(form.Schema):

    title = schema.TextLine(
        title=u"Título",
        required=True,
    )

    directives.widget(esfera='z3c.form.browser.radio.RadioFieldWidget')
    esfera = schema.Choice(title=u"Essa prática é esfera",
                           required=True,
                           vocabulary="mpdg.govbr.observatorio.EsferaPratica")

    uf = schema.Choice(
        title=u"UF",
        description=u"Selecione o seu Estado.",
        required=False,
        vocabulary="brasil.estados",
    )

    orgparticipantes = schema.TextLine(
        title=u"Órgãos participantes",
        description=
        u"Se a prática estiver relacionada a algum órgão de governo, favor informar no campo abaixo",
        required=False,
    )

    # categoria = schema.Choice(
    #     title=u"Assunto",
    #     vocabulary="liberiun.govcontent.CategoriasBoaPratica")

    directives.widget(
        description='plone.app.z3cform.wysiwyg.WysiwygFieldWidget')
    description = schema.Text(
        title=u"Descrição",
        required=False,
    )

    # Subject = Keywords(
    #     title=u'Tags',
    #     required=False,)

    directives.widget(sitesrelacionados=
                      'collective.z3cform.datagridfield.DataGridFieldFactory')
    sitesrelacionados = schema.List(title=u"Sites relacionados",
                                    value_type=DictRow(title=u"tablerow",
                                                       schema=ITableRowSchema),
                                    required=False)

    anexo = NamedFile(
        title=u"Anexo",
        description=u'É obrigatório a inclusão de pelo menos um anexo.',
        required=True)