Exemple #1
0
class BaseObject(Schema):
    class Meta:
        type_ = "object"

    id = fields.Integer()
    created_at = fields.DateTime()
    owner = fields.Nested(BaseUser)
    belongs_to_id = fields.Integer()  # don't leak
    type = fields.String(attribute="discriminator")
Exemple #2
0
class ApplicationSchema(Schema):

    id = fields.String()
    name = fields.String(required=True,
                         validator=ma.validate.Length(min=3, max=20))
    description = fields.String()
    detail = fields.String()

    publicurl = fields.URL(required=True)
    status = fields.String(requred=True, default='deactivate')

    created_date = fields.DateTime(dump_only=True)
    updated_date = fields.DateTime(dump_only=True)

    class Meta:
        type_ = 'applications'
        strict = True
        inflect = common.dasherize
Exemple #3
0
class LocationSchema(Schema):
    class Meta:
        type_ = 'location'
        strict = True
    id = fields.Integer(dump_only=True)
    location_name = fields.String(required=True)
    longitude = fields.String(required=True)
    latitude = fields.String(required=True)
    creation_date = fields.DateTime()
Exemple #4
0
class ScheduledSchema(Schema):
    class Meta:
        type_ = 'scheduled'
        strict = True
    id = fields.Integer(dump_only=True)
    unix_date = fields.String(required=True)
    days = fields.String(required=True)
    times = fields.String(required=True)
    creation_date = fields.DateTime()
Exemple #5
0
class AttendeeSchemaPublic(Schema):
    """
    Api schema for Ticket Holder Model
    """

    class Meta:
        """
        Meta class for Attendee API Schema
        """
        type_ = 'attendee'
        self_view = 'v1.attendee_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    id = fields.Str(dump_only=True)
    firstname = fields.Str(required=True)
    lastname = fields.Str(allow_none=True)
    email = fields.Str(allow_none=True)
    address = fields.Str(allow_none=True)
    city = fields.Str(allow_none=True)
    state = fields.Str(allow_none=True)
    country = fields.Str(allow_none=True)
    job_title = fields.Str(allow_none=True)
    phone = fields.Str(allow_none=True)
    tax_business_info = fields.Str(allow_none=True)
    billing_address = fields.Str(allow_none=True)
    home_address = fields.Str(allow_none=True)
    shipping_address = fields.Str(allow_none=True)
    company = fields.Str(allow_none=True)
    work_address = fields.Str(allow_none=True)
    work_phone = fields.Str(allow_none=True)
    website = fields.Url(allow_none=True)
    blog = fields.Url(allow_none=True)
    twitter = fields.Url(allow_none=True)
    facebook = fields.Url(allow_none=True)
    github = fields.Url(allow_none=True)
    gender = fields.Str(allow_none=True)
    birth_date = fields.DateTime(allow_none=True)

    ticket_id = fields.Str(allow_none=True)
    is_checked_in = fields.Boolean()
    checkin_times = fields.Str(allow_none=True)
    pdf_url = fields.Url(required=True)
    event = Relationship(attribute='event',
                         self_view='v1.attendee_event',
                         self_view_kwargs={'id': '<id>'},
                         related_view='v1.event_detail',
                         related_view_kwargs={'attendee_id': '<id>'},
                         schema='EventSchema',
                         type_='event')
    user = Relationship(attribute='user',
                        self_view='v1.attendee_user',
                        self_view_kwargs={'id': '<id>'},
                        related_view='v1.user_detail',
                        related_view_kwargs={'attendee_id': '<id>'},
                        schema='UserSchemaPublic',
                        type_='user')
Exemple #6
0
class SpeakersCallSchema(Schema):
    """
    Api Schema for Speakers Call model
    """
    class Meta:
        """
        Meta class for Speakers Call Api Schema
        """
        type_ = 'speakers-call'
        self_view = 'v1.speakers_call_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    @validates_schema(pass_original=True)
    def validate_date(self, data, original_data):
        if 'id' in original_data['data']:
            speakers_calls = SpeakersCall.query.filter_by(
                id=original_data['data']['id']).one()

            if 'starts_at' not in data:
                data['starts_at'] = speakers_calls.starts_at

            if 'ends_at' not in data:
                data['ends_at'] = speakers_calls.ends_at

        if data['starts_at'] >= data['ends_at']:
            raise UnprocessableEntity({'pointer': '/data/attributes/ends-at'},
                                      "ends-at should be after starts-at")

    id = fields.Str(dump_only=True)
    announcement = fields.Str(required=True)
    starts_at = fields.DateTime(required=True)
    ends_at = fields.DateTime(required=True)
    hash = fields.Str(allow_none=True)
    privacy = fields.String(
        validate=validate.OneOf(choices=["private", "public"]),
        allow_none=True)
    event = Relationship(attribute='event',
                         self_view='v1.speakers_call_event',
                         self_view_kwargs={'id': '<id>'},
                         related_view='v1.event_detail',
                         related_view_kwargs={'speakers_call_id': '<id>'},
                         schema='EventSchemaPublic',
                         type_='event')
class DiscountCodeSchemaPublic(SoftDeletionSchema):
    """
    API Schema for discount_code Model
    For endpoints which allow somebody other than co-organizer/admin to access the resource.
    """
    class Meta:
        type_ = 'discount-code'
        self_view = 'v1.discount_code_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    id = fields.Integer()
    code = fields.Str(required=True)
    discount_url = fields.Url(allow_none=True)
    value = fields.Float(required=True)
    type = fields.Str(validate=validate.OneOf(choices=["amount", "percent"]),
                      required=True)
    is_active = fields.Boolean()
    tickets_number = fields.Integer(validate=lambda n: n >= 0, allow_none=True)
    min_quantity = fields.Integer(validate=lambda n: n >= 0, allow_none=True)
    max_quantity = fields.Integer(validate=lambda n: n >= 0, allow_none=True)
    valid_from = fields.DateTime(allow_none=True)
    valid_till = fields.DateTime(allow_none=True)
    used_for = fields.Str(validate=validate.OneOf(choices=["event", "ticket"]),
                          allow_none=False)
    created_at = fields.DateTime(allow_none=True)

    event = Relationship(attribute='event',
                         self_view='v1.discount_code_event',
                         self_view_kwargs={'id': '<id>'},
                         related_view='v1.event_detail',
                         related_view_kwargs={'discount_code_id': '<id>'},
                         schema='EventSchemaPublic',
                         type_='event')

    @classmethod
    def quantity_validation_helper(obj, data):
        min_quantity = data.get('min_quantity', None)
        max_quantity = data.get('max_quantity', None)
        if min_quantity is not None and max_quantity is not None:
            if min_quantity > max_quantity:
                raise UnprocessableEntity(
                    {'pointer': '/data/attributes/min-quantity'},
                    "min-quantity cannot be more than max-quantity")
class BadDataSchema(Schema):
    id = fields.Str(required=True)
    number = fields.DateTime(required=True)

    class Meta:
        type_ = 'bad'
        self_view_many = 'bad_list'
        self_view = 'bad_detail'
        self_view_kwargs = {'bad_id': '<id>'}
        strict = True
Exemple #9
0
    class StringJsonAttributePersonSchema(Schema):
        class Meta:
            type_ = 'string_json_attribute_person'
            self_view = 'api.string_json_attribute_person_detail'
            self_view_kwargs = {'person_id': '<id>'}

        id = fields.Integer(as_string=True, attribute='person_id')
        name = fields.Str(required=True)
        birth_date = fields.DateTime()
        address = fields.Nested(address_schema, many=False)
class OutletTypeSchema(Schema):
    id = fields.Integer(dump_only=True)
    name = fields.String(allow_none=True)
    voltage = fields.Int()
    amperage = fields.Int()
    last_modified_dt = fields.DateTime()

    class Meta:
        type_ = 'outlet-type',
        strict = 'true'
Exemple #11
0
class BaseUser(Schema):
    class Meta:
        type_ = "user"

    id = fields.Function(lambda obj: obj.__LOOKUP_ATTRS__ and getattr(
        obj, obj.__LOOKUP_ATTRS__[0]) or obj.id)
    beavyId = fields.Integer(attribute="id")
    name = fields.String()
    active = fields.Boolean()
    created_at = fields.DateTime()
class PreviewSchema(BaseSchema):
    id = fields.String()
    filepath = fields.Str()
    created_on = fields.DateTime()

    class Meta:
        type_ = 'previews'
        self_url = '/api/previews/{id}'
        self_url_kwargs = {'id': '<id>'}
        self_url_many = '/api/previews'
Exemple #13
0
class PlacementPeriod(Schema):
    id = fields.String(dump_only=True, attribute='placement_id')
    start = fields.String()
    end = fields.DateTime()
    cmp = fields.Int()
    delivery = fields.List(fields.Nested(Delivery))
    budget = fields.Int()

    class Meta:
        type_ = 'placement_period'
Exemple #14
0
class EntriesSchema(BaseSchema):

    id = fields.UUID(dump_only=True)
    publisher_id = fields.Integer()
    channel_id = fields.Integer()
    title = fields.Str()
    channel_title = fields.Str()
    link = fields.Url()
    description = fields.Str()
    content = fields.Str()
    content_type = fields.Str()
    media_image_url = fields.Url()
    public_entry_id = fields.Str()
    published_updated_datetime = fields.DateTime()
    published_datetime = fields.DateTime()

    class Meta:
        type_ = 'entries'
        strict = True
class SongSchema(Schema):
    id = fields.Str(dump_only=True)  # Required
    name = fields.String(required=True)
    artist_name = fields.String(required=True)
    description = fields.String(required=True)
    created_at = fields.DateTime()
    deleted = fields.Boolean()

    class Meta:
        type_ = 'song'
class ProfileSchema(Schema):

    id = fields.Integer(dump_only=True)
    bio = fields.String()
    website = fields.String()
    company = fields.String()
    location = fields.String()
    date_created = fields.DateTime(dump_only=True)
    last_modified = fields.DateTime(dump_only=True)

    user = fields.Relationship(related_url='/users/{user_id}',
                               related_url_kwargs={'user_id': '<user_id>'},
                               many=False,
                               include_resource_linkage=True,
                               type_='user',
                               schema='UserSchema')

    class Meta:
        type_ = 'profile'
Exemple #17
0
class UserSchema(Schema):
    class Meta:
        type_ = 'users'
        self_view = 'user_detail'
        self_view_kwargs = {'id': '<id>'}
        self_view_many = 'user_list'

    id = fields.Integer(dump_only=True)
    created_at = fields.DateTime(dump_only=True)
    updated_at = fields.DateTime(dump_only=True)
    name = fields.String(required=True)
    email = fields.Email(required=True)
    password = fields.String(required=True, load_only=True)
    _role = fields.Integer(dump_only=True)
    status = fields.Integer(dump_only=True)
    friends = Relationship(self_view='user_friends',
                           self_view_kwargs={'id': '<id>'},
                           related_view='user_list',
                           related_view_kwargs={'user_id': '<id>'},
                           many=True,
                           schema='UserSchema',
                           type_='users')
    subscriptions = Relationship(self_view='user_subscriptions',
                                 self_view_kwargs={'id': '<id>'},
                                 related_view='subscription_list',
                                 related_view_kwargs={'user_id': '<id>'},
                                 many=True,
                                 schema='SubscriptionSchema',
                                 type_='subscriptions')
    posts = Relationship(self_view='user_posts',
                         self_view_kwargs={'id': '<id>'},
                         related_view='post_list',
                         related_view_kwargs={'user_id': '<id>'},
                         many=True,
                         schema='PostSchema',
                         type_='posts')
    comments = Relationship(self_view='user_comments',
                            self_view_kwargs={'id': '<id>'},
                            related_view='comment_list',
                            related_view_kwargs={'id': '<id>'},
                            many=True,
                            schema='CommentSchema',
                            type_='comments')
Exemple #18
0
class DEPDeviceSchema(Schema):
    """The Device dictionary returned by the DEP Devices fetch endpoint.

    See Also:
          https://mdmenrollment.apple.com/server/devices
    """
    serial_number = fields.String()
    model = fields.String()
    description = fields.String()
    color = fields.String()
    asset_tag = fields.String()
    profile_status = fields.String()
    profile_uuid = fields.UUID()
    profile_assign_time = fields.DateTime()
    profile_push_time = fields.DateTime()
    device_assigned_date = fields.DateTime()
    device_assigned_by = fields.Email()
    os = fields.String()
    device_family = fields.String()
Exemple #19
0
class UserSchema(Schema):

    # Validation for the different fields
    id = fields.Integer(dump_only=True)
    email = fields.String(validate=NOT_BLANK)
    password = fields.String(load_only=True, validate=PASSWORD_LENGTH)
    first_name = fields.String(validate=NOT_BLANK)
    last_name = fields.String(validate=NOT_BLANK)
    active = fields.Boolean(dump_only=True)
    confirmed_at = fields.DateTime(dump_only=True)
    last_login_at = fields.DateTime(dump_only=True)
    current_login_at = fields.DateTime(dump_only=True)
    last_login_ip = fields.String(dump_only=True)
    current_login_ip = fields.String(dump_only=True)
    login_count = fields.Integer(dump_only=True)

    roles = fields.Relationship(
        many=True,
        include_resource_linkage=True,
        type_='role',
        schema='RoleSchema',
        # related_url='/roles/{role_id}',
        # related_url_kwargs={'role_id': '<role.id>'}
    )

    # dogs = fields.Relationship(many=True,
    #                            include_resource_linkage=True,
    #                            type_='dog',
    #                            schema='DogSchema',
    #                            # related_url='/dogs/{dog_id}',
    #                            # related_url_kwargs={'dog_id': '<dog.id>'}
    #                            )

    # Self links
    def get_top_level_links(self, data, many):
        if many:
            self_link = "/users/"
        else:
            self_link = "/users/{}".format(data['id'])
        return {'self': self_link}

    class Meta:
        type_ = 'user'
class PreviewSchema(Schema):
    id = fields.String()
    filepath = fields.Str()
    created_on = fields.DateTime()

    class Meta:
        type_ = 'previews'
        self_view = 'api.previews_detail'
        self_view_kwargs = {'id': '<id>'}
        self_view_many = 'api.previews_list'
class MessageSettingSchema(Schema):
    """
    API Schema for Message Setting Model
    """
    class Meta:
        """
        Meta class for Message Setting API schema
        """

        type_ = 'message-setting'
        self_view = 'v1.message_setting_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    id = fields.Str(dump_only=True)
    action = fields.Str(
        allow_none=True,
        dump_only=True,
        validate=validate.OneOf(choices=[
            INVITE_PAPERS,
            NEW_SESSION,
            USER_CONFIRM,
            USER_REGISTER,
            PASSWORD_RESET,
            EVENT_ROLE,
            SESSION_STATE_CHANGE,
            SESSION_SCHEDULE,
            NEXT_EVENT,
            EVENT_PUBLISH,
            AFTER_EVENT,
            USER_CHANGE_EMAIL,
            USER_REGISTER_WITH_PASSWORD,
            TICKET_PURCHASED,
            EVENT_EXPORTED,
            EVENT_EXPORT_FAIL,
            MAIL_TO_EXPIRED_ORDERS,
            MONTHLY_PAYMENT_EMAIL,
            MONTHLY_PAYMENT_FOLLOWUP_EMAIL,
            EVENT_IMPORTED,
            EVENT_IMPORT_FAIL,
            TICKET_PURCHASED_ORGANIZER,
            TICKET_CANCELLED,
            TICKET_PURCHASED_ATTENDEE,
            PASSWORD_CHANGE,
        ]),
    )
    mail_status = fields.Boolean(default=False)
    notification_status = fields.Boolean(default=False)
    user_control_status = fields.Boolean(default=False)
    email_message = fields.Str(dump_only=True)
    recipient = fields.Str(dump_only=True)
    email_subject = fields.Str(dump_only=True)
    notification_title = fields.Str(dump_only=True)
    notification_message = fields.Str(dump_only=True)
    sent_at = fields.DateTime(dump_only=True)
Exemple #22
0
class ReportSchema(Schema):
    """
    This is an abstraction of Report + ReportMeta
    """
    class Meta:
        sqla_session = db.session
        model = models.Report
        type_ = 'reports'
        self_view = 'rest_api.report'
        self_view_many = 'rest_api.reportlist'
        self_view_kwargs = {'id': '<id>'}
        strict = True

    id = f.Integer(attribute='report_id', allow_none=True, as_string=True)
    hash = f.String(attribute='report_hash')
    created_at = f.DateTime()
    uploaded_at = f.DateTime()

    meta = Relationship(
        related_view='rest_api.report_reportmetalist',
        related_view_kwargs={'id': '<report_id>'},
        many=True,
        type_='report_meta',
        # include_resource_linkage=True,
        schema='ReportMetaSchema')

    samples = Relationship(
        related_view='rest_api.report_samplelist',
        related_view_kwargs={'id': '<report_id>'},
        id_field='sample_id',
        many=True,
        type_='samples',
        # include_resource_linkage=True,
        schema='SampleSchema')

    user = Relationship(related_view='rest_api.user',
                        related_view_kwargs={'id': '<user_id>'},
                        many=False,
                        type_='users',
                        id_field='user_id',
                        include_resource_linkage=True,
                        schema='UserSchema')
Exemple #23
0
    class StringJsonAttributePersonSchema(Schema):
        class Meta:
            type_ = "string_json_attribute_person"
            self_view = "api.string_json_attribute_person_detail"
            self_view_kwargs = {"person_id": "<id>"}

        id = fields.Integer(as_string=True, attribute="person_id")
        name = fields.Str(required=True)
        birth_date = fields.DateTime()
        address = fields.Nested(address_schema, many=False)
        tags = fields.List(fields.Dict())
Exemple #24
0
class DocumentSchema(Schema):

    id = fields.Integer(dump_only=True)
    created = fields.DateTime(dump_only=True)
    doc = fields.Dict()

    class Meta:
        type_ = 'documents'
        #self_url = '/documents/{id}'
        #self_url_kwargs = {'id': '<id>'}
        strict = True
Exemple #25
0
class S3ObjectSchema(CamelCaseSchema):
    class Meta:
        type_ = "file"

    id = fields.Str(attribute="key")
    e_tag = fields.Str()
    content_type = fields.Str()
    last_modified = fields.DateTime()

    def get_type(self):
        return self.content_type
    class ItemSchema(Schema):
        class Meta:
            type_ = 'item'
            self_view = 'rest_api.item_detail'
            self_view_kwargs = {'item_id': '<id>'}
            self_view_many = 'rest_api.item_list'

        id = fields.Str(dump_only=True)
        title = fields.Str()
        content = fields.Str()
        created = fields.DateTime()
Exemple #27
0
class DashboardSchema(Schema):
    class Meta:
        sqla_session = db.session
        model = models.Dashboard
        type_ = 'dashboards'

    id = f.Integer(attribute='dashboard_id', allow_none=True, as_string=True)
    title = f.String()
    data = JsonString()
    is_public = f.Bool()
    modified_at = f.DateTime()
    created_at = f.DateTime()

    user = Relationship(related_view='rest_api.user',
                        related_view_kwargs={'id': '<user_id>'},
                        many=False,
                        type_='users',
                        id_field='user_id',
                        include_resource_linkage=True,
                        schema='UserSchema')
Exemple #28
0
class SettingsSchema(Schema):
    class Meta:
        type_ = 'settings'

    id = fields.DateTime()
    appEnvironment = fields.Integer(as_string=True)
    appName = fields.Str()
    secretKey = fields.Str()
    firebaseStorageBucket = fields.Str()
    firebaseDatabaseURL = fields.Str()
    fromMail = fields.Str()
    sendGridApiKey = fields.Str()
class USBInstallSchema(Schema):
  class Meta:
    type_ = 'usbinstall'
    self_view = 'usbinstall_detail'
    self_view_kwargs = { 'id' : '<id>' }
    self_view_many = 'usbinstall_list'
  id = fields.Integer(as_string=True, dump_only=True)
  product_name = fields.Str()
  fiery_iso = fields.Str()
  usersw_iso = fields.Str()
  osiso_one = fields.Str()
  osiso_two = fields.Str()
  adobe_iso = fields.Str()
  fcps_iso = fields.Str()
  other_isos =  fields.Str()
  reserved_one =  fields.Str()
  reserved_two =  fields.Str()
  reserved_three =  fields.Str()
  reserved_four =  fields.Str()
  created_time = fields.DateTime()
  updated_time = fields.DateTime()
Exemple #30
0
class Person(Schema):
    id = fields.Integer()
    name = fields.String()
    kids_name = fields.String(attribute='name')
    age = fields.Integer()
    birth_date = fields.Date()
    updated_at = fields.DateTime()
    student = fields.Relationship(schema='Student')

    class Meta:
        inflect = dasherize
        type_ = 'people'