Ejemplo n.º 1
0
class Update(colander.MappingSchema):
    _id = colander.SchemaNode(colander.String(),
                                 default='',
                                 missing='')

    path = colander.SchemaNode(colander.String(),
                                 default='',
                                 missing='')

    name = colander.SchemaNode(colander.String(),
                                 default='',
                                 missing='')

    timestamp = colander.DateTime()
    rollback = colander.SchemaNode(colander.Integer(),
                                default = 0,
                                missing = 0)
    state = colander.SchemaNode(colander.Integer(),
                                default = 0,
                                missing = 0)
    timestamp_rollback = colander.DateTime()
    rolluser = colander.SchemaNode(colander.String(),
                                 default='',
                                 missing='')

    user = colander.SchemaNode(colander.String(),
                                 default='',
                                 missing='')
Ejemplo n.º 2
0
 def colander_literal_type(self, data_input):
     # LOGGER.debug('data input type = %s', data_input.dataType)
     if 'boolean' in data_input.dataType:
         return colander.Boolean()
     elif 'integer' in data_input.dataType:
         return colander.Integer()
     elif 'float' in data_input.dataType:
         return colander.Float()
     elif 'double' in data_input.dataType:
         return colander.Float()
     elif 'decimal' in data_input.dataType:
         return colander.Decimal()
     elif 'string' in data_input.dataType:
         return colander.String()
     elif 'dateTime' in data_input.dataType:
         return colander.DateTime()
     elif 'date' in data_input.dataType:
         return colander.Date()
     elif 'time' in data_input.dataType:
         return colander.Time()
     elif 'duration' in data_input.dataType:
         # TODO: check correct type
         # http://www.w3.org/TR/xmlschema-2/#duration
         return colander.Time()
     # guessing from default
     elif hasattr(data_input, 'defaultValue'):
         try:
             dateutil.parser.parse(data_input.defaultValue)
         except Exception:
             return colander.String()
         else:
             return colander.DateTime()
     else:
         return colander.String()
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
class EventSchema(DocumentSchema):
    start = colander.SchemaNode(colander.DateTime(default_tzinfo=None),
                                title=_(u"Start"))
    end = colander.SchemaNode(colander.DateTime(default_tzinfo=None),
                              title=_(u"End"),
                              missing=None)
    all_day = colander.SchemaNode(colander.Boolean(), title=_(u"All day"))
Ejemplo n.º 5
0
class Job(colander.MappingSchema):
    # This is not a ObjectId, is a UUID4 format string of numbers
    _id = colander.SchemaNode(colander.String())

    userid = colander.SchemaNode(ObjectIdField())
    objid = colander.SchemaNode(ObjectIdField())
    objname = colander.SchemaNode(colander.String(), default='no-provided')
    objpath = colander.SchemaNode(colander.String(), default='no-provided')
    computerid = colander.SchemaNode(ObjectIdField(), missing=colander._drop())
    computername = colander.SchemaNode(colander.String(), default='no-provided')
    policyname = colander.SchemaNode(colander.String(), default='no-provided')
    administrator_username = colander.SchemaNode(colander.String(), default='no-provided')

    # Verify that the status selected already exists
    status = colander.SchemaNode(colander.String(),
                                 validator=colander.OneOf(JOB_STATUS.keys()))
    archived = colander.SchemaNode(RealBoolean(),
                                   default=False,
                                   missing=False)
    message = colander.SchemaNode(colander.String(),
                                  default='',
                                  missing='')
    type = colander.SchemaNode(colander.String())
    op = colander.SchemaNode(colander.String(),
                             validator=colander.OneOf(
                                 ['created', 'changed', 'deleted']))

    created = colander.SchemaNode(colander.DateTime())
    last_update = colander.SchemaNode(colander.DateTime())
Ejemplo n.º 6
0
class ProfileSchema(colander.MappingSchema):
    applicationId = colander.SchemaNode(colander.String())
    candidateId = colander.SchemaNode(colander.Integer())
    isRetake = colander.SchemaNode(colander.Bool())
    invitationDate = colander.SchemaNode(colander.DateTime())
    applicationTime = colander.SchemaNode(colander.DateTime())
    speechToText = SpeechToTextSequence()
    videoLength = colander.SchemaNode(colander.Float())
    score = colander.SchemaNode(colander.Integer())
Ejemplo n.º 7
0
class LogSchema(colander.MappingSchema):
    from_time = colander.SchemaNode(
        colander.DateTime(),
        description=u"NOTE: time should be in form of HH:MM:SS",
        missing=colander.null,
        widget=DateTimeInputWidget())
    to_time = colander.SchemaNode(
        colander.DateTime(),
        description=u"NOTE: time should be in form of HH:MM:SS",
        missing=colander.null,
        widget=DateTimeInputWidget())
Ejemplo n.º 8
0
class channel_date_range(colander.MappingSchema):
    date_time_start = colander.SchemaNode(
        colander.DateTime(default_tzinfo=None),
        validator=deferred_date_validator,
        widget=deform.widget.DateTimeInputWidget())
    date_time_end = colander.SchemaNode(
        colander.DateTime(default_tzinfo=None),
        validator=deferred_date_validator,
        widget=deform.widget.DateTimeInputWidget())

    Frequency = colander.SchemaNode(
        colander.String(),
        validator=colander.Length(max=10),
        widget=deform.widget.TextInputWidget(size=10),
        description='Frequency MHz')
Ejemplo n.º 9
0
class EventSchema(DocumentSchema):
    """ Schema for events. """

    start = colander.SchemaNode(colander.DateTime(default_tzinfo=None),
                                title=_(u"Start"))
    end = colander.SchemaNode(colander.DateTime(default_tzinfo=None),
                              title=_(u"End"),
                              missing=None)
    all_day = colander.SchemaNode(colander.Boolean(), title=_(u"All day"))
    link_to_file = colander.SchemaNode(
        colander.Boolean(),
        title=_(u"Link to File"),
        description=_(u"When activated, the link in an associated calendar "
                      u"view points to the first contained file of the event "
                      u"(instead of to the calendar node)."))
Ejemplo n.º 10
0
 def test_sanity(self):
     node = colander.SchemaNode(colander.DateTime())
     ret = convert(node)
     self.assertDictEqual(ret, {
         'type': 'string',
         'format': 'date-time',
     })
Ejemplo n.º 11
0
class DemoObjSchema(base_schema.ObjTypeSchema):
    filename = FilenameSchema(
        save=True,
        update=True,
        isdatafile=True,
        test_equal=False,
    )

    foo_float = colander.SchemaNode(colander.Float(), save=True, update=True)

    foo_float_array = colander.SequenceSchema(colander.SchemaNode(
        colander.Float()),
                                              read_only=True)

    timeseries = colander.SequenceSchema(colander.TupleSchema(children=[
        colander.SchemaNode(colander.DateTime(default_tzinfo=None)),
        colander.SchemaNode(colander.Float())
    ]),
                                         read_only=True)

    variable = base_schema.GeneralGnomeObjectSchema(
        acceptable_schemas=[TimeseriesDataSchema, TimeseriesVectorSchema],
        save=True,
        update=True,
        save_reference=True,
    )

    variables = colander.SequenceSchema(base_schema.GeneralGnomeObjectSchema(
        acceptable_schemas=[TimeseriesDataSchema, TimeseriesVectorSchema]),
                                        save=True,
                                        update=True,
                                        save_reference=True)
Ejemplo n.º 12
0
class Post(TimestampedBase):
    """Represents a message in the system."""
    __tablename__ = 'posts'

    id = Column(Integer, primary_key=True)

    date = Column(DateTime, nullable=False,
                  ca_type=colander.DateTime(default_tzinfo=None))
    author = Column(Unicode(1024), nullable=False)
    subject = Column(Unicode(1024))
    email = relationship('Email', uselist=False, backref='post')
    body = Column(UnicodeText, nullable=False)
    message_id = Column(String, nullable=False, default=msg_id)

    parent_id = Column(Integer, ForeignKey('posts.id'))
    children = relationship('Post',
                            backref=backref('parent', remote_side=[id]))

    def __init__(self, *args, **kwargs):
        if not 'message_id' in kwargs:
            kwargs['message_id'] = msg_id()
        super(Post, self).__init__(*args, **kwargs)

    def __str__(self):
        return '%s %s %s' % (self.__class__.__name__, self.id, self.message_id)

    def ensure_msg_id(self):
        """Make sure the post has a message-id. Make one up if needed."""
        if not self.message_id:
            self.message_id = msg_id()
Ejemplo n.º 13
0
class SaveOverrideSchema(CSRFProtectedSchema, colander.MappingSchema):
    """An API schema for bodhi.server.services.overrides.save_override()."""

    nvr = colander.SchemaNode(
        colander.String(),
    )

    notes = colander.SchemaNode(
        colander.String(),
        validator=colander.Length(min=2),
    )

    expiration_date = colander.SchemaNode(
        colander.DateTime(default_tzinfo=None),
    )

    expired = colander.SchemaNode(
        colander.Boolean(),
        missing=False,
    )

    edited = colander.SchemaNode(
        colander.String(),
        missing=None,
    )
Ejemplo n.º 14
0
class CommentSchema(Schema):
    commenter = colander.SchemaNode(colander.String(), )
    text = colander.SchemaNode(colander.String(), )
    pubdate = colander.SchemaNode(
        colander.DateTime(),
        default=now_default,
    )
Ejemplo n.º 15
0
class LockSchema(Schema):
    ownerid = LockOwnerSchema()
    timeout = colander.SchemaNode(
        colander.Int(),
        validator=colander.Range(0),
        default=3600,
        title='Timeout (secs)',
        )
    infinite = colander.SchemaNode(
        colander.Boolean(),
        default=False,
        missing=False,
        title='Infinite?',
        description='Locks all descendants',
        )
    last_refresh = colander.SchemaNode(
        colander.DateTime(),
        title='Last Refresh',
        default=now(),
        )
    comment = colander.SchemaNode(
        colander.String(),
        validator=colander.Length(max=255),
        missing=None,
        title='Comment',
        )
    resource = LockResourceSchema()
Ejemplo n.º 16
0
class UserInfoSchema(colander.MappingSchema):
    username = colander.SchemaNode(
        colander.String(),
        oid="userinfo-username",
        missing="",
        widget=deform.widget.TextInputWidget(template="readonly/textinput"),
    )
    email = colander.SchemaNode(
        colander.String(),
        oid="userinfo-email",
        validator=colander.Email(msg="Invalid e-mail address"),
    )
    state = colander.SchemaNode(
        colander.String(),
        oid="userinfo-state",
        missing="",
        widget=deform.widget.TextInputWidget(template="readonly/textinput"),
    )
    created = colander.SchemaNode(
        colander.DateTime(),
        oid="userinfo-created",
        missing=None,
        widget=deform.widget.DateTimeInputWidget(
            template="readonly/datetimeinput"),
    )
Ejemplo n.º 17
0
class EventSchema(colander.MappingSchema):
    """Schema for new event data validation"""
    name = colander.SchemaNode(colander.String(),
                               validator=colander.Length(max=255))
    long = colander.SchemaNode(colander.Float(),
                               validator=colander.Range(-180, 180))
    lat = colander.SchemaNode(colander.Float(),
                              validator=colander.Range(-90, 90))
    description = colander.SchemaNode(colander.String(),
                                      validator=colander.Length(max=20000))
    start_date = colander.SchemaNode(colander.DateTime())
    end_date = colander.SchemaNode(colander.DateTime(), missing=colander.drop)
    main_image = colander.SchemaNode(colander.String(), missing=colander.drop)
    category = colander.SchemaNode(colander.String(),
                                   validator=colander.Length(max=255))
    tags = Tags(missing=colander.drop)
Ejemplo n.º 18
0
class PublicationConfigurationSchema(Schema):

    """Schema for site configuration."""

    closing_date = colander.SchemaNode(
        colander.DateTime(),
        title=_('Closing date')
        )

    closing_frequence = colander.SchemaNode(
        colander.Integer(),
        default=DEFAULT_CLOSING_FREQUENCE,
        title=_('Closing frequence'),
        )

    delay_before_publication = colander.SchemaNode(
        colander.Integer(),
        default=DEFAULT_DELAY_BEFORE_PUBLICATION,
        title=_('Delay before publication'),
        )

    publication_number = colander.SchemaNode(
        colander.Integer(),
        default=0,
        title=_('Publication number'),
        )

    extraction_template = colander.SchemaNode(
        ObjectData(File),
        widget=get_file_widget(file_extensions=['odt']),
        title=_('Extraction template'),
        missing=None,
        description=_("Only ODT files are supported."),
        )
Ejemplo n.º 19
0
class DigitalSetSchema(colander.MappingSchema):
    id_set = colander.SchemaNode(colander.String(), missing='')
    created = colander.SchemaNode(colander.DateTime(),
                                  missing=datetime.datetime.now())
    description = colander.SchemaNode(colander.String(), missing='')
    id_user = colander.SchemaNode(colander.String(), missing='')
    metadata = MetadataSequenceSchema(missing=[])
    groups = DGroupSequenceSchema(missing=[])
Ejemplo n.º 20
0
def define_date_node(schema):
    schema['vote'] = colander.SchemaNode(
            colander.DateTime(),
            widget=deform.widget.DateTimeInputWidget(),
            validator=colander.Range(min=datetime.datetime.now(tz=pytz.UTC),
                min_err=_('${val} is earlier than earliest datetime ${min}')),
            title=_('Date')
            )               
Ejemplo n.º 21
0
Archivo: view.py Proyecto: iimcz/emod
class ViewSchema(colander.MappingSchema):
    id_view = colander.SchemaNode(colander.String(), missing='')
    created = colander.SchemaNode(colander.DateTime(),
                                  missing=datetime.datetime.now())
    description = colander.SchemaNode(colander.String(), missing='')
    id_user = colander.SchemaNode(colander.String(), missing='')
    public = colander.SchemaNode(colander.Integer(), missing=0)
    metadata = MetadataSequenceSchema(missing=[])
Ejemplo n.º 22
0
def now_node(**kw):
    """
    Return a schema node for time selection, defaulted to "now"
    """
    if "default" not in kw:
        kw['default'] = deferred_now
    return colander.SchemaNode(colander.DateTime(default_tzinfo=None),
                               widget=get_datetime_input(),
                               **kw)
Ejemplo n.º 23
0
class ReportSchema(colander.MappingSchema):

    hash = colander.SchemaNode(colander.String())
    date = colander.SchemaNode(colander.DateTime())
    message = colander.SchemaNode(colander.String())
    stack_trace = StackTraceSchema()
    environment_data = colander.SchemaNode(
        colander.Mapping(unknown='preserve'),
        validator=_valid_environment_data)
Ejemplo n.º 24
0
class Job(colander.MappingSchema):
    # This is not a ObjectId, is a UUID4 format string of numbers
    _id = colander.SchemaNode(colander.String())

    userid = colander.SchemaNode(ObjectIdField())
    objid = colander.SchemaNode(ObjectIdField())

    # Verify that the status selected already exists
    status = colander.SchemaNode(colander.String(),
                                 validator=colander.OneOf(JOB_STATUS.keys()))
    type = colander.SchemaNode(colander.String())
    op = colander.SchemaNode(colander.String(),
                             validator=colander.OneOf(
                                 ['created', 'changed', 'deleted']
                             ))

    created = colander.SchemaNode(colander.DateTime())
    last_update = colander.SchemaNode(colander.DateTime())
Ejemplo n.º 25
0
 def colander_literal_type(self, data_input):
     # LOGGER.debug('data input type = %s', data_input.dataType)
     if 'boolean' in data_input.dataType:
         return colander.Boolean()
     elif 'integer' in data_input.dataType:
         return colander.Integer()
     elif 'float' in data_input.dataType:
         return colander.Float()
     elif 'double' in data_input.dataType:
         return colander.Float()
     elif 'angle' in data_input.dataType:
         return colander.Float()
     elif 'decimal' in data_input.dataType:
         return colander.Decimal()
     elif 'string' in data_input.dataType:
         if data_input.maxOccurs > 1:
             # we are going to use a SelectWidget with multiple=True
             return colander.Set()
         elif data_input.identifier.endswith("FileUpload"):
             # we want to upload a file but just return a string containing
             # the path
             return deform.FileData()
         else:
             return colander.String()
     elif 'dateTime' in data_input.dataType:
         return colander.DateTime()
     elif 'date' in data_input.dataType:
         return colander.Date()
     elif 'time' in data_input.dataType:
         return colander.Time()
     elif 'duration' in data_input.dataType:
         # TODO: check correct type
         # http://www.w3.org/TR/xmlschema-2/#duration
         return colander.Time()
     # guessing from default
     elif hasattr(data_input, 'defaultValue'):
         try:
             dateutil.parser.parse(data_input.defaultValue)
         except Exception:
             return colander.String()
         else:
             return colander.DateTime()
     else:
         return colander.String()
Ejemplo n.º 26
0
    class ActivitySchema(colander.MappingSchema):
        """ Schema for CustomContent. """

        engagement_id = colander.SchemaNode(
            colander.Integer(),
            title=_(u"Engagement"),
            widget=deferred_engagement_select_widget)

        start_dt = colander.SchemaNode(
            colander.DateTime(
                default_tzinfo=FixedOffset(8, 0, 'Asia/Kuala_Lumpur')),
            title=_(u'Start'),
            widget=DateTimeInputWidget(time_options=(('format', 'h:i A'),
                                                     ('interval', 60))),
            default=deferred_default_dt)
        end_dt = colander.SchemaNode(
            colander.DateTime(
                default_tzinfo=FixedOffset(8, 0, 'Asia/Kuala_Lumpur')),
            title=_(u'End'),
            widget=DateTimeInputWidget(time_options=(('format', 'h:i A'),
                                                     ('interval', 60))),
            default=deferred_default_dt)

        summary = colander.SchemaNode(
            colander.String(),
            title=_('Activity Summary'),
            widget=RichTextWidget(),
            missing=u"",
        )

        issues = colander.SchemaNode(
            colander.String(),
            title=_('Issues Faced'),
            widget=RichTextWidget(),
            missing=u"",
        )

        tags = colander.SchemaNode(
            ObjectType(),
            title=_('Tags'),
            widget=deferred_tag_it_widget,
            missing=[],
        )
Ejemplo n.º 27
0
class BlogEntrySchema(Schema):
    title = colander.SchemaNode(colander.String())
    body = colander.SchemaNode(
        colander.String(),
        widget=deform.widget.RichTextWidget(options={
            "menubar": False,
            "plugins": "link image",
        }))
    pub_date = colander.SchemaNode(colander.DateTime())
    name = NameSchemaNode(editing=True)
Ejemplo n.º 28
0
 class meta(colander.MappingSchema):
     lat = colander.SchemaNode(colander.String())
     lon = colander.SchemaNode(colander.String())
     updated = colander.SchemaNode(colander.DateTime())
     title = colander.SchemaNode(colander.String())
     description = colander.SchemaNode(colander.String())
     count = colander.SchemaNode(colander.Integer())
     link = colander.SchemaNode(colander.String())
     total_count = colander.SchemaNode(colander.Integer())
     url = colander.SchemaNode(colander.String())
Ejemplo n.º 29
0
class DateSchema(colander.MappingSchema):
    """Payload for this queue."""

    date = colander.SchemaNode(colander.Date())

    timestamp = colander.SchemaNode(colander.DateTime(default_tzinfo=None))

    event_name = colander.SchemaNode(
        colander.String(),
        validator=colander.Regex(r'^(([a-z])+\.([a-z])+)+$'))
Ejemplo n.º 30
0
class RideForm(colander.MappingSchema):
    id = colander.SchemaNode(colander.Integer(),
                             widget=deform.widget.HiddenWidget(),
                             missing=None)
    equipment = colander.SchemaNode(colander.Integer(),
                                    default=get_default_equipment,
                                    widget=get_equipment_widget,
                                    missing=None)
    start_time = colander.SchemaNode(colander.DateTime(),
                                     widget=get_datetime_widget(),
                                     missing=None)
    end_time = colander.SchemaNode(colander.DateTime(),
                                   widget=get_datetime_widget(),
                                   missing=None)
    startloc = colander.SchemaNode(colander.String(),
                                   widget=get_location_widget,
                                   missing=None)
    endloc = colander.SchemaNode(colander.String(),
                                 widget=get_location_widget,
                                 missing=None)
    route = colander.SchemaNode(colander.String(), missing=None)
    rolling_time = colander.SchemaNode(colander.Time(),
                                       widget=get_timedelta_widget(),
                                       missing=None)
    total_time = colander.SchemaNode(colander.Time(),
                                     widget=get_timedelta_widget(),
                                     missing=None)
    distance = colander.SchemaNode(colander.Float(), missing=None)
    odometer = colander.SchemaNode(colander.Float(), missing=None)
    avspeed = colander.SchemaNode(colander.Float(), missing=None)
    maxspeed = colander.SchemaNode(colander.Float(), missing=None)
    trailer = colander.SchemaNode(colander.Boolean(), missing=None)
    surface = colander.SchemaNode(colander.Integer(),
                                  default=get_default_surface,
                                  widget=get_surface_widget,
                                  missing=None)
    ridergroup = colander.SchemaNode(colander.Integer(),
                                     default=get_default_ridergroup,
                                     widget=get_ridergroup_widget,
                                     missing=None)
    remarks = colander.SchemaNode(colander.String(),
                                  widget=deform.widget.TextAreaWidget(),
                                  missing=None)