Exemple #1
0
class EventsInterfaceConfigurationSchema(Schema):

    nb_event_maxi = colander.SchemaNode(
        colander.Integer(),
        title=_('Maximum number of events per Member'),
        default=7,
    )

    event_descriptions = colander.SchemaNode(
        colander.Sequence(),
        omit(
            select(
                EventDescriptionTemplate(
                    name='description',
                    title=_('Description'),
                    widget=SimpleMappingWidget(
                        css_class=
                        "object-well default-well mail-template-well mail-template-block"
                    )), ['locale', 'template']), ['_csrf_token_']),
        widget=SequenceWidget(
            min_len=1,
            max_len=len(AVAILABLE_LANGUAGES),
            add_subitem_text_template=_('Add a new description')),
        title=_('Descriptions'),
        default=descriptions_default)
Exemple #2
0
class MailSeqTemplate(Schema):

    mail_id = colander.SchemaNode(
        colander.String(),
        widget=deform.widget.HiddenWidget(),
        title=_('Mail id'),
    )

    title = colander.SchemaNode(
        colander.String(),
        widget=deform.widget.TextInputWidget(template='readonly/textinput'),
        title=_('Title'),
        missing="")

    languages = colander.SchemaNode(
        colander.Sequence(),
        omit(
            select(
                MailTemplate(
                    name='language',
                    title=_('language'),
                    widget=SimpleMappingWidget(
                        css_class=
                        "object-well default-well mail-template-well mail-template-block"
                    )), ['locale', 'subject', 'template']), ['_csrf_token_']),
        widget=SequenceWidget(
            min_len=1,
            max_len=len(AVAILABLE_LANGUAGES),
            add_subitem_text_template=_('Add a new language')),
        title=_('Languages'),
    )
Exemple #3
0
    def bbox_data(self, data_input):
        node = colander.SchemaNode(
            colander.String(),
            name=data_input.identifier,
            title=data_input.title,
            validator=BBoxValidator(),
            widget=BBoxWidget()
        )

        # sometimes abstract is not set
        node.description = getattr(data_input, 'abstract') or 'No summary'
        # optional value?
        if data_input.minOccurs == 0:
            node.missing = colander.drop

        # sequence of nodes ...
        if data_input.maxOccurs > 1:
            node = colander.SchemaNode(
                colander.Sequence(),
                node,
                name=data_input.identifier,
                title=data_input.title,
                validator=colander.Length(max=data_input.maxOccurs)
            )

        return node
Exemple #4
0
    def boundingbox(self, data_input):
        node = colander.SchemaNode(
            colander.String(),
            name=data_input.identifier,
            title=data_input.title,
            default="0,-90,180,90",
            widget=deform.widget.TextInputWidget()
        )
        # sometimes abstract is not set
        node.description = getattr(data_input, 'abstract', '')

        # optional value?
        if data_input.minOccurs == 0:
            node.missing = colander.drop

        # validator
        pattern = '-?\d+,-?\d+,-?\d+,-?\d+'
        regex = re.compile(pattern)
        node.validator = colander.Regex(
            regex=regex,
            msg='String does not match pattern: minx,miny,maxx,maxy')

        # finally add node to root schema
        # sequence of nodes ...
        if data_input.maxOccurs > 1:
            node = colander.SchemaNode(
                colander.Sequence(),
                node,
                name=data_input.identifier,
                title=data_input.title,
                validator=colander.Length(max=data_input.maxOccurs)
            )

        return node
Exemple #5
0
def get_project_schema():
    """
    Return the project Edition/add form schema
    """
    schema = SQLAlchemySchemaNode(Project, excludes=('_acl', ))

    schema['name'].missing = colander.required

    # Add a custom node to be able to associate existing customers
    customer_id_node = colander.SchemaNode(
        colander.Integer(),
        widget=deferred_customer_select,
        validator=deferred_customer_validator,
        default=deferred_default_customer,
        name='un client')
    customer_id_node.objectify = customer_objectify
    customer_id_node.dictify = customer_dictify

    schema.insert(
        3,
        colander.SchemaNode(colander.Sequence(),
                            customer_id_node,
                            widget=deform.widget.SequenceWidget(min_len=1),
                            title=u"Clients",
                            name='customers'))

    return schema
Exemple #6
0
def get_list(thetype,tr,config):
    col_type = colander.SchemaNode(colander.Sequence(),
                                   name=tr,
                                   description=config.trait(tr).desc,
                                   widget=deform.widget.TextInputCSVWidget(cols=100,rows=1))
    col_type.add(colander.SchemaNode(colander.String()))
    return col_type
Exemple #7
0
class FilesystemLinkerParametersSchema(colander.MappingSchema):
	directories = colander.SchemaNode(
		colander.Sequence(),
		colander.SchemaNode(colander.String()),
		title="Directories",
		description="List of directories to be symlinked into a persistent filesystem location."
	)
Exemple #8
0
class GetTestResultsSchema(CSRFProtectedSchema, colander.MappingSchema):
    """An API schema for bodhi.server.services.updates.get_test_results()."""

    alias = Builds(
        colander.Sequence(accept_scalar=True),
        missing=None,
    )
Exemple #9
0
    def bbox_data(self, data_input):
        node = colander.SchemaNode(colander.String(),
                                   name=data_input.identifier,
                                   title=data_input.title,
                                   validator=BBoxValidator(),
                                   widget=BBoxWidget())

        # sometimes abstract is not set
        node.description = getattr(data_input, 'abstract') or 'No summary'
        # optional value?
        if data_input.minOccurs == 0:
            node.missing = colander.drop

        if (hasattr(data_input, 'defaultValue')
                and data_input.defaultValue is not None
                and len(data_input.defaultValue.split(',')) > 3):
            default = ",".join(data_input.defaultValue.split(',')[:4])
            node.default = default

        # sequence of nodes ...
        if data_input.maxOccurs > 1:
            node = colander.SchemaNode(
                colander.Sequence(),
                node,
                name=data_input.identifier,
                title=data_input.title,
                validator=colander.Length(max=data_input.maxOccurs))

        return node
Exemple #10
0
def get_params(params, **kw):
    """
    :return: pair (appstruct, request params dict)
    """
    def default_params():
        return {
            'biblio': {
                n: ''
                for n in
                'author year title editor journal address publisher'.split()
            }
        }

    reqparams = {}
    cstruct = default_params()

    biblio = colander.SchemaNode(colander.Mapping(), name='biblio', missing={})
    for name in cstruct['biblio']:
        biblio.add(
            colander.SchemaNode(colander.String(),
                                name=name,
                                missing='',
                                title=name.capitalize()))
        cstruct['biblio'][name] = params.get(name, '')
        if cstruct['biblio'][name]:
            reqparams[name] = cstruct['biblio'][name]

    schema = colander.SchemaNode(colander.Mapping())
    for name, cls in dict(
            languoid=Languoid,
            doctype=Doctype,
            macroarea=None,
    ).items():
        plural = name + 's'
        _kw = dict(collection=kw.get(plural))
        if name == 'languoid':
            _kw['alias'] = 'hid'
        schema.add(
            colander.SchemaNode(colander.Sequence(),
                                colander.SchemaNode(ModelInstance(cls, **_kw),
                                                    name=name),
                                missing=[],
                                name=plural))
        if plural != 'languoids':
            cstruct[plural] = params.getall(plural) if hasattr(params, 'getall') \
                else params.get(plural, [])
            if cstruct[plural]:
                reqparams[plural] = cstruct[plural]
        else:
            cstruct[plural] = [
                p for p in params.get(plural, '').split(',') if p
            ]
            if cstruct[plural]:
                reqparams[plural] = params[plural]
    schema.add(biblio)
    try:
        return schema.deserialize(cstruct), reqparams
    except colander.Invalid:  # pragma: no cover
        return default_params(), {}
Exemple #11
0
    def _colander_schema(self, instance, value):
        subfield = colander.SchemaNode(colander.Tuple())
        subfield.add(colander.SchemaNode(colander.String(), name='subkey'))
        subfield.add(colander.SchemaNode(colander.String(), name='value'))

        return colander.SchemaNode(colander.Sequence(),
                                   subfield,
                                   name=self.name)
Exemple #12
0
class ListCommentSchema(PaginatedSchema, SearchableSchema):
    """An API schema for bodhi.server.services.comments.query_comments()."""

    updates = Updates(
        colander.Sequence(accept_scalar=True),
        location="querystring",
        missing=None,
        preparer=[util.splitter],
    )

    packages = Packages(
        colander.Sequence(accept_scalar=True),
        location="querystring",
        missing=None,
        preparer=[util.splitter],
    )

    user = colander.SchemaNode(
        colander.String(),
        location="querystring",
        missing=None,
    )

    update_owner = colander.SchemaNode(
        colander.String(),
        location="querystring",
        missing=None,
    )

    ignore_user = colander.SchemaNode(
        colander.String(),
        location="querystring",
        missing=None,
    )

    anonymous = colander.SchemaNode(
        colander.Boolean(true_choices=('true', '1')),
        location="querystring",
        missing=None,
    )

    since = colander.SchemaNode(
        colander.DateTime(),
        location="querystring",
        missing=None,
    )
Exemple #13
0
class ListReleaseSchema(PaginatedSchema):
    """
    An API schema for listing releases.

    This schema is used by bodhi.server.services.releases.query_releases_html() and
    bodhi.server.services.releases.query_releases_json().
    """

    ids = ReleaseIds(
        colander.Sequence(accept_scalar=True),
        location="querystring",
        missing=None,
        preparer=[util.splitter],
    )

    name = colander.SchemaNode(
        colander.String(),
        location="querystring",
        missing=None,
    )

    updates = Updates(
        colander.Sequence(accept_scalar=True),
        location="querystring",
        missing=None,
        preparer=[util.splitter],
    )

    packages = Packages(
        colander.Sequence(accept_scalar=True),
        location="querystring",
        missing=None,
        preparer=[util.splitter],
    )

    state = colander.SchemaNode(
        colander.String(),
        validator=colander.OneOf(list(ReleaseState.values())),
        missing=None,
    )

    exclude_archived = colander.SchemaNode(
        colander.Boolean(true_choices=('true', '1')),
        location="querystring",
        missing=None,
    )
Exemple #14
0
class WaiveTestResultsSchema(CSRFProtectedSchema, colander.MappingSchema):
    """An API schema for bodhi.server.services.updates.waive_test_results()."""

    comment = colander.SchemaNode(
        colander.String(),
        missing=None,
    )
    tests = Tests(colander.Sequence(accept_scalar=True), missing=None, preparer=[util.splitter])
Exemple #15
0
class ReportSearchSchema(colander.MappingSchema):
    def schema_type(self, **kw):
        return colander.Mapping(unknown='preserve')

    resource = colander.SchemaNode(StringToAppList(),
                                   validator=possible_applications_validator,
                                   missing=possible_applications)
    request_id = colander.SchemaNode(colander.Sequence(accept_scalar=True),
                                     colander.SchemaNode(colander.String()),
                                     missing=None)
    start_date = colander.SchemaNode(PermissiveDate(), missing=None)
    end_date = colander.SchemaNode(PermissiveDate(), missing=None)
    page = colander.SchemaNode(colander.Integer(),
                               validator=colander.Range(min=1),
                               missing=1)

    min_occurences = colander.SchemaNode(colander.Sequence(accept_scalar=True),
                                         colander.SchemaNode(
                                             colander.Integer()),
                                         missing=None)

    http_status = colander.SchemaNode(colander.Sequence(accept_scalar=True),
                                      colander.SchemaNode(colander.Integer()),
                                      missing=None)
    priority = colander.SchemaNode(colander.Sequence(accept_scalar=True),
                                   colander.SchemaNode(colander.Integer()),
                                   missing=None)
    error = colander.SchemaNode(colander.Sequence(accept_scalar=True),
                                colander.SchemaNode(colander.String()),
                                missing=None)
    url_path = colander.SchemaNode(colander.Sequence(accept_scalar=True),
                                   colander.SchemaNode(colander.String()),
                                   missing=None)
    url_domain = colander.SchemaNode(colander.Sequence(accept_scalar=True),
                                     colander.SchemaNode(colander.String()),
                                     missing=None)
    report_status = colander.SchemaNode(colander.Sequence(accept_scalar=True),
                                        colander.SchemaNode(colander.String()),
                                        missing=None)
    min_duration = colander.SchemaNode(colander.Sequence(accept_scalar=True),
                                       colander.SchemaNode(colander.Float()),
                                       missing=None)
    max_duration = colander.SchemaNode(colander.Sequence(accept_scalar=True),
                                       colander.SchemaNode(colander.Float()),
                                       missing=None)
Exemple #16
0
class ShellPrepareParametersSchema(colander.MappingSchema):
    # Must have a key called commands, which is a list of strings.
    commands = colander.SchemaNode(
        colander.Sequence(),
        colander.SchemaNode(colander.String()),
        title="Commands",
        description=
        "A list of command to run. They can be any bash syntax you would like. Each item in the list becomes a single line in a shell script that is written out and executed."
    )
Exemple #17
0
class OptionalVenueSchema(VisualisableElementSchema, SearchableEntitySchema):

    typ_factory = ObjectData

    name = NameSchemaNode(
        editing=context_is_a_venue,
        )

    id = colander.SchemaNode(
        colander.String(),
        widget=deform.widget.HiddenWidget(),
        title="ID",
        missing=""
        )

    title = colander.SchemaNode(
        colander.String(),
        widget=venue_choice,
        title=_('Venue title'),
        description=_('Indicate the venue (room, theatre, lecture hall, square, etc.).'),
        )

    description = colander.SchemaNode(
        colander.String(),
        widget=RichTextWidget(),
        description=_("Vous pouvez ajouter ou éditer la description du lieu. Cette description doit porter sur le lieu de l'annonce et non sur l'annonce."),
        title=_("Venue description")
        )

    addresses = colander.SchemaNode(
        colander.Sequence(),
        omit(AddressSchema(name='address',
                           widget=SimpleMappingWidget(
                               css_class='address-well object-well default-well')),
        ['_csrf_token_']),
        widget=SimpleSequenceWidget(
            min_len=1,
            add_subitem_text_template=_('Add a new address'),
            remove_subitem_text_template=_('Remove the address')),
        title=_('Venue addresses'),
        )

    other_conf = omit(MoreInfoVebueSchema(widget=SimpleMappingtWidget(
                        mapping_css_class='controled-form'
                                          ' object-well hide-bloc',
                        ajax=True,
                        control_css_class='optional-venue-form',
                        activator_css_class="glyphicon glyphicon-map-marker",
                        activator_title=_("Avez-vous une minute ? Afin d'améliorer la visibilité et la pertinence de votre événement, pensez à vérifier ou compléter les informations associées au lieu en cliquant ici."))),
                        ["_csrf_token_"])

    origin_oid = colander.SchemaNode(
        colander.Int(),
        widget=deform.widget.HiddenWidget(),
        title=_('OID'),
        missing=0
        )
Exemple #18
0
    def _colander_schema(self, instance, value):
        kwargs = {'name': self.name}
        if not self.required:
            kwargs.update({'missing': None})

        schema = colander.SchemaNode(colander.Sequence(), **kwargs)
        schema.add(colander.SchemaNode(colander.String(), name=self.name))

        return schema
Exemple #19
0
class Instance(StrictAboutExtraKeysColanderMappingSchema):
    name = colander.SchemaNode(
        colander.String(),
        title="Name",
        description="Instance type name for this instance.")
    quantity = colander.SchemaNode(
        colander.Integer(),
        title="Quantity",
        description="The quantity of instances to start with.",
        missing=1,
        default=1)
    runtime = RuntimePlugin(
        title="Runtime",
        description=
        "A section describing the runtime plugin name and version for this instance."
    )
    startup = Prepares(
        title="Startup tasks",
        description=
        "A list of plugins and parameters to run on instance startup.",
        default=[],
        missing=[])
    placement = PlacementPlugin(
        title="Placement information",
        description=
        "A section that provides hints to Paasmaker about where to place your application.",
        default=PlacementPlugin.default(),
        missing=PlacementPlugin.default())
    hostnames = colander.SchemaNode(
        colander.Sequence(),
        colander.SchemaNode(colander.String()),
        title="Hostnames",
        description=
        "A set of public hostnames that this instance will have if it is the current version of the application.",
        default=[],
        missing=[])
    exclusive = colander.SchemaNode(
        colander.Boolean(),
        title="Version Exclusive",
        description=
        "If set to true, only one version of this instance type will run at a time. This is good for background workers that you don't want overlapping.",
        default=False,
        missing=False)
    standalone = colander.SchemaNode(
        colander.Boolean(),
        title="Standalone",
        description=
        "If true, this instance doesn't require a TCP port. Affects the startup of the application.",
        default=False,
        missing=False)
    crons = Crons(
        title="Cron tasks",
        description=
        "A list of cron tasks to run against your instances. Cron is implemented by calling a URL on your instance.",
        default=[],
        missing=[])
Exemple #20
0
class CandidatesSchema(Schema):
    candidates = colander.SchemaNode(colander.Sequence(),
                                     omit(
                                         CandidateSchema(widget=ObjectWidget(),
                                                         editable=True,
                                                         name='candidate',
                                                         omit=['judgment']),
                                         ['_csrf_token_']),
                                     widget=InLineWidget(),
                                     title=_('Candidates'))
Exemple #21
0
class ExtractSchema(SmartFolderSchema):
    classifications = colander.SchemaNode(
        colander.Sequence(),
        colander.SchemaNode(colander.String(),
                            widget=classifications_widget,
                            name=_("Classification")),
        widget=classifications_seq_widget,
        title=_('Classifications'),
        description=_('Select one or more options of classification.'),
        validator=colander.Length(min=1))
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 #24
0
def main(options):
    log.addHandler(logging.StreamHandler(sys.stdout))
    log.setLevel(getattr(logging, options.log_level.upper()))
    log.debug(options)

    nbhd = M.Neighborhood.query.get(name=options.neighborhood)
    if not nbhd:
        return 'Invalid neighborhood "%s".' % options.neighborhood

    data = json.load(open(options.file, 'r'))

    # dynamically add to the schema (e.g. if needs nbhd)
    project = Project()
    project.add(
        col.SchemaNode(col.Sequence(),
                       col.SchemaNode(Award(nbhd)),
                       name='awards',
                       missing=[]))
    project.add(
        col.SchemaNode(ProjectShortnameType(nbhd, options.update),
                       name='shortname',
                       missing=None))

    projects = []
    for datum in data:
        try:
            projects.append(project.deserialize(datum))
        except Exception:
            keep_going = options.validate_only
            log.error('Error on %s\n%s',
                      datum['shortname'],
                      datum,
                      exc_info=keep_going)
            if not keep_going:
                raise

    log.debug(projects)

    if options.validate_only:
        return

    chunks = [projects[i::options.nprocs] for i in range(options.nprocs)]
    jobs = []
    for i in range(options.nprocs):
        p = multiprocessing.Process(target=create_projects,
                                    args=(chunks[i], nbhd, options),
                                    name='worker-' + str(i + 1))
        jobs.append(p)
        p.start()

    for j in jobs:
        j.join()
        if j.exitcode != 0:
            return j.exitcode
    return 0
Exemple #25
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 #26
0
    def literal_data(self, data_input):
        node = colander.SchemaNode(
            self.colander_literal_type(data_input),
            name=data_input.identifier,
            title=data_input.title,
            validator=TextValidator(),
        )

        # sometimes abstract is not set
        node.description = getattr(data_input, 'abstract', '')
        # optional value?
        if data_input.minOccurs == 0:
            node.missing = colander.drop
        # TODO: fix init of default
        if hasattr(data_input, 'defaultValue') \
           and data_input.defaultValue is not None:
            if type(node.typ) in (colander.DateTime, colander.Date,
                                  colander.Time):
                node.default = dateutil.parser.parse(data_input.defaultValue)
            elif type(node.typ) == colander.Boolean:
                # TODO: boolean default does not work ...
                node.default = bool(data_input.defaultValue == 'True')
            else:
                node.default = data_input.defaultValue
        self.colander_literal_widget(node, data_input)

        ## Find ranges and use new validator
        if node.name == "elevationOut":
            LOGGER.debug("Looking at the elevationOut node")
            LOGGER.debug("%s" % (node))
            node.validator = RangeValidator()

        # Use validators for longitude and latitude
        if node.name == "latitude":
            node.validator = LatitudeValidator()
        if node.name == "longitude":
            node.validator = LongitudeValidator()
        if node.name == "lon_bounds":
            node.validator = LongitudeBoundaryValidator()
        if node.name == "lat_bounds":
            node.validator = LatitudeBoundaryValidator()
        if node.name == "scale":
            node.validator = TupleFloatValidator()

        # sequence of nodes ...
        if data_input.maxOccurs > 1:
            node = colander.SchemaNode(
                colander.Sequence(),
                node,
                name=data_input.identifier,
                title=data_input.title,
                validator=colander.Length(max=data_input.maxOccurs))

        return node
Exemple #27
0
class ListReleaseSchema(PaginatedSchema):
    name = colander.SchemaNode(
        colander.String(),
        location="querystring",
        missing=None,
    )

    updates = Updates(
        colander.Sequence(accept_scalar=True),
        location="querystring",
        missing=None,
        preparer=[splitter],
    )

    packages = Packages(
        colander.Sequence(accept_scalar=True),
        location="querystring",
        missing=None,
        preparer=[splitter],
    )
Exemple #28
0
class PermissionsSchema(resource.ResourceSchema):
    uri = colander.SchemaNode(colander.String())
    resource_name = colander.SchemaNode(colander.String())
    permissions = colander.Sequence(colander.SchemaNode(colander.String()))
    bucket_id = colander.SchemaNode(colander.String())
    collection_id = colander.SchemaNode(colander.String(), missing=colander.drop)
    group_id = colander.SchemaNode(colander.String(), missing=colander.drop)
    record_id = colander.SchemaNode(colander.String(), missing=colander.drop)

    class Options:
        preserve_unknown = False
Exemple #29
0
class CreateAdminGroupSchema(CSRFSchema):

    group_type = colander.SchemaNode(
        colander.String(),
        title=_('Group Type'),
        widget=SelectWidget(values=(('', _('Select')), ) + VALID_GROUP_TYPES),
        validator=group_type_validator,
    )

    name = colander.SchemaNode(
        colander.String(),
        title=_('Group Name'),
        validator=validators.Length(min=GROUP_NAME_MIN_LENGTH,
                                    max=GROUP_NAME_MAX_LENGTH),
    )

    authority = colander.SchemaNode(
        colander.String(),
        title=_('Authority'),
        description=_("The group's authority"),
        hint=_('The authority within which this group should be created.'
               ' Note that only users within the designated authority'
               ' will be able to be associated with this group (as'
               ' creator or member).'))

    creator = colander.SchemaNode(
        colander.String(),
        title=_('Creator'),
        description=_("Username for this group's creator"),
        hint=_(
            'This user will be set as the "creator" of the group. Note that'
            ' the user must be on the same authority as the group authority'),
    )

    description = colander.SchemaNode(
        colander.String(),
        title=_('Description'),
        description=_('Optional group description'),
        validator=colander.Length(max=GROUP_DESCRIPTION_MAX_LENGTH),
        widget=TextAreaWidget(rows=3),
        missing=None)

    origins = colander.SequenceSchema(
        colander.Sequence(),
        colander.SchemaNode(colander.String(),
                            name='origin',
                            validator=colander.url),
        title=_('Scope Origins'),
        hint=_(
            'Origins where this group appears (e.g. "https://example.com")'),
        widget=SequenceWidget(add_subitem_text_template=_('Add origin'),
                              min_len=1),
        validator=colander.Length(
            min=1, min_err=_('At least one origin must be specified')))
Exemple #30
0
class ListCommentSchema(PaginatedSchema, SearchableSchema):
    updates = Updates(
        colander.Sequence(accept_scalar=True),
        location="querystring",
        missing=None,
        preparer=[splitter],
    )

    packages = Packages(
        colander.Sequence(accept_scalar=True),
        location="querystring",
        missing=None,
        preparer=[splitter],
    )

    user = colander.SchemaNode(
        colander.String(),
        location="querystring",
        missing=None,
    )

    update_owner = colander.SchemaNode(
        colander.String(),
        location="querystring",
        missing=None,
    )

    anonymous = colander.SchemaNode(
        colander.Boolean(true_choices=('true', '1')),
        location="querystring",
        missing=None,
    )

    since = colander.SchemaNode(
        colander.DateTime(),
        location="querystring",
        missing=None,
    )