Пример #1
0
class Type(Base):
    __tablename__ = "type"
    __table_args__ = {"schema": schema}
    __colanderalchemy_config__ = {"title": _("Type"), "plural": _("Types")}

    id = Column(
        Integer,
        primary_key=True,
        info={"colanderalchemy": {"title": _("Identifier"), "widget": HiddenWidget()}},
    )
    label_fr = Column(
        String(50),
        info={
            "colanderalchemy": {"title": _("Label(fr)"), "widget": TextInputWidget()}
        },
    )
    label_en = Column(
        String(50),
        info={
            "colanderalchemy": {"title": _("Label(en)"), "widget": TextInputWidget()}
        },
    )
    category_id = Column(
        Integer,
        ForeignKey("{}.category.id".format(schema)),
        info={
            "colanderalchemy": {
                "title": _("Category"),
                "widget": RelationSelectWidget(
                    Category,
                    "id",
                    "label_fr",
                    order_by="label_fr",
                    default_value=("", _("- Select -")),
                ),
            }
        },
    )
    category = relationship(Category, backref="types")
    wms_layer = Column(
        String(255),
        info={
            "colanderalchemy": {
                "title": _("WMS layer"),
                "description": _(
                    "Example: https://service.wms/?service=WMS&version=1.0.3&layer=layername"
                ),
                "widget": TextInputWidget(),
            }
        },
    )

    def icon_url(self, request):
        return self.category.icon_url(request)

    def label(self, locale):
        return getattr(self, "label_{}".format(locale))
Пример #2
0
class EditGameDepSchema(MappingSchema):
    name = SchemaNode(String(),
                      widget=TextInputWidget(size=40),
                      validator=Regex(
                          "^[a-zA-Z_0-9]*$",
                          "Only characters a-z A-Z 0-9 _ " + "are accepted."))
    display_name = SchemaNode(String(), widget=TextInputWidget(size=40))
    description = SchemaNode(String(), widget=TextAreaWidget(cols=80, rows=20))
    tags = SchemaNode(String(), widget=TextInputWidget(size=40), missing='')
Пример #3
0
class ThreadSchemaAPI(MappingSchema):
    title = SchemaNode(String(),
                       default=deferred_default_title,
                       widget=TextInputWidget(),
                       location="body",
                       type='str')
    description = SchemaNode(String(),
                             default=deferred_default_description,
                             widget=TextInputWidget(),
                             location="body",
                             type='str')
Пример #4
0
class ThreadSchema(MappingSchema):
    title = SchemaNode(String(),
                       default=deferred_default_title,
                       widget=TextInputWidget(),
                       location="body",
                       type='str')
    description = SchemaNode(String(),
                             default=deferred_default_description,
                             widget=TextInputWidget(),
                             location="body",
                             type='str')
    body = SchemaNode(String(),
                      default='',
                      location="body",
                      type='str',
                      widget=TextAreaWidget(rows=5, cols=80))
Пример #5
0
class EditArticleSchema(MappingSchema):
    display_name = SchemaNode(String(),
                              widget=TextInputWidget(size=40),
                              missing='',
                              location="body",
                              type='str')
    article = SchemaNode(String(),
                         widget=TextAreaWidget(cols=140, rows=20),
                         location="body",
                         type='str')
    summary = SchemaNode(String(),
                         widget=TextInputWidget(size=40),
                         missing='',
                         location="body",
                         type='str')
    tags = SchemaNode(String(), widget=TextInputWidget(size=40), missing='')
Пример #6
0
class ClientNewValidator(Schema):
    name = SchemaNode(String(),
                      title=u'Ime klijenta',
                      widget=TextInputWidget(),
                      validator=Length(
                          min=1,
                          max=1024,
                          min_err=MIN_CHAR_LENGTH_ERROR.format(1),
                          max_err=MAX_CHAR_LENGTH_ERROR.format(1024)),
                      missing_msg=REQUIRED_FIELD)
    address = SchemaNode(String(),
                         title=u'Adresa klijenta',
                         widget=TextInputWidget(),
                         missing=null,
                         validator=Length(
                             min=1,
                             max=1024,
                             min_err=MIN_CHAR_LENGTH_ERROR.format(1),
                             max_err=MAX_CHAR_LENGTH_ERROR.format(1024)))
    city = SchemaNode(String(),
                      title=u'Grad klijenta',
                      widget=TextInputWidget(),
                      missing=null,
                      validator=Length(
                          min=1,
                          max=1024,
                          min_err=MIN_CHAR_LENGTH_ERROR.format(1),
                          max_err=MAX_CHAR_LENGTH_ERROR.format(1024)))
    postal_code = SchemaNode(String(),
                             title=u'Poštanski broj klijenta',
                             widget=TextInputWidget(),
                             missing=null,
                             validator=Length(
                                 min=1,
                                 max=1024,
                                 min_err=MIN_CHAR_LENGTH_ERROR.format(1),
                                 max_err=MAX_CHAR_LENGTH_ERROR.format(1024)))
    oib = SchemaNode(String(),
                     title=u'OIB klijenta',
                     widget=TextInputWidget(),
                     missing=null,
                     validator=Length(
                         min=1,
                         max=20,
                         min_err=MIN_CHAR_LENGTH_ERROR.format(1),
                         max_err=MAX_CHAR_LENGTH_ERROR.format(20)))
Пример #7
0
class ReportingPeriodForm(colander.MappingSchema):
    validator = StartEndDateValidator()
    title = colander.SchemaNode(colander.String(encoding='utf-8'),
                                title=_(u"Name"),
                                description=_(
                                    u"Give the reporting period a name", ))
    form_xpath = colander.SchemaNode(
        colander.String(encoding='utf-8'),
        title=_(u"Form Xpath"),
        description=_(u"The identifier located in the XLSForms", ))
    start_date = colander.SchemaNode(MonthYearDate(),
                                     title=_(u"Start Date"),
                                     widget=TextInputWidget(),
                                     missing_msg=_(u"Start date is required"))
    end_date = colander.SchemaNode(MonthYearDate(),
                                   title=_(u"End Date"),
                                   widget=TextInputWidget(),
                                   missing_msg=_(u"End date is required"))
Пример #8
0
class PostSchema(MappingSchema):
    title = SchemaNode(String(),
                       default=deferred_default_title,
                       widget=TextInputWidget(),
                       location="body",
                       type='str')
    body = SchemaNode(String(),
                      default=deferred_default_body,
                      widget=TextAreaWidget(rows=5, cols=80),
                      location="body",
                      type='str')
Пример #9
0
class ReceiptEditValidator(ReceiptBaseValidator):
    client_name = colander.SchemaNode(
        colander.String(),
        title=Receipt.CLIENT,
        widget=TextInputWidget(
            readonly=True,
            readonly_template=u'readonly/textinput_readonly'
        ),
        missing_msg=REQUIRED_FIELD,
        insert_before='number'
    )
Пример #10
0
class ClientItemSchema(colander.Schema):
    client_item_id = colander.SchemaNode(colander.Integer(),
                                         widget=HiddenWidget(),
                                         validator=client_item_id_validator,
                                         missing_msg=REQUIRED_FIELD)
    name = colander.SchemaNode(
        colander.String(),
        title=Item.NAME,
        widget=TextInputWidget(
            readonly=True, readonly_template=u'readonly/textinput_readonly'),
        missing_msg=REQUIRED_FIELD)
    price = colander.SchemaNode(
        colander.Decimal('0.01', decimal.ROUND_HALF_EVEN),
        title=Item.PRICE,
        missing_msg=REQUIRED_FIELD,
        widget=TextInputWidget(),
        validator=colander.Range(
            min=0,
            max=999999.99,
            min_err=string_constants.MIN_NUMBER_RANGE_ERROR.format(0),
            max_err=string_constants.MAX_NUMBER_RANGE_ERROR.format(999999.99)))
Пример #11
0
class DeviceLinkSchema(MappingSchema):
    device = SchemaNode(typ=Int(),
                        title='Parameter',
                        default=deferred_device_default,
                        widget=deferred_device_widget)
    target = SchemaNode(typ=String(),
                        title='Target Log',
                        default='value',
                        widget=SelectWidget(values=[('value', 'Values'), ('setpoint', 'Setpoints')]))
    color = SchemaNode(typ=String(),
                       title='Color',
                       default='#FF0000',
                       widget=TextInputWidget())
Пример #12
0
class Category(Base):
    __tablename__ = "category"
    __table_args__ = {"schema": schema}
    __colanderalchemy_config__ = {"title": _("Category"), "plural": _("Categories")}

    id = Column(
        Integer,
        primary_key=True,
        info={"colanderalchemy": {"title": _("Identifier"), "widget": HiddenWidget()}},
    )
    label_fr = Column(
        String(50),
        info={
            "colanderalchemy": {"title": _("Label(fr)"), "widget": TextInputWidget()}
        },
    )
    label_en = Column(
        String(50),
        info={
            "colanderalchemy": {"title": _("Label(en)"), "widget": TextInputWidget()}
        },
    )
    email = Column(
        String(254),
        nullable=False,
        info={"colanderalchemy": {"title": _("Email"), "widget": TextInputWidget()}},
    )

    icon = Column(
        String(150),
        info={"colanderalchemy": {"title": _("Label(en)"), "widget": HiddenWidget()}},
    )

    def icon_url(self, request):
        return generate_url(request, self.icon or default_icon())

    def label(self, locale):
        return getattr(self, "label_{}".format(locale))
Пример #13
0
 def get(self):
     appstruct = {}
     appstruct['came_from'] = self.request.referrer
     if self.request.user:
         appstruct['contact_name'] = self.request.user.full_name
         appstruct['reply_email'] = self.request.user.email
         for field in self.frm:
             if field.name == 'contact_name' or field.name == 'reply_email':
                 field.widget = TextInputWidget(
                     template='readonly/textinput')
     rendered_form = self.frm.render(appstruct=appstruct)
     return {
         'forms': [self.frm],
         'rendered_form': rendered_form,
     }
class ParameterLinkSchema(MappingSchema):
    parameter = SchemaNode(typ=Int(),
                           title='Parameter',
                           default=deferred_parameter_default,
                           widget=deferred_parameter_widget)
    target = SchemaNode(
        typ=String(),
        title='Target Log',
        default=deferred_target_default,
        widget=SelectWidget(values=[('value',
                                     'Values'), ('setpoint', 'Setpoints')]))
    color = SchemaNode(typ=String(),
                       title='Color',
                       default=deferred_color_default,
                       widget=TextInputWidget())
Пример #15
0
class EditProfileSchema(CSRFSchema):
    username = SchemaNode(
        String(),
        missing='',
        widget=TextInputWidget(template='readonly/textinput'),
    )
    first_name = SchemaNode(String(), required=False)
    last_name = SchemaNode(String(), required=False)
    email = SchemaNode(
        String(),
        title=u'Email Address',
        validator=create_user_email_validator,
        widget=CheckedInputWidget(subject=u'Email Address',
                                  confirm_subject=u'Confirm Email Address'),
    )
    came_from = SchemaNode(
        String(),
        widget=HiddenWidget(),
        default='.',
        title=u'came_from',
    )
Пример #16
0
class OrganizationSchema(CSRFSchema):

    authority = colander.SchemaNode(colander.String(), title=_("Authority"))

    name = colander.SchemaNode(
        colander.String(),
        title=_("Name"),
        validator=validators.Length(ORGANIZATION_NAME_MIN_CHARS,
                                    ORGANIZATION_NAME_MAX_CHARS),
        widget=TextInputWidget(max_length=ORGANIZATION_NAME_MAX_CHARS),
    )

    logo = colander.SchemaNode(
        colander.String(),
        title=_("Logo"),
        hint=_("SVG markup for logo. You can get this from a .svg file by"
               " opening it in a text editor and copying the contents."),
        widget=TextAreaWidget(rows=5),
        validator=validate_logo,
        missing=None,
    )
Пример #17
0
class CreateAdminGroupSchema(CSRFSchema):

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

    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=TextInputWidget(rows=3),
        missing=None)
Пример #18
0
class RegistrationForm(colander.MappingSchema):
    group = colander.SchemaNode(colander.String(encoding='utf-8'),
                                title=_(u"Role"),
                                widget=new_user_role_widget)
    clinics = colander.SchemaNode(colander.Set(),
                                  title=_(u"Clinic"),
                                  missing='',
                                  widget=clinic_selection_widget)
    municipality = colander.SchemaNode(colander.String(encoding='utf-8'),
                                       title=_(u"Municipality"),
                                       missing='',
                                       widget=municipality_selection_widget)
    state = colander.SchemaNode(colander.String(encoding='utf-8'),
                                title=_(u"State"),
                                missing='',
                                widget=state_selection_widget)
    username = colander.SchemaNode(
        colander.String(encoding='utf-8'),
        validator=colander.Length(max=25,
                                  max_err=_(u'Longer than maximum length 25')),
        widget=TextInputWidget(),
        title=_(u"Username"),
        description=_(u"Type the username of the clinic"))
    password = colander.SchemaNode(
        colander.String(encoding='utf-8'),
        validator=colander.Length(min=5,
                                  min_err=_(u'Shorter than minimum length 5')),
        widget=CheckedPasswordWidget(subject=_(u"Password"),
                                     confirm_subject=_(u"Confirm Password")),
        title=_(u"Password"))

    def validator(self, node, value):
        exc = colander.Invalid(node, "")
        valid = True
        if value['group'] not in GROUPS:
            valid = False

        if not valid:
            raise exc
Пример #19
0
class SiteProfileForm(colander.MappingSchema):
    name = colander.SchemaNode(colander.Str(),
                               title="Municipality Name",
                               widget=TextInputWidget(size=30))
    box_volume = colander.SchemaNode(
        colander.Float(),
        title="Standard Box's Volume (m3)",
        validator=colander.Range(min=MIN_VOLUME,
                                 min_err="The length must be greater than 0"))
    wheelbarrow_volume = colander.SchemaNode(
        colander.Float(),
        title="Wheelbarrow's Volume (m3)",
        validator=colander.Range(min=MIN_VOLUME,
                                 min_err="The length must be greater than 0"))
    leachete_tank_length = colander.SchemaNode(
        colander.Float(),
        title="Leachete Tank's Length (m)",
        validator=colander.Range(min=MIN_VOLUME,
                                 min_err="The length must be greater than 0"))
    leachete_tank_width = colander.SchemaNode(
        colander.Float(),
        title="Leachete Tank's Width (m)",
        validator=colander.Range(min=MIN_VOLUME,
                                 min_err="The length must be greater than 0"))
Пример #20
0
import colander
from storage.schemas import FileData
from deform.widget import (TextInputWidget, TextAreaWidget, HiddenWidget,
                           FileUploadWidget)


class MemoryFileUploadTempStore(dict):
    def preview_url(self, uuid):
        return None


tmpstore = MemoryFileUploadTempStore()
input_widget = TextInputWidget(css_class='form-control')
text_widget = TextAreaWidget(css_class='form-control body-field')
file_widget = FileUploadWidget(tmpstore, css_class='form-control')


class BlogCreateSchema(colander.Schema):
    title = colander.SchemaNode(colander.String(),
                                title='Title',
                                widget=input_widget)
    slug = colander.SchemaNode(colander.String(),
                               missing=None,
                               title='Slug',
                               widget=input_widget)
    body = colander.SchemaNode(colander.String(),
                               title='Body',
                               widget=text_widget)
    image = colander.SchemaNode(FileData(upload_to='blog/'),
                                missing='',
                                title='Image',
Пример #21
0
    def __init__(self,
                 title,
                 name,
                 round=1,
                 missing=u'',
                 widget=None,
                 l_choices=None,
                 multiple=False,
                 desc=None,
                 table_reduce=False,
                 rank=0,
                 required=False,
                 missing_msg='champ requis',
                 primary_key=False,
                 codec='utf-8'):

        # Form display
        self.title = title
        self.name = name
        self.round = round
        self.type = unicode
        self.desc = desc
        self.required = required
        self.missing_msg = missing_msg
        self.multiple = multiple
        self.mapinit = None if not self.multiple else []

        # Db column
        self.dbcol_ = (name, Colsql(Strsql(250), primary_key=primary_key))

        # Table display
        self.table_reduce, self.rank = table_reduce, rank

        if widget is not None:
            self.widget = widget
        else:
            if l_choices is not None:
                if len(l_choices) < 1:
                    l_choices = [('', '-')]
                self.widget = Select2Widget(values=l_choices,
                                            multiple=multiple)
            else:
                self.widget = TextInputWidget()

        self.processing_form = {
            'form': lambda x: x.decode(codec) if isinstance(x, str) else x,
            'db': lambda x: x.decode(codec) if isinstance(x, str) else x
        }
        self.processing_db = {
            'upload': lambda x: x.decode(codec) if isinstance(x, str) else x,
            'download': lambda x: x.decode(codec) if isinstance(x, str) else x
        }

        if not multiple:
            self.sn = sn(String(),
                         title=self.title,
                         name=name,
                         widget=self.widget,
                         missing=missing,
                         description=desc,
                         required=self.required,
                         missing_msg=self.missing_msg)
        else:
            self.processing_form.update({
                'form':
                lambda x: ';'.join(map(str, x)) if x else missing,
                'db':
                lambda x: x.split(';')
            })
            self.sn = sn(Set(),
                         title=self.title,
                         name=name,
                         widget=self.widget,
                         description=desc)

        if not required:
            self.sn.missing = missing
Пример #22
0
class EditRevisionSchema(MappingSchema):
    version = SchemaNode(Decimal(), widget=TextInputWidget(size=40))
    module_type = SchemaNode(String(),
                             name="moduletype",
                             widget=deferred_revision_module_type_widget,
                             validator=deferred_revision_module_type_validator)
Пример #23
0
def PlaceholderTextInputWidget(placeholder, type='text'):
    w = TextInputWidget(template='placeholderinput',
                        type=type,
                        placeholder=placeholder)
    return w
Пример #24
0
class CreateAdminGroupSchema(CSRFSchema):
    def __init__(self, *args):
        super(CreateAdminGroupSchema,
              self).__init__(validator=group_creator_validator, *args)

    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),
        widget=TextInputWidget(max_length=GROUP_NAME_MAX_LENGTH),
    )

    organization = colander.SchemaNode(
        colander.String(),
        title=_('Organization'),
        description=_('Organization which this group belongs to'),
        widget=group_organization_select_widget,
    )

    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, max_length=GROUP_DESCRIPTION_MAX_LENGTH),
        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')))

    members = colander.SequenceSchema(
        colander.Sequence(),
        colander.SchemaNode(colander.String(),
                            name='member',
                            validator=member_exists_validator),
        title=_('Members'),
        hint=_('Add more members by their username to this group'),
        widget=SequenceWidget(add_subitem_text_template=_('Add member')),
        missing=None)
Пример #25
0
 def serialize(self, field, cstruct, **kw):
     jquery.need()
     jqueryui.need()
     mba_widget.need()
     kw['position'] = self.position
     return TextInputWidget.serialize(self, field, cstruct, **kw)
Пример #26
0
class PeripheryControllerSchema(MappingSchema):
    name = SchemaNode(typ=String(),
                      title='Name',
                      default=deferred_name_default,
                      widget=TextInputWidget(size=40))
Пример #27
0
class ItemNewSchema(Schema):
    name = SchemaNode(
        String(),
        title=Item.NAME,
        widget=TextInputWidget(),
        validator=Length(
            min=1,
            max=2048,
            min_err=MIN_CHAR_LENGTH_ERROR.format(1),
            max_err=MAX_CHAR_LENGTH_ERROR.format(2048)
        ),
        missing_msg=REQUIRED_FIELD
    )
    ean = SchemaNode(
        String(),
        title=Item.EAN,
        widget=TextInputWidget(),
        missing=null,
        validator=Length(
            min=1,
            max=1024,
            min_err=MIN_CHAR_LENGTH_ERROR.format(1),
            max_err=MAX_CHAR_LENGTH_ERROR.format(1024)
        )
    )
    measurement_unit = SchemaNode(
        String(),
        title=Item.MEASUREMENT_UNIT,
        widget=TextInputWidget(),
        missing=null,
        validator=Length(
            min=1,
            max=128,
            min_err=MIN_CHAR_LENGTH_ERROR.format(1),
            max_err=MAX_CHAR_LENGTH_ERROR.format(128)
        )
    )
    pack_size = SchemaNode(
        Integer(),
        title=Item.PACK_SIZE,
        widget=TextInputWidget(),
        missing=null,
        validator=Range(
            min=1,
            max=9999,
            min_err=MIN_NUMBER_RANGE_ERROR.format(1),
            max_err=MAX_NUMBER_RANGE_ERROR.format(9999)
        )
    )
    pallete_size = SchemaNode(
        Integer(),
        title=Item.PALLETE_SIZE,
        widget=TextInputWidget(),
        missing=null,
        validator=Range(
            min=1,
            max=9999,
            min_err=MIN_NUMBER_RANGE_ERROR.format(1),
            max_err=MAX_NUMBER_RANGE_ERROR.format(9999)
        )
    )
    price = SchemaNode(
        Decimal('0.01', decimal.ROUND_HALF_EVEN),
        title=Item.PRICE,
        widget=TextInputWidget(),
        missing_msg=REQUIRED_FIELD,
        validator=Range(
            min=0,
            max=999999.99,
            min_err=MIN_NUMBER_RANGE_ERROR.format(0),
            max_err=MAX_NUMBER_RANGE_ERROR.format(999999.99)
        )
    )
    return_amount = SchemaNode(
        Float(),
        title=Item.RETURN_AMOUNT,
        widget=TextInputWidget(),
        default=0.0,
        validator=Range(
            min=0.0,
            max=9999,
            min_err=MIN_NUMBER_RANGE_ERROR.format(0.0),
            max_err=MAX_NUMBER_RANGE_ERROR.format(9999)
        )
    )
    stock_quantity = SchemaNode(
        Integer(),
        title=Item.STOCK_QUANTITY,
        widget=TextInputWidget(),
        validator=Range(
            min=-9999,
            max=9999,
            min_err=MIN_NUMBER_RANGE_ERROR.format(-9999),
            max_err=MAX_NUMBER_RANGE_ERROR.format(9999)
        )
    )
Пример #28
0
class LayerWMS(DimensionLayer):
    __tablename__ = "layer_wms"
    __table_args__ = {"schema": _schema}
    __colanderalchemy_config__ = {
        "title": _("WMS Layer"),
        "plural": _("WMS Layers")
    }

    __c2cgeoform_config__ = {"duplicate": True}

    __mapper_args__ = {"polymorphic_identity": "l_wms"}

    id = Column(
        Integer,
        ForeignKey(_schema + ".layer.id", ondelete="CASCADE"),
        primary_key=True,
        info={"colanderalchemy": {
            "missing": None,
            "widget": HiddenWidget()
        }},
    )
    ogc_server_id = Column(
        Integer,
        ForeignKey(_schema + ".ogc_server.id"),
        nullable=False,
        info={
            "colanderalchemy": {
                "title":
                _("OGC server"),
                "column":
                2,
                "widget":
                RelationSelect2Widget(OGCServer,
                                      "id",
                                      "name",
                                      order_by="name",
                                      default_value=("", _("- Select -"))),
            }
        },
    )
    layer = Column(
        Unicode,
        nullable=False,
        info={"colanderalchemy": {
            "title": _("WMS layer name"),
            "column": 2
        }})
    style = Column(
        Unicode, info={"colanderalchemy": {
            "title": _("Style"),
            "column": 2
        }})
    valid = Column(
        Boolean,
        info={
            "colanderalchemy": {
                "title": _("Valid"),
                "column": 2,
                "widget": CheckboxWidget(readonly=True)
            }
        },
    )
    invalid_reason = Column(
        Unicode,
        info={
            "colanderalchemy": {
                "title": _("Reason why I am not valid"),
                "column": 2,
                "widget": TextInputWidget(readonly=True),
            }
        },
    )
    time_mode = Column(
        Enum("disabled", "value", "range", native_enum=False),
        default="disabled",
        nullable=False,
        info={
            "colanderalchemy": {
                "title":
                _("Time mode"),
                "column":
                2,
                "widget":
                SelectWidget(values=(("disabled", _("Disabled")), ("value",
                                                                   _("Value")),
                                     ("range", _("Range")))),
            }
        },
    )
    time_widget = Column(
        Enum("slider", "datepicker", native_enum=False),
        default="slider",
        nullable=False,
        info={
            "colanderalchemy": {
                "title":
                _("Time widget"),
                "column":
                2,
                "widget":
                SelectWidget(values=(("slider", _("Slider")),
                                     ("datepicker", _("Datepicker")))),
            }
        },
    )

    # relationship with OGCServer
    ogc_server = relationship(
        "OGCServer",
        info={"colanderalchemy": {
            "title": _("OGC server"),
            "exclude": True
        }})

    def __init__(
        self,
        name: str = "",
        layer: str = "",
        public: bool = True,
        time_mode: str = "disabled",
        time_widget: str = "slider",
    ) -> None:
        DimensionLayer.__init__(self, name=name, public=public)
        self.layer = layer
        self.time_mode = time_mode
        self.time_widget = time_widget

    @staticmethod
    def get_default(dbsession: Session) -> Optional[DimensionLayer]:
        return cast(
            Optional[DimensionLayer],
            dbsession.query(LayerWMS).filter(
                LayerWMS.name == "wms-defaults").one_or_none(),
        )
Пример #29
0
 def __init__(self, position='element_bottom', **kw):
     TextInputWidget.__init__(self, **kw)
     self.position = position
Пример #30
0
class FieldSettingSchema(MappingSchema):
    value = SchemaNode(typ=String(),
                       title=deferred_name_default,
                       default=deferred_value_default,
                       description=deferred_description_default,
                       widget=TextInputWidget())
Пример #31
0
class CreateAdminGroupSchema(CSRFSchema):
    def __init__(self, *args):
        super(CreateAdminGroupSchema, self).__init__(
            validator=group_creator_validator, *args
        )

    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
        ),
        widget=TextInputWidget(max_length=GROUP_NAME_MAX_LENGTH),
    )

    organization = colander.SchemaNode(
        colander.String(),
        title=_("Organization"),
        description=_("Organization which this group belongs to"),
        widget=group_organization_select_widget,
    )

    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, max_length=GROUP_DESCRIPTION_MAX_LENGTH),
        missing=None,
    )

    # Although the default value of the enforce_scope property is True,
    # we need to allow the unchecking of the checkbox that represents it,
    # which means that empty values should be treated as False.
    enforce_scope = colander.SchemaNode(
        colander.Boolean(),
        hint=_(
            "Only allow annotations for documents within this group's defined scopes"
        ),
        widget=CheckboxWidget(css_class="form-checkbox--inline"),
        missing=False,
    )

    scopes = colander.SequenceSchema(
        colander.Sequence(),
        colander.SchemaNode(
            colander.String(), name="scope", validator=url_with_origin_validator
        ),
        title=_("Scopes"),
        hint=_(
            "Define where this group appears. A document's URL must start with one or more"
            " of the entered scope strings (e.g. 'http://www.example.com')"
        ),
        widget=SequenceWidget(add_subitem_text_template=_("Add scope"), min_len=1),
        validator=colander.Length(
            min=1, min_err=_("At least one scope must be specified")
        ),
    )

    members = colander.SequenceSchema(
        colander.Sequence(),
        colander.SchemaNode(
            colander.String(), name="member", validator=member_exists_validator
        ),
        title=_("Members"),
        hint=_("Add more members by their username to this group"),
        widget=SequenceWidget(add_subitem_text_template=_("Add member")),
        missing=None,
    )
Пример #32
0
ABSTRACT_MAXLENGTH = 160


class ArgumentSchema(Schema):
    title = string_property(title=_('title'),
                            validator=Length(min=5, max=TITLE_MAXLENGTH))
    abstract = string_property(title=_('abstract'),
                               validator=Length(min=5, max=ABSTRACT_MAXLENGTH))
    details = string_property(title=_('details'),
                              validator=Length(min=10, max=4096),
                              missing='')


argument_widgets = {
    'title':
    TextInputWidget(attributes={'maxlength': TITLE_MAXLENGTH}),
    'abstract':
    TextAreaWidget(rows=2, attributes={'maxlength': ABSTRACT_MAXLENGTH}),
    'details':
    TextAreaWidget(rows=4)
}


class ArgumentForm(Form):
    def __init__(self, request, action):
        super().__init__(ArgumentSchema(),
                         request,
                         action,
                         buttons=[Button(title=_("submit"))])
        self.set_widgets(argument_widgets)