class ExclusionSchema(Schema):

    participant = colander.SchemaNode(
        ObjectType(),
        widget=participant_choice,
        missing=[],
        title=_("Participant that you request to exclude"))
Exemple #2
0
class GameSchema(VisualisableElementSchema, SearchableEntitySchema):
    """Schema for Web advertising"""

    name = NameSchemaNode(editing=context_is_a_game, )

    description = colander.SchemaNode(colander.String(),
                                      widget=RichTextWidget(),
                                      title=_("Description"),
                                      missing="")

    winners = colander.SchemaNode(colander.Set(),
                                  widget=winners_widget,
                                  title=_('Winners'))

    winner_number = colander.SchemaNode(colander.Int(),
                                        title=_('Winner number'))

    participants = colander.SchemaNode(colander.Set(),
                                       widget=participants_widget,
                                       title=_('Participants'))

    start_date = colander.SchemaNode(colander.DateTime(),
                                     title=_('Start date'))

    end_date = colander.SchemaNode(colander.DateTime(), title=_('End date'))

    announcement = colander.SchemaNode(ObjectType(),
                                       widget=announcement_choice,
                                       missing=None,
                                       title=_("Cultural event"))

    picture = colander.SchemaNode(ObjectData(Image),
                                  widget=picture_widget,
                                  title=_('Picture'),
                                  missing=None)
class AddIdeaSchema(Schema):

    idea = colander.SchemaNode(
        ObjectType(),
        widget=idea_choice,
        title=_('Re-use one or more existing idea(s)'),
        missing=None,
        #description=_('Choose an idea')
        )

    new_idea_choice = colander.SchemaNode(
        colander.Boolean(),
        widget=deform.widget.CheckboxWidget(css_class="new-idea-control"),
        label=_('Add a new idea'),
        title='',
        missing=False
        )

    new_idea = select(IdeaSchema(factory=Idea,
                                 editable=True,
                                 omit=['keywords'],
                                 widget=SimpleMappingtWidget(
                                    mapping_css_class='hide-bloc new-idea-form',
                                    ajax=False)),
                    ['challenge',
                     'title',
                     'text',
                     'keywords'])
class SubmissionSchema(Schema):

    sites = colander.SchemaNode(
        ObjectType(),
        widget=sites_choice,
        default=sites_default,
        title=_('Sites'),
        validator=colander.Length(min=1)
        )
Exemple #5
0
class ProposalSchema(VisualisableElementSchema, SearchableEntitySchema):
    """Schema for Proposal"""

    name = NameSchemaNode(
        editing=context_is_a_proposal,
        )

    challenge = colander.SchemaNode(
        ObjectType(),
        widget=challenge_choice,
        missing=None,
        title=_("Challenge (optional)"),
        description=_("You can select and/or modify the challenge associated to this proposal. "
                      "For an open proposal, do not select anything in the « Challenge » field.")
    )

    description = colander.SchemaNode(
        colander.String(),
        validator=colander.Length(max=600),
        widget=LimitedTextAreaWidget(rows=5,
                                     cols=30,
                                     limit=600),
        title=_("Abstract")
        )

    text = colander.SchemaNode(
        colander.String(),
        widget=RichTextWidget(),
        title=_("Text")
        )

    related_ideas = colander.SchemaNode(
        colander.Set(),
        widget=ideas_choice,
        title=_('Related ideas'),
        validator=Length(_, min=1),
        default=[],
        )

    add_files = omit(AddFilesSchemaSchema(
                        widget=SimpleMappingtWidget(
                        mapping_css_class='controled-form'
                                          ' object-well default-well hide-bloc',
                        ajax=True,
                        activator_icon="glyphicon glyphicon-file",
                        activator_title=_('Add files'))),
                    ["_csrf_token_"])

    anonymous = colander.SchemaNode(
        colander.Boolean(),
        widget=anonymous_widget,
        label=_('Remain anonymous'),
        description=_('Check this box if you want to remain anonymous.'),
        title='',
        missing=False,
        default=False
        )
Exemple #6
0
class VenueSchema(SourceVenueSchema):

    title = colander.SchemaNode(
        ObjectType(),
        widget=venue_choice,
        title=_('Cinema'),
        description=_('Select a cinema.'),
        # description=('Sélectionner un cinéma.'),
    )
class CompareIdeaSchema(Schema):

    versions = colander.SchemaNode(
        ObjectType(),
        widget=version_choice,
        title=_('Previous versions'),
        description=_("Select the previous version with which to compare"),
        missing=None
        )
class ReplaceVenuesSchema(Schema):

    source = colander.SchemaNode(ObjectType(),
                                 widget=target_choice,
                                 title=_("Venue"))

    targets = colander.SchemaNode(colander.Set(),
                                  widget=targets_choice,
                                  title=_("Doubloons"))
class OrderSmartFoldersSchema(Schema):

    folders = colander.SchemaNode(
        colander.Sequence(),
        colander.SchemaNode(ObjectType(),
                            widget=folders_widget,
                            name=_("folder")),
        widget=folder_seq_widget,
        title=_('Folders'),
        description=_('Drag and drop folders to order'))
class OrderSmartFoldersSchema(Schema):

    folders = colander.SchemaNode(
        colander.Sequence(),
        colander.SchemaNode(ObjectType(),
                            widget=folders_widget,
                            name=_("topic of interest")),
        widget=folder_seq_widget,
        title=_('The topics of interests'),
        description=_('Drag and drop the topics of interests to be sorted'))
Exemple #11
0
class IdeaSchema(VisualisableElementSchema, SearchableEntitySchema):
    """Schema for idea"""

    name = NameSchemaNode(editing=context_is_a_idea, )

    challenge = colander.SchemaNode(
        ObjectType(),
        widget=challenge_choice,
        missing=None,
        title=_("Challenge (optional)"),
        description=
        _("You can select and/or modify the challenge associated to this idea. "
          "For an open idea, do not select anything in the « Challenge » field."
          ))

    text = colander.SchemaNode(
        colander.String(),
        widget=LimitedTextAreaWidget(
            rows=5,
            cols=30,
            limit=2000,
            alert_template='novaideo:views/templates/idea_text_alert.pt',
            alert_values={'limit': 2000},
            item_css_class='content-preview-form',
            placeholder=_('I have an idea!')),
        title=_("Text"))

    note = colander.SchemaNode(colander.String(),
                               widget=LimitedTextAreaWidget(
                                   rows=3,
                                   cols=30,
                                   limit=300,
                                   alert_values={'limit': 300}),
                               title=_("Note"),
                               missing="")

    attached_files = colander.SchemaNode(
        colander.Sequence(),
        colander.SchemaNode(ObjectData(File),
                            name=_("File"),
                            widget=get_file_widget()),
        widget=FilesWidget(add_subitem_text_template='',
                           item_css_class='files-block'),
        missing=[],
        title=_('Attached files'),
    )

    anonymous = colander.SchemaNode(
        colander.Boolean(),
        widget=anonymous_widget,
        label=_('Remain anonymous'),
        description=_('Check this box if you want to remain anonymous.'),
        title='',
        missing=False,
        default=False)
Exemple #12
0
class InterviewSchema(BaseReviewSchema):
    """Schema for interview"""

    name = NameSchemaNode(
        editing=context_is_a_interview,
        )

    review = colander.SchemaNode(
        ObjectType(),
        widget=review_choice,
        missing=None,
        title=_("Review")
        )
Exemple #13
0
class ServiceSchema(VisualisableElementSchema):
    """Schema for service"""

    name = NameSchemaNode(editing=context_is_a_service, )

    perimeter = colander.SchemaNode(colander.Set(),
                                    widget=perimeter_widget,
                                    title=_('Perimeter'))

    delegate = colander.SchemaNode(ObjectType(),
                                   widget=delegate_widget,
                                   title=_('Delegate this service to'),
                                   default=default_delegate)
Exemple #14
0
class ContentsByKeywordsSchema(Schema):

    content_types = colander.SchemaNode(
        colander.Set(),
        widget=content_types_choices,
        title=_('Types'),
        description=_('You can select the content types to be displayed.'),
        default=default_content_types,
        missing=default_content_types)

    states = colander.SchemaNode(
        colander.Set(),
        widget=states_choices,
        title=_('States'),
        description=_(
            'You can select the states of the contents to be displayed.'),
        default=['published'],
        missing=['published'])

    tree = colander.SchemaNode(
        typ=DictSchemaType(),
        widget=core.keyword_widget,
        default=DEFAULT_TREE,
        title=_('Keywords'),
        description=
        _('Indicate keywords. You can specify a second keyword level for each keyword chosen.'
          ))

    author = colander.SchemaNode(
        ObjectType(),
        widget=authors_choices,
        title=_('Author'),
        description=_(
            'You can enter the author name of the contents to be displayed.'),
        default=None,
        missing=None)

    dates = omit(
        PublicationDates(widget=SimpleMappingWidget(css_class="filter-block"
                                                    " object-well"
                                                    " default-well")),
        ["_csrf_token_"])
Exemple #15
0
class ContentsByKeywordsSchema(Schema):

    content_types = colander.SchemaNode(
        colander.Set(),
        widget=content_types_choices,
        title=_('Types'),
        description=_('You can select the content types to be displayed.'),
        default=default_content_types,
        missing=default_content_types)

    states = colander.SchemaNode(
        colander.Set(),
        widget=states_choices,
        title=_('States'),
        description=_(
            'You can select the states of the contents to be displayed.'),
        default=['published'],
        missing=['published'])

    keywords = colander.SchemaNode(
        colander.Set(),
        widget=keywords_choice,
        title=_('Keywords'),
        description=_(
            "You can select the keywords of the contents to be displayed."),
        missing=[])

    author = colander.SchemaNode(
        ObjectType(),
        widget=authors_choices,
        title=_('Author'),
        description=_(
            'You can enter the author name of the contents to be displayed.'),
        default=None,
        missing=None)

    dates = omit(
        PublicationDates(widget=SimpleMappingWidget(css_class="filter-block"
                                                    " object-well"
                                                    " default-well")),
        ["_csrf_token_"])
Exemple #16
0
class ModerationServiceSchema(ServiceSchema):
    """Schema for service"""

    name = NameSchemaNode(editing=context_is_a_service, )

    perimeter = colander.SchemaNode(colander.Set(),
                                    widget=perimeter_m_widget,
                                    title=_('Perimeter'))

    delegate = colander.SchemaNode(ObjectType(),
                                   widget=delegate_m_widget,
                                   title=_('Delegate this service to'))

    @invariant
    def contact_invariant(self, appstruct):
        appstruct_copy = appstruct.copy()
        request = self.bindings['request']
        context = self.bindings['context']
        node = self.get('delegate')
        site = None
        if isinstance(context, SiteFolder):
            site = context
        else:
            site = request.get_site_folder

        services = site.get_services('moderation')
        services = site.get_all_services(kinds=['moderation'],
                                         validate=True,
                                         delegation=False).get(
                                             'moderation', [])
        if services:
            organization = appstruct_copy['delegate']
            for service in services:
                if service.delegate is organization:
                    raise colander.Invalid(
                        node,
                        _('This service is already delegated to the following organization: ${organization} ',
                          mapping={'organization': organization.title}))
Exemple #17
0
class CorrelationSchema(VisualisableElementSchema):
    """Schema for correlation"""

    name = NameSchemaNode(editing=context_is_a_correlation, )

    intention = colander.SchemaNode(
        colander.String(),
        widget=intention_choice,
        title=_('Intention'),
    )

    comment = colander.SchemaNode(colander.String(),
                                  validator=colander.Length(max=500),
                                  widget=deform.widget.TextAreaWidget(rows=4,
                                                                      cols=60),
                                  title=_("Message"))

    targets = colander.SchemaNode(
        ObjectType(),
        widget=targets_choice,
        validator=colander.Length(min=1),
        title=_('Targets'),
    )
Exemple #18
0
class PersonSchema(VisualisableElementSchema, UserSchema,
                   SearchableEntitySchema):
    """Schema for Person"""

    name = NameSchemaNode(editing=context_is_a_person, )

    function = colander.SchemaNode(colander.String(),
                                   widget=deform.widget.TextInputWidget(),
                                   title=_('Function'),
                                   missing='')

    description = colander.SchemaNode(colander.String(),
                                      widget=LimitedTextAreaWidget(
                                          rows=5,
                                          cols=30,
                                          limit=1200,
                                          alert_values={'limit': 1200}),
                                      title=_("Description"),
                                      missing="")

    tree = colander.SchemaNode(
        typ=DictSchemaType(),
        widget=keyword_widget,
        default=DEFAULT_TREE,
        missing=DEFAULT_TREE,
        title=_('Topics of interest'),
        description=
        _('Indicate keywords. You can specify a second keyword level for each keyword chosen.'
          ))

    email = colander.SchemaNode(colander.String(),
                                validator=colander.All(
                                    colander.Email(), email_validator,
                                    colander.Length(max=100)),
                                title=_('Login (email)'))

    picture = colander.SchemaNode(
        ObjectData(Image),
        widget=picture_widget,
        title=_('Picture'),
        description=
        _('You see a square on the top left of the image if it exceeds the maximum'
          ' size allowed. Move and enlarge it if necessary, to determine an area of'
          ' interest. Several images will be generated from this area.'),
        required=False,
        missing=None,
    )

    cover_picture = colander.SchemaNode(
        ObjectData(File),
        widget=get_file_widget(file_extensions=['png', 'jpg', 'svg']),
        title=_('Cover picture'),
        missing=None,
        description=_("Only PNG and SVG files are supported."),
    )

    first_name = colander.SchemaNode(
        colander.String(),
        title=_('Given name(s)'),
        description=
        _("Given name(s), as it(they) appear(s) on your official identity documents"
          ))

    last_name = colander.SchemaNode(
        colander.String(),
        title=_('Family name(s)'),
        description=
        _("Family name(s), as it(they) appear(s) on your official identity documents"
          ))

    birth_date = colander.SchemaNode(colander.Date(), title=_('Date of birth'))

    citizenship = colander.SchemaNode(
        colander.String(),
        widget=citizenship_choice,
        title=_('Citizenship'),
        description=
        _('What is the Member State of the European Union of which you are a citizen? Only citizens of the European Union can be members of the CosmoPolitical Cooperative.'
          ),
    )

    birthplace = colander.SchemaNode(
        colander.String(),
        title=_('Place of birth'),
        description=_(
            "Place of birth (city or municipality + country if relevant), "
            "as it appears on your official identity documents"))

    user_title = colander.SchemaNode(
        colander.String(),
        widget=titles_choice,
        title=_('Title', context='user'),
        description=
        _('Please do not select anything if you do not want to communicate this information.'
          ),
        missing='')

    locale = colander.SchemaNode(
        colander.String(),
        title=_('Locale'),
        widget=locale_widget,
        missing=locale_missing,
        validator=colander.OneOf(AVAILABLE_LANGUAGES),
    )

    password = colander.SchemaNode(
        colander.String(),
        widget=deform.widget.CheckedPasswordWidget(),
        validator=colander.Length(min=3, max=100),
        title=_("Password"))

    organization = colander.SchemaNode(
        ObjectType(),
        widget=organization_choice,
        missing=None,
        title=_('Organization'),
    )

    pseudonym = colander.SchemaNode(
        colander.String(),
        widget=deform.widget.TextInputWidget(item_css_class='pseudonym-input'),
        validator=colander.All(pseudonym_validator, ),
        title=_('Pseudonym'),
        description=
        _("Please choose the pseudonym that will identify you for the whole duration of your "
          "activity on the platform. We STRONGLY recommend that you select a pseudonym that makes "
          "tracking back to your real identity impossible (or extremely difficult). Thereby, you "
          "protect the confidentiality of your political opinions (i.e. personal data that are the "
          "purpose of a specific protection under the General Data Protection Regulation - GDPR) "
          "against any form of external pressure in real life (e.g. by your employer or your customers). "
          "Be very careful! Once you have chosen it, you will NEVER be able to change this pseudonym afterwards. "
          "Choose it with care!"),
    )

    accept_conditions = colander.SchemaNode(
        colander.Boolean(),
        widget=conditions_widget,
        label=_('I have read and accept the terms and conditions of use'),
        title='',
        missing=False)

    @invariant
    def user_invariant(self, appstruct):
        context = self.bindings['context']
        first_name = appstruct.get('first_name', None)
        last_name = appstruct.get('last_name', None)
        birth_date = appstruct.get('birth_date', None)
        birthplace = appstruct.get('birthplace', None)
        if first_name and last_name and birth_date and birthplace:
            try:
                birth_date = colander.iso8601.parse_date(birth_date)
                birth_date = birth_date.date()
            except colander.iso8601.ParseError as e:
                return

            key = first_name + last_name + birthplace + birth_date.strftime(
                "%d/%m/%Y")
            key = normalize_title(key).replace(' ', '')
            novaideo_catalog = find_catalog('novaideo')
            identifier_index = novaideo_catalog['identifier']
            query = identifier_index.any([key])
            users = list(query.execute().all())
            if context in users:
                users.remove(context)

            if users:
                raise colander.Invalid(self, _('User already exists'))
Exemple #19
0
class QuestionSchema(VisualisableElementSchema, SearchableEntitySchema):
    """Schema for question"""

    name = NameSchemaNode(
        editing=context_is_a_question,
        )

    challenge = colander.SchemaNode(
        ObjectType(),
        widget=challenge_choice,
        missing=None,
        title=_("Challenge (optional)"),
        description=_("You can select and/or modify the challenge associated to this question. "
                      "For an open question, do not select anything in the « Challenge » field.")
    )

    title = colander.SchemaNode(
        colander.String(),
        title=_("Question")
        )

    options = colander.SchemaNode(
        colander.Sequence(),
        colander.SchemaNode(
            colander.String(),
            name=_("Option")
            ),
        widget=SequenceWidget(
            add_subitem_text_template='',
            orderable=True),
        title=_('Options'),
        description=_("You can add options to your question. "
                      "Users can only answer questions with options once. "
                      "Statistics will be provided indicating the percentage "
                      "of each option."),
        missing=[]
        )

    text = colander.SchemaNode(
        colander.String(),
        widget=LimitedTextAreaWidget(
            rows=5,
            cols=30,
            limit=2000,
            alert_values={'limit': 2000},
            item_css_class='content-preview-form',
            placeholder=_('I have a question!')),
        title=_("Details"),
        missing=''
        )

    attached_files = colander.SchemaNode(
        colander.Sequence(),
        colander.SchemaNode(
            ObjectData(File),
            name=_("File"),
            widget=get_file_widget()
            ),
        widget=FilesWidget(
            add_subitem_text_template='',
            item_css_class='files-block'),
        missing=[],
        title=_('Attached files'),
        )

    anonymous = colander.SchemaNode(
        colander.Boolean(),
        widget=anonymous_widget,
        label=_('Remain anonymous'),
        description=_('Check this box if you want to remain anonymous.'),
        title='',
        missing=False,
        default=False
        )