Exemple #1
0
class WorksheetBlockSchema(PlainSchema):
    id = fields.Integer()
    mode = fields.String(validate=validate.OneOf(set(BlockModes.values)))
    is_refined = fields.Bool()

    class Meta:
        type_ = 'worksheet-block'
class WorksheetSchema(Schema):
    id = fields.String(validate=validate_uuid, attribute='uuid')
    uuid = fields.String(attribute='uuid')  # for backwards compatibility
    name = fields.String(validate=validate_name)
    owner = fields.Relationship(include_resource_linkage=True,
                                type_='users',
                                attribute='owner_id')
    title = fields.String(validate=validate_ascii)
    frozen = fields.DateTime(allow_none=True)
    is_anonymous = fields.Bool()
    tags = fields.List(fields.String(validate=validate_ascii))
    group_permissions = fields.Relationship(include_resource_linkage=True,
                                            type_='worksheet-permissions',
                                            id_field='id',
                                            many=True)
    items = fields.Relationship(include_resource_linkage=True,
                                type_='worksheet-items',
                                id_field='id',
                                many=True)
    last_item_id = fields.Integer(dump_only=True)

    # Bundle permission of the authenticated user for convenience, read-only
    permission = fields.Integer()
    permission_spec = PermissionSpec(attribute='permission')

    class Meta:
        type_ = 'worksheets'
Exemple #3
0
class ValidTokenSchema(Schema):
    class Meta:
        type_ = 'valid-tokens'
        kwargs = {'id': '<id>'}

    id = fields.Str(required=True, dump_only=True)
    valid = fields.Bool(required=True)
Exemple #4
0
class DeleteAdminRole(Schema):
    class Meta:
        type_ = 'delete-admins'
        kwargs = {'id': '<id>'}

    id = fields.Str(required=True, dump_only=True)
    email = fields.Str(required=True)
    siteAdmin = fields.Bool(required=True)
Exemple #5
0
class InstalledProfileSchema(Schema):
    class Meta:
        type_ = 'installed_profiles'
        self_view = 'api_app.installed_profile_detail'
        self_view_kwargs = {'installed_profile_id': '<id>'}
        self_view_many = 'api_app.installed_profiles_list'

    id = fields.Int(dump_only=True)

    has_removal_password = fields.Bool()
    is_encrypted = fields.Bool()
    payload_description = fields.Str()
    payload_display_name = fields.Str()
    payload_identifier = fields.Str()
    payload_organization = fields.Str()
    payload_removal_disallowed = fields.Boolean()
    payload_uuid = fields.UUID()
Exemple #6
0
class ControlLimitSchema(BaseSchema):
    """
    Defines "control limits" for a control chart.
    """

    # If we should enable the limits at all
    enabled = f.Bool()
    # Number of standard deviations on each side
    sigma = f.Float()
Exemple #7
0
class MarkupBlockSchema(WorksheetBlockSchema):
    """
    Schema for blocks that contain markup.
    Does not need refining, contains markup text as payload.
    """

    mode = fields.Constant(BlockModes.markup_block)
    is_refined = fields.Bool(validate=validate.Equal(True))  # always refined
    text = fields.String()
Exemple #8
0
class AllUsersSchema(Schema):
    class Meta:
        type_ = 'all-users'
        self_views = 'admin.show_all_users'
        kwargs = {'id': '<id>'}

    id = fields.Str(required=True, dump_only=True, attribute='User.id')
    username = fields.Str(required=True, attribute='User.username')
    email = fields.Str(required=True, attribute='User.email')
    password = fields.Str(required=True, attribute='User.password')
    created_at = fields.Date(required=True, attribute='User.created_at')
    photoURL = fields.Str(required=True, attribute='User.photoURL')
    deleted_at = fields.Date(attribute='User.deleted_at')
    isAdmin = fields.Bool(attribute='Permissions.isAdmin')
    isUser = fields.Bool(attribute='Permissions.isUser')
    isSales = fields.Bool(attribute='Permissions.isSales')
    lastLoginIp = fields.Str(allow_none=True, attribute='User.last_login_ip')
    lastLoginDate = fields.DateTime(allow_none=True, attribute='User.last_login_date')
Exemple #9
0
class TodoSchema(Schema):
    class Meta:
        type_ = 'todo'
        self_view = 'todo_detail'
        self_view_kwargs = {'id': '<id>'}

    id = fields.Integer(dump_only=True)
    name = fields.Str()
    done = fields.Bool()
Exemple #10
0
class WorksheetBlockSchema(PlainSchema):
    """
    Parent schema for all worksheet blocks.
    """

    mode = fields.String(validate=validate.OneOf(set(BlockModes.values)))
    is_refined = fields.Bool(default=False)

    class Meta:
        type_ = 'worksheet-block'
class GroupSchema(Schema):
    id = fields.String(validate=validate_uuid, attribute='uuid')
    name = fields.String(required=True, validate=validate_name)
    user_defined = fields.Bool(dump_only=True)
    owner = fields.Relationship(include_resource_linkage=True, type_='users', attribute='owner_id')
    admins = fields.Relationship(include_resource_linkage=True, type_='users', many=True)
    members = fields.Relationship(include_resource_linkage=True, type_='users', many=True)

    class Meta:
        type_ = 'groups'
Exemple #12
0
class TrackSchema(Schema):
    id = fields.Str(dump_only=True)
    title = fields.Str(required=True,
                       validate=validate.Length(min=1,
                                                error='Title cannot be blank'))
    audio_url = fields.Str(dump_only=True)
    featured = fields.Bool(dump_only=True)
    sort = fields.Str(dump_only=True)

    class Meta:
        type_ = "track"
Exemple #13
0
class OAuthUserSchema(Schema):
    class Meta:
        type_ = 'users'
        kwargs = {'id': '<id>'}

    id = fields.Str(required=True, dump_only=True)
    username = fields.Str(required=True)
    email = fields.Str(required=True)
    photoURL = fields.Str(required=True, allow_none=True)
    siteAdmin = fields.Bool()
    password = fields.Str(allow_none=True)
Exemple #14
0
class UserSchema(Schema):
    class Meta:
        type_ = 'user-signups'
        self_view = 'registerUser.register_user'
        kwargs = {'id': '<id>'}

    id = fields.Str(required=True, dump_only=True)
    username = fields.Str(required=True)
    email = fields.Str()
    password = fields.Str(required=True, load_only=True)
    photoURL = fields.Str()
    siteAdmin = fields.Bool()
    last_login_date = fields.DateTime()
Exemple #15
0
class SingleSchema(Schema):
    id = fields.Str(dump_only=True)
    title = fields.Str(required=True,
                       validate=validate.Length(min=1,
                                                error='Title cannot be blank'))
    release_date = fields.Str(required=True)
    license = fields.Str(default='')
    audio_url = fields.Str(dump_only=True)
    sort = fields.Str(dump_only=True)
    featured = fields.Bool(dump_only=True)

    class Meta:
        type_ = "single"
Exemple #16
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")
    avatar_id = fields.String(allow_none=True)
    has_access = fields.Bool()

    class Meta:
        type_ = 'users'
Exemple #17
0
class BundleSchema(Schema):
    id = fields.String(validate=validate_uuid, attribute='uuid')
    uuid = fields.String(attribute='uuid')  # for backwards compatibility
    bundle_type = fields.String(
        validate=validate.OneOf({bsc.BUNDLE_TYPE
                                 for bsc in BUNDLE_SUBCLASSES}))
    command = fields.String(allow_none=True, validate=validate_ascii)
    data_hash = fields.String()
    state = fields.String()
    owner = fields.Relationship(include_resource_linkage=True,
                                type_='users',
                                attribute='owner_id')
    frozen = fields.DateTime(allow_none=True)
    is_anonymous = fields.Bool()
    storage_type = fields.String()
    is_dir = fields.Bool()
    metadata = fields.Dict(values=fields.String(validate=validate_ascii))
    dependencies = fields.Nested(BundleDependencySchema, many=True)
    children = fields.Relationship(include_resource_linkage=True,
                                   type_='bundles',
                                   id_field='uuid',
                                   many=True)
    group_permissions = fields.Relationship(include_resource_linkage=True,
                                            type_='bundle-permissions',
                                            id_field='id',
                                            many=True)
    host_worksheets = fields.Relationship(include_resource_linkage=True,
                                          type_='worksheets',
                                          id_field='uuid',
                                          many=True)
    args = fields.String()

    # Bundle permission of the authenticated user for convenience, read-only
    permission = fields.Integer()
    permission_spec = PermissionSpec(attribute='permission')

    class Meta:
        type_ = 'bundles'
Exemple #18
0
class ManagedApplicationSchema(Schema):
    class Meta:
        type_ = 'managed_applications'
        self_view = 'applications_api.managed_application_detail'
        self_view_kwargs = {'managed_application_id': '<id>'}
        self_view_many = 'applications_api.managed_applications_list'

    id = fields.Int(dump_only=True)
    bundle_id = fields.Str()
    external_version_id = fields.Int()
    has_configuration = fields.Bool()
    has_feedback = fields.Bool()
    is_validated = fields.Bool()
    management_flags = fields.Int()
    status = fields.Str()

    device = Relationship(
        related_view='api_app.device_detail',
        related_view_kwargs={'device_id': '<device_id>'},
        many=False,
        schema='DeviceSchema',
        type_='devices',
    )
class RestaurantSchema(Schema):
    id = fields.Str()
    metadata = fields.ResourceMeta()
    cuisine = fields.List(fields.Str)
    name = fields.Str()
    location = fields.Str()
    phone = fields.Str()
    display_phone = fields.Str()
    rating = fields.Float()
    price = fields.Str()
    is_closed = fields.Bool()
    photos = fields.List(fields.Str)
    website = fields.Str()

    class Meta:
        type_ = 'restaurants'
class UsersGroupsRolesSchema(Schema):
    """
    Api schema for users_groups_role Model
    """

    class Meta:
        """
        Meta class for users_groups_role Api Schema
        """

        type_ = 'users-groups-role'
        self_view = 'v1.users_groups_roles_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    id = fields.Str(dump_only=True)
    email = TrimmedEmail(required=True)
    accepted = fields.Bool(dump_only=True)
    token = fields.Str(dump_only=True)

    group = Relationship(
        self_view='v1.users_groups_roles_group',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.group_detail',
        related_view_kwargs={'users_groups_roles_id': '<id>'},
        schema='GroupSchema',
        type_='group',
    )

    user = Relationship(
        dump_only=True,
        self_view='v1.users_groups_roles_user',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.user_detail',
        related_view_kwargs={'users_groups_roles_id': '<id>'},
        schema='UserSchemaPublic',
        type_="user",
    )

    role = Relationship(
        self_view='v1.users_groups_roles_role',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.role_detail',
        related_view_kwargs={'users_groups_roles_id': '<id>'},
        schema='RoleSchema',
        type_="role",
    )
Exemple #21
0
class PlotSchema(JsonApiSchema):
    """
    Data that can be used to generate a plot.
    """
    class Meta:
        type_ = "plots"
        unknown = INCLUDE

    id = f.String(dump_only=True)
    type = f.String()
    x = f.List(f.Raw())
    y = f.List(f.Raw())
    text = f.List(f.Raw())
    hoverinfo = f.Str()
    line = f.Dict()
    mode = f.String()
    name = f.String()
    fill = f.String()
    fillcolor = f.String()
    showlegend = f.Bool()
Exemple #22
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')
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
Exemple #24
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 #25
0
class InstalledApplicationSchema(Schema):
    class Meta:
        type_ = 'installed_applications'
        self_view = 'api_app.installed_application_detail'
        self_view_kwargs = {'installed_application_id': '<id>'}
        self_view_many = 'api_app.installed_applications_list'
        strict = True

    id = fields.Int(dump_only=True)
    bundle_identifier = fields.Str(dump_only=True)
    name = fields.Str(dump_only=True)
    short_version = fields.Str(dump_only=True)
    version = fields.Str(dump_only=True)
    bundle_size = fields.Int(dump_only=True)
    dynamic_size = fields.Int(dump_only=True)
    is_validated = fields.Bool(dump_only=True)

    device = Relationship(
        related_view='api_app.device_detail',
        related_view_kwargs={'device_id': '<device_id>'},
        type_='devices',
    )
class EventSchemaPublic(SoftDeletionSchema):
    class Meta:
        type_ = 'event'
        self_view = 'v1.event_detail'
        self_view_kwargs = {'id': '<id>'}
        self_view_many = 'v1.event_list'
        inflect = dasherize

    @validates_schema(pass_original=True)
    def validate_timezone(self, data, original_data):
        if 'id' in original_data['data']:
            try:
                event = Event.query.filter_by(
                    id=original_data['data']['id']).one()
            except NoResultFound:
                raise ObjectNotFound({'source': 'data/id'},
                                     "Event id not found")

            if 'timezone' not in data:
                data['timezone'] = event.timezone
        try:
            timezone(data['timezone'])
        except pytz.exceptions.UnknownTimeZoneError:
            raise UnprocessableEntity({'pointer': '/data/attributes/timezone'},
                                      "Unknown timezone: '{}'".format(
                                          data['timezone']))

    id = fields.Str(dump_only=True)
    identifier = fields.Str(dump_only=True)
    name = fields.Str(required=True)
    external_event_url = fields.Url(allow_none=True)
    starts_at = fields.DateTime(required=True, timezone=True)
    ends_at = fields.DateTime(required=True, timezone=True)
    timezone = fields.Str(required=True)
    is_event_online = fields.Boolean(default=False)
    latitude = fields.Float(validate=lambda n: -90 <= n <= 90, allow_none=True)
    longitude = fields.Float(validate=lambda n: -180 <= n <= 180,
                             allow_none=True)
    logo_url = fields.Url(allow_none=True)
    location_name = fields.Str(allow_none=True)
    searchable_location_name = fields.Str(allow_none=True)
    description = fields.Str(allow_none=True)
    original_image_url = fields.Url(allow_none=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)
    show_remaining_tickets = fields.Bool(allow_none=False, default=False)
    owner_name = fields.Str(allow_none=True)
    is_map_shown = fields.Bool(default=False)
    has_owner_info = fields.Bool(default=False)
    owner_description = fields.Str(allow_none=True)
    is_sessions_speakers_enabled = fields.Bool(default=False)
    privacy = fields.Str(default="public")
    state = fields.Str(validate=validate.OneOf(choices=["published", "draft"]),
                       allow_none=True,
                       default='draft')
    ticket_url = fields.Url(allow_none=True)
    code_of_conduct = fields.Str(allow_none=True)
    schedule_published_on = fields.DateTime(allow_none=True)
    is_featured = fields.Bool(default=False)
    is_promoted = fields.Bool(default=False)
    is_ticket_form_enabled = fields.Bool(default=True)
    payment_country = fields.Str(allow_none=True)
    payment_currency = fields.Str(allow_none=True)
    paypal_email = fields.Str(allow_none=True)
    is_tax_enabled = fields.Bool(default=False)
    is_billing_info_mandatory = fields.Bool(default=False)
    is_donation_enabled = fields.Bool(default=False)
    can_pay_by_paypal = fields.Bool(default=False)
    can_pay_by_stripe = fields.Bool(default=False)
    can_pay_by_cheque = fields.Bool(default=False)
    can_pay_by_bank = fields.Bool(default=False)
    can_pay_onsite = fields.Bool(default=False)
    can_pay_by_omise = fields.Bool(default=False)
    can_pay_by_alipay = fields.Bool(default=False)
    can_pay_by_paytm = fields.Bool(default=False)
    cheque_details = fields.Str(allow_none=True)
    bank_details = fields.Str(allow_none=True)
    onsite_details = fields.Str(allow_none=True)
    is_sponsors_enabled = fields.Bool(default=False)
    created_at = fields.DateTime(dump_only=True, timezone=True)
    pentabarf_url = fields.Url(dump_only=True)
    ical_url = fields.Url(dump_only=True)
    xcal_url = fields.Url(dump_only=True)
    refund_policy = fields.String(
        dump_only=True,
        default='All sales are final. No refunds shall be issued in any case.')
    is_stripe_linked = fields.Boolean(dump_only=True,
                                      allow_none=True,
                                      default=False)

    tickets = Relationship(attribute='tickets',
                           self_view='v1.event_ticket',
                           self_view_kwargs={'id': '<id>'},
                           related_view='v1.ticket_list',
                           related_view_kwargs={'event_id': '<id>'},
                           schema='TicketSchemaPublic',
                           many=True,
                           type_='ticket')
    faqs = Relationship(attribute='faqs',
                        self_view='v1.event_faqs',
                        self_view_kwargs={'id': '<id>'},
                        related_view='v1.faq_list',
                        related_view_kwargs={'event_id': '<id>'},
                        schema='FaqSchema',
                        many=True,
                        type_='faq')
    faq_types = Relationship(attribute='faq_types',
                             self_view='v1.event_faq_types',
                             self_view_kwargs={'id': '<id>'},
                             related_view='v1.faq_type_list',
                             related_view_kwargs={'event_id': '<id>'},
                             schema='FaqTypeSchema',
                             many=True,
                             type_='faq_type')
    feedbacks = Relationship(attribute='feedbacks',
                             self_view='v1.event_feedbacks',
                             self_view_kwargs={'id': '<id>'},
                             related_view='v1.feedback_list',
                             related_view_kwargs={'event_id': '<id>'},
                             schema='FeedbackSchema',
                             many=True,
                             type_='feedback')
    ticket_tags = Relationship(attribute='ticket_tags',
                               self_view='v1.event_ticket_tag',
                               self_view_kwargs={'id': '<id>'},
                               related_view='v1.ticket_tag_list',
                               related_view_kwargs={'event_id': '<id>'},
                               schema='TicketTagSchema',
                               many=True,
                               type_='ticket-tag')
    microlocations = Relationship(attribute='microlocation',
                                  self_view='v1.event_microlocation',
                                  self_view_kwargs={'id': '<id>'},
                                  related_view='v1.microlocation_list',
                                  related_view_kwargs={'event_id': '<id>'},
                                  schema='MicrolocationSchema',
                                  many=True,
                                  type_='microlocation')
    social_links = Relationship(attribute='social_link',
                                self_view='v1.event_social_link',
                                self_view_kwargs={'id': '<id>'},
                                related_view='v1.social_link_list',
                                related_view_kwargs={'event_id': '<id>'},
                                schema='SocialLinkSchema',
                                many=True,
                                type_='social-link')
    tracks = Relationship(attribute='track',
                          self_view='v1.event_tracks',
                          self_view_kwargs={'id': '<id>'},
                          related_view='v1.track_list',
                          related_view_kwargs={'event_id': '<id>'},
                          schema='TrackSchema',
                          many=True,
                          type_='track')
    sponsors = Relationship(attribute='sponsor',
                            self_view='v1.event_sponsor',
                            self_view_kwargs={'id': '<id>'},
                            related_view='v1.sponsor_list',
                            related_view_kwargs={'event_id': '<id>'},
                            schema='SponsorSchema',
                            many=True,
                            type_='sponsor')
    speakers_call = Relationship(attribute='speakers_call',
                                 self_view='v1.event_speakers_call',
                                 self_view_kwargs={'id': '<id>'},
                                 related_view='v1.speakers_call_detail',
                                 related_view_kwargs={'event_id': '<id>'},
                                 schema='SpeakersCallSchema',
                                 type_='speakers-call')
    session_types = Relationship(attribute='session_type',
                                 self_view='v1.event_session_types',
                                 self_view_kwargs={'id': '<id>'},
                                 related_view='v1.session_type_list',
                                 related_view_kwargs={'event_id': '<id>'},
                                 schema='SessionTypeSchema',
                                 many=True,
                                 type_='session-type')
    event_copyright = Relationship(attribute='copyright',
                                   self_view='v1.event_copyright',
                                   self_view_kwargs={'id': '<id>'},
                                   related_view='v1.event_copyright_detail',
                                   related_view_kwargs={'event_id': '<id>'},
                                   schema='EventCopyrightSchema',
                                   type_='event-copyright')
    tax = Relationship(attribute='tax',
                       self_view='v1.event_tax',
                       self_view_kwargs={'id': '<id>'},
                       related_view='v1.tax_detail',
                       related_view_kwargs={'event_id': '<id>'},
                       schema='TaxSchema',
                       type_='tax')
    sessions = Relationship(attribute='session',
                            self_view='v1.event_session',
                            self_view_kwargs={'id': '<id>'},
                            related_view='v1.session_list',
                            related_view_kwargs={'event_id': '<id>'},
                            schema='SessionSchema',
                            many=True,
                            type_='session')
    speakers = Relationship(attribute='speaker',
                            self_view='v1.event_speaker',
                            self_view_kwargs={'id': '<id>'},
                            related_view='v1.speaker_list',
                            related_view_kwargs={'event_id': '<id>'},
                            schema='SpeakerSchema',
                            many=True,
                            type_='speaker')
    event_type = Relationship(attribute='event_type',
                              self_view='v1.event_event_type',
                              self_view_kwargs={'id': '<id>'},
                              related_view='v1.event_type_detail',
                              related_view_kwargs={'event_id': '<id>'},
                              schema='EventTypeSchema',
                              type_='event-type')
    event_topic = Relationship(attribute='event_topic',
                               self_view='v1.event_event_topic',
                               self_view_kwargs={'id': '<id>'},
                               related_view='v1.event_topic_detail',
                               related_view_kwargs={'event_id': '<id>'},
                               schema='EventTopicSchema',
                               type_='event-topic')
    event_sub_topic = Relationship(attribute='event_sub_topic',
                                   self_view='v1.event_event_sub_topic',
                                   self_view_kwargs={'id': '<id>'},
                                   related_view='v1.event_sub_topic_detail',
                                   related_view_kwargs={'event_id': '<id>'},
                                   schema='EventSubTopicSchema',
                                   type_='event-sub-topic')
    custom_forms = Relationship(attribute='custom_form',
                                self_view='v1.event_custom_forms',
                                self_view_kwargs={'id': '<id>'},
                                related_view='v1.custom_form_list',
                                related_view_kwargs={'event_id': '<id>'},
                                schema='CustomFormSchema',
                                many=True,
                                type_='custom-form')
    owner = Relationship(attribute='owner',
                         self_view='v1.event_owner',
                         self_view_kwargs={'id': '<id>'},
                         related_view='v1.user_detail',
                         schema='UserSchemaPublic',
                         related_view_kwargs={'event_id': '<id>'},
                         type_='user')
    organizers = Relationship(attribute='organizers',
                              self_view='v1.event_organizers',
                              self_view_kwargs={'id': '<id>'},
                              related_view='v1.user_list',
                              schema='UserSchemaPublic',
                              type_='user',
                              many=True)
    coorganizers = Relationship(attribute='coorganizers',
                                self_view='v1.event_coorganizers',
                                self_view_kwargs={'id': '<id>'},
                                related_view='v1.user_list',
                                schema='UserSchemaPublic',
                                type_='user',
                                many=True)
    stripe_authorization = Relationship(
        attribute='stripe_authorization',
        self_view='v1.stripe_authorization_event',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.stripe_authorization_detail',
        related_view_kwargs={'event_id': '<id>'},
        schema='StripeAuthorizationSchema',
        type_='stripe-authorization')
    order_statistics = Relationship(
        self_view='v1.event_order_statistics',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.order_statistics_event_detail',
        related_view_kwargs={'id': '<id>'},
        schema='OrderStatisticsEventSchema',
        type_='order-statistics-event')
    general_statistics = Relationship(
        self_view='v1.event_general_statistics',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.event_statistics_general_detail',
        related_view_kwargs={'id': '<id>'},
        schema='EventStatisticsGeneralSchema',
        type_='general-statistics-event')
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)

    # 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)
class SettingSchemaAdmin(SettingSchemaNonAdmin):
    """
    Admin 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)
    #
    # General
    #

    app_environment = fields.Str(default=Environment.PRODUCTION)

    # Static domain
    static_domain = fields.Str(allow_none=True)

    #
    #  STORAGE
    #

    # storage place, local, s3, .. can be more in future
    storage_place = fields.Str(allow_none=True)
    # S3
    aws_key = fields.Str(allow_none=True)
    aws_secret = fields.Str(allow_none=True)
    aws_bucket_name = fields.Str(allow_none=True)
    aws_region = fields.Str(allow_none=True)
    # Google Storage
    gs_key = fields.Str(allow_none=True)
    gs_secret = fields.Str(allow_none=True)
    gs_bucket_name = fields.Str(allow_none=True)

    #
    # CAPTCHA
    #

    # Google reCAPTCHA
    is_google_recaptcha_enabled = fields.Bool(allow_none=False, default=False)
    google_recaptcha_site = fields.Str(allow_none=True)
    google_recaptcha_secret = fields.Str(allow_none=True)

    #
    # Social Login
    #

    # Google Auth
    google_client_id = fields.Str(allow_none=True)
    google_client_secret = fields.Str(allow_none=True)
    # FB
    fb_client_id = fields.Str(allow_none=True)
    fb_client_secret = fields.Str(allow_none=True)
    # Twitter
    tw_consumer_key = fields.Str(allow_none=True)
    tw_consumer_secret = fields.Str(allow_none=True)
    # Instagram
    in_client_id = fields.Str(allow_none=True)
    in_client_secret = fields.Str(allow_none=True)

    #
    # Payment Gateways
    #

    # Stripe Credantials
    stripe_client_id = fields.Str(allow_none=True)
    stripe_publishable_key = fields.Str(allow_none=True)
    stripe_secret_key = fields.Str(allow_none=True)
    stripe_test_client_id = fields.Str(allow_none=True)
    stripe_test_secret_key = fields.Str(allow_none=True)
    stripe_test_publishable_key = fields.Str(allow_none=True)

    # PayPal Credentials
    paypal_mode = fields.Str(allow_none=True)
    paypal_client = fields.Str(allow_none=True)
    paypal_secret = fields.Str(allow_none=True)
    paypal_sandbox_client = fields.Str(allow_none=True)
    paypal_sandbox_secret = fields.Str(allow_none=True)

    # Omise Credentials
    omise_mode = fields.Str(allow_none=True)
    omise_test_public = fields.Str(allow_none=True)
    omise_test_secret = fields.Str(allow_none=True)
    omise_live_public = fields.Str(allow_none=True)
    omise_live_secret = fields.Str(allow_none=True)

    # Alipay Credentials
    alipay_publishable_key = fields.Str(allow_none=True)
    alipay_secret_key = fields.Str(allow_none=True)

    # payTM credentials
    paytm_mode = fields.Str(allow_none=True)
    paytm_live_merchant = fields.Str(allow_none=True)
    paytm_live_secret = fields.Str(allow_none=True)
    paytm_sandbox_merchant = fields.Str(allow_none=True)
    paytm_sandbox_secret = fields.Str(allow_none=True)
    #
    # EMAIL
    #

    # Email service. (sendgrid,smtp)
    email_service = fields.Str(allow_none=True)
    email_from = fields.Str(allow_none=True)
    email_from_name = fields.Str(allow_none=True)
    # Sendgrid
    sendgrid_key = fields.Str(allow_none=True)
    # SMTP
    smtp_host = fields.Str(allow_none=True)
    smtp_username = fields.Str(allow_none=True)
    smtp_password = fields.Str(allow_none=True)
    smtp_port = fields.Integer(allow_none=True)
    smtp_encryption = fields.Str(allow_none=True)  # Can be tls, ssl, none

    # Event Invoices settings
    invoice_sending_day = fields.Integer(allow_none=False, default=1)
    invoice_sending_timezone = fields.Str(allow_none=False, default="UTC")

    # Admin Invoice Details
    admin_billing_contact_name = fields.Str(allow_none=True)
    admin_billing_phone = fields.Str(allow_none=True)
    admin_billing_email = fields.Email(allow_none=True)
    admin_billing_state = fields.Str(allow_none=True)
    admin_billing_country = fields.Str(allow_none=True)
    admin_billing_tax_info = fields.Str(allow_none=True)
    admin_company = fields.Str(allow_none=True)
    admin_billing_address = fields.Str(allow_none=True)
    admin_billing_city = fields.Str(allow_none=True)
    admin_billing_zip = fields.Str(allow_none=True)
    admin_billing_additional_info = fields.Str(allow_none=True)
Exemple #29
0
class GroupSchema(SoftDeletionSchema):
    """
    Api Schema for event type model
    """
    class Meta:
        """
        Meta class for event type Api Schema
        """

        type_ = 'group'
        self_view = 'v1.group_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    id = fields.Str(dump_only=True)
    name = fields.Str(required=True)
    created_at = fields.DateTime(dump_only=True, timezone=True)
    social_links = fields.Nested(GroupSocialLinkSchema, many=True)
    logo_url = fields.Url(allow_none=True)
    is_promoted = fields.Bool(default=False)
    banner_url = fields.Url(allow_none=True)
    thumbnail_image_url = fields.Url(dump_only=True)
    follower_count = fields.Integer(dump_only=True)
    about = fields.Str(allow_none=True)

    events = Relationship(
        self_view='v1.group_events',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.event_list',
        related_view_kwargs={'group_id': '<id>'},
        many=True,
        schema='EventSchemaPublic',
        type_='event',
    )

    user = Relationship(
        attribute='user',
        self_view='v1.group_user',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.user_detail',
        related_view_kwargs={'group_id': '<id>'},
        schema='UserSchemaPublic',
        type_='user',
        dump_only=True,
    )

    roles = Relationship(
        self_view='v1.event_users_groups_roles',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.users_groups_roles_list',
        related_view_kwargs={'group_id': '<id>'},
        schema='UsersGroupsRolesSchema',
        type_='users-groups-role',
        many=True,
    )

    follower = Relationship(
        self_view='v1.group_followers',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.user_follow_group_list',
        related_view_kwargs={'group_id': '<id>'},
        schema='UserFollowGroupSchema',
        type_='user-follow-group',
    )

    followers = Relationship(
        self_view='v1.group_followers',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.user_follow_group_list',
        related_view_kwargs={'group_id': '<id>'},
        schema='UserFollowGroupSchema',
        many=True,
        type_='user-follow-group',
    )
class AdminUserSchema(AuthenticatedUserSchema):
    is_verified = fields.Bool()
    has_access = fields.Bool()