class CustomPlaceholderSchema(Schema):
    class Meta:
        type_ = 'custom-placeholder'
        self_view = 'v1.custom_placeholder_detail'
        self_view_kwargs = {'id': '<id>'}
        self_view_many = 'v1.custom_placeholder_list'
        inflect = dasherize

    id = fields.Integer(dump_only=True)
    name = fields.String(required=True)
    original_image_url = fields.Url(required=True)
    thumbnail_image_url = fields.Url(dump_only=True)
    large_image_url = fields.Url(dump_only=True)
    icon_image_url = fields.Url(dump_only=True)
    copyright = fields.String(allow_none=True)
    origin = fields.String(allow_none=True)
    event_sub_topic = Relationship(
        attribute='event_sub_topic',
        self_view='v1.custom_placeholder_event_sub_topic',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.event_sub_topic_detail',
        related_view_kwargs={'custom_placeholder_id': '<id>'},
        schema='EventSubTopicSchema',
        type_='event-sub-topic',
    )
Ejemplo n.º 2
0
class UserSchemaPublic(SoftDeletionSchema):
    """
    Api schema for User Model which can be accessed by any resource to which user is related.
    Co-organizers of events to which the user will be related will have access to this info.
    """
    class Meta:
        """
        Meta class for User Api Schema
        """

        type_ = 'user'
        self_view = 'v1.user_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    id = fields.Str(dump_only=True)
    email = fields.Email(required=True)
    avatar_url = fields.Url(allow_none=True)
    first_name = fields.Str(allow_none=True)
    last_name = fields.Str(allow_none=True)
    original_image_url = fields.Url(dump_only=True, allow_none=True)
    thumbnail_image_url = fields.Url(dump_only=True, allow_none=True)
    small_image_url = fields.Url(dump_only=True, allow_none=True)
    icon_image_url = fields.Url(dump_only=True, allow_none=True)
    was_registered_with_order = fields.Boolean()
class SponsorSchema(SoftDeletionSchema):
    """
    Sponsors API schema based on Sponsors model
    """
    class Meta:
        """
        Meta class for Sponsor schema
        """

        type_ = 'sponsor'
        self_view = 'v1.sponsor_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    id = fields.Str(dump_only=True)
    name = fields.Str(required=True)
    description = fields.Str(allow_none=True)
    url = fields.Url(allow_none=True)
    level = fields.Integer(allow_none=True)
    logo_url = fields.Url(allow_none=True)
    type = fields.Str(allow_none=True)
    event = Relationship(
        attribute='event',
        self_view='v1.sponsor_event',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.event_detail',
        related_view_kwargs={'sponsor_id': '<id>'},
        schema='EventSchemaPublic',
        type_='event',
    )
Ejemplo n.º 4
0
class SpeakerSchema(SoftDeletionSchema):
    """
    Speaker Schema based on Speaker Model
    """
    class Meta:
        """
        Meta class for speaker schema
        """
        type_ = 'speaker'
        self_view = 'v1.speaker_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    id = fields.Str(dump_only=True)
    name = fields.Str(required=True)
    email = fields.Str(required=True)
    photo_url = fields.Url(allow_none=True)
    thumbnail_image_url = fields.Url(allow_none=True)
    small_image_url = fields.Url(allow_none=True)
    icon_image_url = fields.Url(allow_none=True)
    short_biography = fields.Str(allow_none=True)
    long_biography = fields.Str(allow_none=True)
    speaking_experience = fields.Str(allow_none=True)
    mobile = fields.Str(allow_none=True)
    website = fields.Url(allow_none=True)
    twitter = fields.Url(allow_none=True)
    facebook = fields.Url(allow_none=True)
    github = fields.Url(allow_none=True)
    linkedin = fields.Url(allow_none=True)
    organisation = fields.Str(allow_none=True)
    is_featured = fields.Boolean(default=False)
    position = fields.Str(allow_none=True)
    country = fields.Str(allow_none=True)
    city = fields.Str(allow_none=True)
    gender = fields.Str(allow_none=True)
    heard_from = fields.Str(allow_none=True)
    sponsorship_required = fields.Str(allow_none=True)
    event = Relationship(attribute='event',
                         self_view='v1.speaker_event',
                         self_view_kwargs={'id': '<id>'},
                         related_view='v1.event_detail',
                         related_view_kwargs={'speaker_id': '<id>'},
                         schema='EventSchemaPublic',
                         type_='event')
    user = Relationship(attribute='user',
                        self_view='v1.speaker_user',
                        self_view_kwargs={'id': '<id>'},
                        related_view='v1.user_detail',
                        related_view_kwargs={'speaker_id': '<id>'},
                        schema='UserSchemaPublic',
                        type_='user')
    sessions = Relationship(attribute='sessions',
                            self_view='v1.speaker_session',
                            self_view_kwargs={'id': '<id>'},
                            related_view='v1.session_list',
                            related_view_kwargs={'speaker_id': '<id>'},
                            schema='SessionSchema',
                            many=True,
                            type_='session')
Ejemplo n.º 5
0
class VideoChannelSchemaPublic(Schema):
    class Meta:
        type_ = 'video-channel'
        self_view = 'v1.video_channel_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    id = fields.Str(dump_only=True)
    name = fields.Str(required=True)
    provider = fields.Str(required=True)
    url = fields.Url(required=True)
    api_url = fields.Url(required=False, allow_none=True)
    created_at = fields.DateTime(dump_only=True)
    modified_at = fields.DateTime(dump_only=True)
Ejemplo n.º 6
0
class SCEPConfigFlatSchema(FlatSchema):
    url = fields.Url(relative=False, schemes=['http', 'https'], required=True)
    challenge_enabled = fields.Boolean()
    ca_fingerprint = fields.String()
    subject = fields.String()
    key_size = fields.Integer()
    key_type = fields.String(dump_only=True)
    key_usage = fields.Integer()
    subject_alt_name = fields.String()
    retries = fields.Integer()
    retry_delay = fields.Integer()
    certificate_renewal_time_interval = fields.Integer()

    @post_load
    def make_scepconfig(self, data: dict) -> SCEPConfig:
        """Construct a model from a parsed JSON schema."""
        rows = db.session.query(SCEPConfig).count()

        if rows == 1:
            db.session.query(SCEPConfig).update(data)
            o = db.session.query(SCEPConfig).first()
        else:
            o = SCEPConfig(**data)
            db.session.add(o)

        return o
Ejemplo n.º 7
0
class SocialLinkSchema(SoftDeletionSchema):
    """
    Social Link API Schema based on Social link model
    """

    class Meta:
        """
        Meta class for social link schema
        """

        type_ = 'social-link'
        self_view = 'v1.social_link_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    id = fields.Str(dump_only=True)
    name = fields.Str(required=True)
    link = fields.Url(required=True)
    identifier = fields.Str(allow_none=True)
    event = Relationship(
        self_view='v1.social_link_event',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.event_detail',
        related_view_kwargs={'social_link_id': '<id>'},
        schema='EventSchemaPublic',
        type_='event',
    )
Ejemplo n.º 8
0
class NewsSchema(Schema):

    id = fields.UUID(dump_only=True, attribute='uuid')

    status = fields.Integer()
    news_id = fields.String()
    timestamp_publish = fields.DateTime("%Y-%m-%dT%H:%M:%S+00:00")
    title = fields.String()
    news_type = fields.String()
    site = fields.String()
    lang = fields.String()
    excerpt = fields.String()
    news_category = fields.String()
    url = fields.Url()
    image_url = fields.String()
    body = fields.String()
    body_markdown = fields.String()

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

    class Meta:
        type_ = 'news'
Ejemplo n.º 9
0
class EventInvoiceSchema(SoftDeletionSchema):
    """
    Event Invoice API Schema based on event invoice model
    """
    class Meta:
        type_ = 'event-invoice'
        self_view = 'v1.event_invoice_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    id = fields.Str(dump_only=True)
    identifier = fields.Str(allow_none=True)
    amount = fields.Float(validate=lambda n: n >= 0, allow_none=True)
    address = fields.Str(allow_none=True)
    city = fields.Str(allow_none=True)
    state = fields.Str(allow_none=True)
    country = fields.Str(validate=validate.OneOf(choices=PAYMENT_COUNTRIES), allow_none=True)
    zipcode = fields.Str(allow_none=True)
    created_at = fields.DateTime(allow_none=True)
    completed_at = fields.DateTime(default=None)
    transaction_id = fields.Str(allow_none=True)
    paid_via = fields.Str(validate=validate.OneOf(
        choices=["free", "stripe", "paypal", "transfer", "onsite", "cheque"]), allow_none=True)
    payment_mode = fields.Str(allow_none=True)
    brand = fields.Str(allow_none=True)
    exp_month = fields.Integer(validate=lambda n: 0 <= n <= 12, allow_none=True)
    exp_year = fields.Integer(validate=lambda n: n >= 2015, allow_none=True)
    last4 = fields.Str(allow_none=True)
    stripe_token = fields.Str(allow_none=True)
    paypal_token = fields.Str(allow_none=True)
    status = fields.Str(validate=validate.OneOf(choices=["paid", "due"]), allow_none=True)
    invoice_pdf_url = fields.Url(allow_none=True)
    user = Relationship(attribute='user',
                        self_view='v1.event_invoice_user',
                        self_view_kwargs={'id': '<id>'},
                        related_view='v1.user_detail',
                        related_view_kwargs={'event_invoice_id': '<id>'},
                        schema='UserSchemaPublic',
                        type_='user')
    order = Relationship(attribute='order',
                         self_view='v1.event_invoice_order',
                         self_view_kwargs={'id': '<id>'},
                         related_view='v1.order_detail',
                         related_view_kwargs={'id': '<id>'},
                         schema='OrderSchema',
                         type_='order')
    event = Relationship(attribute='event',
                         self_view='v1.event_invoice_event',
                         self_view_kwargs={'id': '<id>'},
                         related_view='v1.event_detail',
                         related_view_kwargs={'event_invoice_id': '<id>'},
                         schema='EventSchemaPublic',
                         type_='event')
    discount_code = Relationship(attribute='discount_code',
                                 self_view='v1.event_invoice_discount_code',
                                 self_view_kwargs={'id': '<id>'},
                                 related_view='v1.discount_code_detail',
                                 related_view_kwargs={'event_invoice_id': '<id>'},
                                 schema='DiscountCodeSchemaPublic',
                                 type_='discount-code')
Ejemplo n.º 10
0
class EventTopicSchema(SoftDeletionSchema):
    """
    Api Schema for event topic model
    """
    class Meta:
        """
        Meta class for event topic Api Schema
        """
        type_ = 'event-topic'
        self_view = 'v1.event_topic_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    id = fields.Str(dump_only=True)
    name = fields.Str(required=True)
    system_image_url = fields.Url()
    slug = fields.Str(dump_only=True)
    events = Relationship(attribute='event',
                          many=True,
                          self_view='v1.event_topic_event',
                          self_view_kwargs={'id': '<id>'},
                          related_view='v1.event_list',
                          related_view_kwargs={'event_topic_id': '<id>'},
                          schema='EventSchemaPublic',
                          type_='event')
    event_sub_topics = Relationship(
        attribute='event_sub_topics',
        self_view='v1.event_topic_event_sub_topic',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.event_sub_topic_list',
        related_view_kwargs={'event_topic_id': '<id>'},
        many=True,
        schema='EventSubTopicSchema',
        type_='event-sub-topic')
Ejemplo n.º 11
0
class SettingSchemaPublic(Schema):
    """
    Public Api schema for settings Model
    """
    class Meta:
        """
        Meta class for setting Api Schema
        """
        type_ = 'setting'
        self_view = 'v1.setting_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    id = fields.Str(dump_only=True)

    # Name of the application. (Eg. Event Yay!, Events City)
    app_name = fields.Str(allow_none=True)

    # Tagline for the application. (Eg. Event Management and Ticketing, Home)
    tagline = fields.Str(allow_none=True)

    # Order Expiry Time
    order_expiry_time = fields.Integer(allow_none=False, default=15, validate=lambda n: 1 <= n <= 60)

    # Maximum number of complex custom fields allowed for a given form
    max_complex_custom_fields = fields.Integer(allow_none=False, default=30, validate=lambda n: 1 <= n <= 30)

    # Google Analytics
    analytics_key = fields.Str(allow_none=True)

    # FB
    fb_client_id = fields.Str(allow_none=True)

    #
    # Social links
    #
    google_url = fields.Str(allow_none=True)
    github_url = fields.Str(allow_none=True)
    twitter_url = fields.Str(allow_none=True)
    support_url = fields.Str(allow_none=True)
    facebook_url = fields.Str(allow_none=True)
    youtube_url = fields.Str(allow_none=True)

    # Url of Frontend
    frontend_url = fields.Url(allow_none=True)

    #
    # Cookie Policy
    #
    cookie_policy = fields.Str(allow_none=True)
    cookie_policy_link = fields.Str(allow_none=True)

    #
    # Online Payment Flags
    #
    is_paytm_activated = fields.Bool(default=False)
    is_paypal_activated = fields.Bool(dump_only=True)
    is_stripe_activated = fields.Bool(dump_only=True)
    is_omise_activated = fields.Bool(dump_only=True)
    is_alipay_activated = fields.Bool(dump_only=True)
Ejemplo n.º 12
0
class DiscountCodeSchemaPublic(Schema):
    """
    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)
    tickets = fields.Str(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')
Ejemplo n.º 13
0
class PostSchema(Schema):
    class Meta:
        type_ = 'posts'
        self_view = 'post_detail'
        self_view_kwargs = {'id': '<id>'}
        self_view_many = 'post_list'

    id = fields.Integer(dump_only=True)
    created_at = fields.DateTime(dump_only=True)
    updated_at = fields.DateTime(dump_only=True)
    link = fields.Url()
    text = fields.String(required=True)
    rating = fields.Integer(dump_only=True)
    user = Relationship(attribute='user',
                        self_view='post_user',
                        self_view_kwargs={'id': '<id>'},
                        related_view='post_detail',
                        related_view_kwargs={'id': '<id>'},
                        schema='UserSchema',
                        type_='users')
    channel = Relationship(attribute='channel',
                           self_view='post_channel',
                           self_view_kwargs={'id': '<id>'},
                           related_view='post_detail',
                           related_view_kwargs={'id': '<id>'},
                           schema='ChannelSchema',
                           type_='channels')
    comments = Relationship(self_view='post_comments',
                            self_view_kwargs={'id': '<id>'},
                            related_view='comment_list',
                            related_view_kwargs={'id': '<id>'},
                            many=True,
                            schema='CommentSchema',
                            type_='comments')
Ejemplo n.º 14
0
class ApplicationManifestSchema(Schema):
    class Meta:
        type_ = 'application_manifests'
        self_view = 'applications_api.application_manifest_detail'
        self_view_kwargs = {'application_manifest_id': '<id>'}
        self_view_many = 'applications_api.application_manifest_list'
        strict = True

    checksums = Relationship(
        related_view='applications_api.application_manifest_checksum_detail',
        related_view_kwargs={'application_checksum_id': '<id>'},
        many=True,
        schema='ApplicationManifestChecksumSchema',
        type_='application_manifest_checksums')

    full_size_image_url = fields.Url()
    display_image_url = fields.Url()
Ejemplo n.º 15
0
class VideoStreamSchema(Schema):
    class Meta:
        type_ = 'video-stream'
        self_view = 'v1.video_stream_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    id = fields.Str(dump_only=True)
    name = fields.Str(required=True)
    url = fields.Url(required=True)
    password = fields.Str(required=False, allow_none=True)
    bg_img_url = fields.Str(required=False, allow_none=True)
    additional_information = fields.Str(required=False, allow_none=True)
    extra = fields.Nested(VideoStreamExtraSchema, allow_none=True)
    rooms = Relationship(
        many=True,
        self_view='v1.video_stream_rooms',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.microlocation_list',
        related_view_kwargs={'video_stream_id': '<id>'},
        schema='MicrolocationSchema',
        type_='microlocation',
    )
    event = Relationship(
        self_view='v1.video_stream_event',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.event_detail',
        related_view_kwargs={'video_stream_id': '<id>'},
        schema='EventSchemaPublic',
        type_='event',
    )
    video_channel = Relationship(
        attribute='channel',
        self_view='v1.video_stream_channel',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.video_channel_detail',
        related_view_kwargs={'video_stream_id': '<id>'},
        schema='VideoChannelSchemaPublic',
        type_='video-channel',
    )
    video_recordings = Relationship(
        many=True,
        self_view='v1.video_stream_recordings',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.video_recording_list',
        related_view_kwargs={'video_stream_id': '<id>'},
        schema='VideoRecordingSchema',
        type_='video-recording',
    )
    moderators = Relationship(
        many=True,
        self_view='v1.video_stream_moderators',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.video_stream_moderator_list',
        related_view_kwargs={'video_stream_id': '<id>'},
        schema='VideoStreamModeratorSchema',
        type_='video-stream-moderator',
    )
Ejemplo n.º 16
0
class SnippetsSchema(BaseSchema):

    id = fields.UUID(dump_only=True)
    desktop_redirect = fields.Url(required=True)
    desktop_redirect_count = fields.Integer(dump_only=True)
    mobile_redirect = fields.Url()
    mobile_redirect_count = fields.Integer(dump_only=True)
    tablet_redirect = fields.Url()
    tablet_redirect_count = fields.Integer(dump_only=True)
    short_url = fields.Url()
    time_since_creation = fields.Function(
        lambda obj: get_time_since_creation(obj),
        dump_only=True,
    )

    class Meta:
        type_ = 'snippets'
        strict = True
Ejemplo n.º 17
0
class ApplicationSchema(Schema):
    class Meta:
        type_ = 'applications'
        self_view = 'applications_api.application_detail'
        self_view_kwargs = {'application_id': '<id>'}
        self_view_many = 'applications_api.application_list'
        strict = True

    id = fields.Int(dump_only=True)
    manifest_url = fields.Url()
Ejemplo n.º 18
0
class NewsSchema(Schema):
    id = fields.UUID(attribute="uuid")
    title = fields.Str()
    body_markdown = fields.Str()
    excerpt = fields.Str()
    timestamp_publish = fields.DateTime("%Y-%m-%dT%H:%M:%S+00:00")
    url = fields.Url()
    image_url = fields.Url(allow_none=True)
    lang = fields.Str()

    @pre_dump
    def empty_image_url_to_none(self, data):
        if not data.image_url:
            data.image_url = None
        return data

    class Meta:
        type_ = "news"
        strict = True
Ejemplo n.º 19
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
Ejemplo n.º 20
0
class EventInvoiceSchema(SoftDeletionSchema):
    """
    Event Invoice API Schema based on event invoice model
    """
    class Meta:
        type_ = 'event-invoice'
        self_view = 'v1.event_invoice_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    id = fields.Str(dump_only=True)
    identifier = fields.Str(allow_none=True)
    amount = fields.Float(validate=lambda n: n >= 0, allow_none=True)
    created_at = fields.DateTime(allow_none=True)
    issued_at = fields.DateTime(dump_only=True)
    due_at = fields.DateTime(dump_only=True)
    completed_at = fields.DateTime(default=None, allow_none=True)
    transaction_id = fields.Str(allow_none=True)
    paid_via = fields.Str(
        validate=validate.OneOf(choices=[
            "free", "stripe", "paypal", "transfer", "onsite", "cheque"
        ]),
        allow_none=True,
    )
    payment_mode = fields.Str(allow_none=True)
    brand = fields.Str(allow_none=True)
    exp_month = fields.Integer(validate=lambda n: 0 <= n <= 12,
                               allow_none=True)
    exp_year = fields.Integer(validate=lambda n: n >= 2015, allow_none=True)
    last4 = fields.Str(allow_none=True)
    stripe_token = fields.Str(allow_none=True)
    paypal_token = fields.Str(allow_none=True)
    status = fields.Str(
        validate=validate.OneOf(choices=[
            "paid", "due", "refunding", "refunded", "failed", "resolved"
        ]),
        allow_none=True,
    )
    invoice_pdf_url = fields.Url(allow_none=True)
    user = Relationship(
        self_view='v1.event_invoice_user',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.user_detail',
        related_view_kwargs={'event_invoice_id': '<id>'},
        schema='UserSchemaPublic',
        type_='user',
    )
    event = Relationship(
        self_view='v1.event_invoice_event',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.event_detail',
        related_view_kwargs={'event_invoice_id': '<id>'},
        schema='EventSchemaPublic',
        type_='event',
    )
Ejemplo n.º 21
0
class UserSchema(Schema):
    id = fields.String(attribute='user_id')
    user_name = fields.String()
    first_name = fields.String(allow_none=True)
    last_name = fields.String(allow_none=True)
    affiliation = fields.String(allow_none=True)
    url = fields.Url(allow_none=True)
    date_joined = fields.LocalDateTime("%c")

    class Meta:
        type_ = 'users'
Ejemplo n.º 22
0
class UserSchemaPublic(SoftDeletionSchema):
    """
    Api schema for User Model which can be accessed by any resource to which user is related.
    Co-organizers of events to which the user will be related will have access to this info.
    """
    class Meta:
        """
        Meta class for User Api Schema
        """

        type_ = 'user'
        self_view = 'v1.user_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    id = fields.Str(dump_only=True)
    email = TrimmedEmail(required=True)
    avatar_url = fields.Url(allow_none=True)
    first_name = fields.Str(allow_none=True)
    last_name = fields.Str(allow_none=True)
    public_name = fields.Str(allow_none=True)
    is_profile_public = fields.Bool(default=False, allow_none=False)
    original_image_url = fields.Url(dump_only=True, allow_none=True)
    thumbnail_image_url = fields.Url(dump_only=True, allow_none=True)
    small_image_url = fields.Url(dump_only=True, allow_none=True)
    icon_image_url = fields.Url(dump_only=True, allow_none=True)
    was_registered_with_order = fields.Boolean()

    @pre_dump
    def handle_deleted_or_private_users(self, data):
        if not data:
            return data
        can_access = require_current_user() and (current_user.is_staff
                                                 or current_user.id == data.id)
        if data.deleted_at != None and not can_access:
            user = User(id=0,
                        email='*****@*****.**',
                        first_name='deleted',
                        last_name='user')
            return user
        return data
Ejemplo n.º 23
0
class ChannelsSchema(BaseSchema):

    id = fields.UUID(dump_only=True)
    publisher_id = fields.Integer()
    title = fields.Str()
    link = fields.Url()
    publication_updated_datetime = fields.DateTime()
    public_channel_id = fields.Str()

    class Meta:
        type_ = 'channels'
        strict = True
Ejemplo n.º 24
0
class SettingSchemaPublic(Schema):
    """
    Public Api schema for settings Model
    """
    class Meta:
        """
        Meta class for setting Api Schema
        """
        type_ = 'setting'
        self_view = 'v1.setting_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    id = fields.Str(dump_only=True)

    # Name of the application. (Eg. Event Yay!, Open Event)
    app_name = fields.Str(allow_none=True)

    # Tagline for the application. (Eg. Event Management and Ticketing, Home)
    tagline = fields.Str(allow_none=True)

    # Google Analytics
    analytics_key = fields.Str(allow_none=True)

    # FB
    fb_client_id = fields.Str(allow_none=True)

    #
    # Social links
    #
    google_url = fields.Str(allow_none=True)
    github_url = fields.Str(allow_none=True)
    twitter_url = fields.Str(allow_none=True)
    support_url = fields.Str(allow_none=True)
    facebook_url = fields.Str(allow_none=True)
    youtube_url = fields.Str(allow_none=True)

    # Url of Frontend
    frontend_url = fields.Url(allow_none=True)

    #
    # Cookie Policy
    #
    cookie_policy = fields.Str(allow_none=True)
    cookie_policy_link = fields.Str(allow_none=True)

    #
    # Online Payment Flags
    #
    is_paypal_activated = fields.Bool(dump_only=True)
    is_stripe_activated = fields.Bool(dump_only=True)
    is_omise_activated = fields.Bool(dump_only=True)
    is_alipay_activated = fields.Bool(dump_only=True)
Ejemplo n.º 25
0
class AttendeeSchemaPublic(SoftDeletionSchema):
    """
    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(required=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()
    device_name_checkin = fields.Str(allow_none=True)
    checkin_times = fields.Str(allow_none=True)
    checkout_times = fields.Str(allow_none=True, dump_only=True)
    attendee_notes = fields.Str(allow_none=True)
    is_checked_out = fields.Boolean()
    pdf_url = fields.Url(dump_only=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')
Ejemplo n.º 26
0
class ApplicationSchema(Schema):
    class Meta:
        type_ = 'applications'
        self_view = 'applications_api.application_detail'
        self_view_kwargs = {'application_id': '<id>'}
        self_view_many = 'applications_api.applications_list'
        strict = True

    id = fields.Int(dump_only=True)
    display_name = fields.Str()
    description = fields.Str()
    version = fields.Str()
    itunes_store_id = fields.Int()
    bundle_id = fields.Str()
    purchase_method = fields.Int()
    manifest_url = fields.Url()
    management_flags = fields.Int()
    change_management_state = fields.Str()

    # iTunes Search API cache
    country = fields.Str()
    artist_id = fields.Int()
    artist_name = fields.Str()
    artist_view_url = fields.Url()
    artwork_url60 = fields.Url()
    artwork_url100 = fields.Url()
    artwork_url512 = fields.Url()
    release_notes = fields.Str()
    release_date = fields.DateTime()
    minimum_os_version = fields.Str()
    file_size_bytes = fields.Number()

    # expose the underlying polymorphic identity for lists that contain all types of apps
    discriminator = fields.Str()

    tags = Relationship(related_view='api_app.tags_list',
                        related_view_kwargs={'application_id': '<id>'},
                        many=True,
                        schema='TagSchema',
                        type_='tags')
Ejemplo n.º 27
0
class EventCopyrightSchema(Schema):

    class Meta:
        type_ = 'event-copyright'
        self_view = 'v1.event_copyright_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    id = fields.Str(dump_only=True)
    holder = fields.Str(allow_none=True)
    holder_url = fields.Url(allow_none=True)
    licence = fields.Str(required=True)
    licence_url = fields.Url(allow_none=True)
    year = fields.Int(validate=lambda n: 1900 <= n <= datetime.now().year, allow_none=True)
    logo_url = fields.Url(attribute='logo', allow_none=True)
    event = Relationship(attribute='event',
                         self_view='v1.copyright_event',
                         self_view_kwargs={'id': '<id>'},
                         related_view='v1.event_detail',
                         related_view_kwargs={'copyright_id': '<id>'},
                         schema='EventSchemaPublic',
                         type_='event')
Ejemplo n.º 28
0
class ImageSchema(Schema):
    src = fields.Url()

    class Meta:
        type_ = 'image'
        additional = ('id', )

    def ImageUrlConverted(self, obj):
        _file = Path(obj.filename)
        ret = urlunparse(
            ('https', 'example.com',
             'images/{:}/{:}'.format(_file.parent.name,
                                     _file.name), None, None, None))
        return ret
Ejemplo n.º 29
0
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",
                )
Ejemplo n.º 30
0
class VideoSchema(Schema):

    id = fields.UUID(dump_only=True, attribute='uuid')

    status = fields.Integer(required=True)
    video_id = fields.String()
    timestamp_publish = fields.DateTime("%Y-%m-%dT%H:%M:%S+00:00")
    url = fields.Url()
    site = fields.String()
    title = fields.String()
    description = fields.String()
    thumbnail_url = fields.Url()
    description_snippet = fields.String()

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

    class Meta:
        type_ = 'video'