Exemplo n.º 1
0
class ServiceHistorySchema(ma.Schema):
    id = fields.UUID()
    name = fields.String()
    created_at = fields.DateTime()
    updated_at = fields.DateTime()
    active = fields.Boolean()
    message_limit = fields.Integer()
    restricted = fields.Boolean()
    email_from = fields.String()
    created_by_id = fields.UUID()
    version = fields.Integer()
Exemplo n.º 2
0
class NotificationsFilterSchema(ma.Schema):
    class Meta:
        strict = True

    template_type = fields.Nested(BaseTemplateSchema,
                                  only=['template_type'],
                                  many=True)
    status = fields.Nested(NotificationModelSchema, only=['status'], many=True)
    page = fields.Int(required=False)
    page_size = fields.Int(required=False)
    limit_days = fields.Int(required=False)
    include_jobs = fields.Boolean(required=False)
    include_from_test_key = fields.Boolean(required=False)
    older_than = fields.UUID(required=False)
    format_for_csv = fields.String()
    to = fields.String()
    include_one_off = fields.Boolean(required=False)
    count_pages = fields.Boolean(required=False)

    @pre_load
    def handle_multidict(self, in_data):
        if isinstance(in_data, dict) and hasattr(in_data, 'getlist'):
            out_data = dict([(k, in_data.get(k)) for k in in_data.keys()])
            if 'template_type' in in_data:
                out_data['template_type'] = [{
                    'template_type': x
                } for x in in_data.getlist('template_type')]
            if 'status' in in_data:
                out_data['status'] = [{
                    "status": x
                } for x in in_data.getlist('status')]

        return out_data

    @post_load
    def convert_schema_object_to_field(self, in_data):
        if 'template_type' in in_data:
            in_data['template_type'] = [
                x.template_type for x in in_data['template_type']
            ]
        if 'status' in in_data:
            in_data['status'] = [x.status for x in in_data['status']]
        return in_data

    @validates('page')
    def validate_page(self, value):
        _validate_positive_number(value)

    @validates('page_size')
    def validate_page_size(self, value):
        _validate_positive_number(value)
Exemplo n.º 3
0
class UnarchivedTemplateSchema(BaseSchema):
    archived = fields.Boolean(required=True)

    @validates_schema
    def validate_archived(self, data):
        if data['archived']:
            raise ValidationError('Template has been deleted', 'template')
Exemplo n.º 4
0
class OCRRequest(Schema):
    """Parameter definition for OCR requests"""

    FILE_TYPE = "fileType"
    LANGUAGE = "language"
    DETECT_ORIENTATION = "detectOrientation"
    BODY = "body"

    language = fields.Str(
        attribute=FILE_TYPE,
        description="File type as a ",
        missing="en",
        required=False,
    )

    language = fields.Str(
        attribute=LANGUAGE,
        description=
        "The BCP-47 language code of the text to be detected. The default is 'en'.",
        missing="en",
        required=False,
    )
    detect_orientation = fields.Boolean(
        attribute=DETECT_ORIENTATION,
        required=False,
        missing=False,
        description="Whether detect the text orientation in the image.",
    )
    body = fields.Raw(
        attribute=BODY,
        required=True,
        description="File data to be processed",
    )
Exemplo n.º 5
0
class TaskSchema(EndDateValidationMixin, Schema):
    _id = fields.Str(dump_only=True, required=True)
    description = fields.Str(required=True,
                             allow_none=False,
                             validate=not_empty)
    end_date = fields.DateTime(required=True)
    created_at = fields.DateTime(missing=datetime.utcnow())
    done = fields.Boolean(missing=False)
    user_id = fields.String()
Exemplo n.º 6
0
class CommentListSchema(BaseMarshmallow):
    class Meta:
        fields = ("id", "content", "user", "reply_user", "sub_comment",
                  "theme_id", "more")

    user = fields.Nested(CommentUserSchema)
    reply_user = fields.Nested(CommentUserSchema,
                               attribute="reply_comment.user")
    sub_comment = fields.Nested(SonCommentSchema, many=True)
    more = fields.Boolean(attribute="more_sub_comment")
Exemplo n.º 7
0
class AccountSchema(Schema):    
    account_number = fields.Str()
    buying_power = fields.Float()
    cash = fields.Float()
    daytrade_count = fields.Float()
    daytrading_buying_power = fields.Float()
    equity = fields.Float()
    id =fields.Str()
    last_equity = fields.Float()
    portfolio_value = fields.Float()
    status = fields.Str()
    trading_blocked = fields.Boolean()
Exemplo n.º 8
0
class UpdateTaskSchema(EndDateValidationMixin, Schema):
    description = fields.Str(allow_none=False, validate=not_empty)
    end_date = fields.DateTime()
    done = fields.Boolean()
Exemplo n.º 9
0
class LoginSchema(Schema):
    email = fields.Email(required=True, validate=Length(min=3, max=50))
    password = fields.String(required=True, validate=Length(min=3, max=50))
    remember_me = fields.Boolean(required=False, default=False, missing=False)
Exemplo n.º 10
0
class LikeSchema(ma.Schema):
    is_liked = fields.Boolean()