Ejemplo n.º 1
0
class UserSchema(BaseSchema):
    class Meta:
        model = User
        exclude = ('updated_on', 'password')

    id = ma.UUID(dump_only=True)
    email = ma.Email(unique=True, primary_key=True, required=True)
    username = ma.String(required=True)
    name = ma.String(load=True)
    brand_ids = ma.List(ma.UUID, dump_only=True)
    retail_shop_ids = ma.List(ma.UUID, dump_only=True)
    retail_shops = ma.Nested('RetailShopSchema', many=True, dump_only=True)

    _links = ma.Hyperlinks({
        'shops':
        ma.URLFor('pos.retail_shop_view', __id__in='<retail_shop_ids>')
    })
    roles = ma.Nested('RoleSchema',
                      many=True,
                      dump_only=True,
                      only=('id', 'name'))
    permissions = ma.Nested('PermissionSchema',
                            many=True,
                            dump_only=True,
                            only=('id', 'name'))
Ejemplo n.º 2
0
class UserSchema(BaseSchema):
    class Meta:
        model = User

    id = ma.Integer(dump_only=True)
    # is_admin = ma.Boolean(dump_only=True)
    email = ma.Email(required=False)
Ejemplo n.º 3
0
class UserSchema(BaseSchema):
    class Meta:
        model = User
        exclude = ('updated_on', 'confirmed_at')
        #fields = ('id', 'email', 'username')

    id = ma.Integer(dump_only=True)
    email = ma.Email(required=False)
    mobile_number = ma.String(required=True)
    username = ma.String(required=True)
    roles = ma.Nested('RoleSchema', many=True, dump_only=True, only=('id', 'name'))
Ejemplo n.º 4
0
class UserSchema(ma.ModelSchema):
    class Meta:
        model = User
        exclude = ('created_on', 'updated_on', 'password', 'current_login_at',
                   'current_login_ip', 'last_login_at', 'last_login_ip',
                   'login_count')

    id = ma.Integer(dump_only=True)
    email = ma.Email()
    user_profile = ma.Nested('UserProfileSchema', many=False)
    authentication_token = ma.String()
Ejemplo n.º 5
0
class DistributorSchema(BaseSchema):
    class Meta:
        model = Distributor
        exclude = ('created_on', 'updated_on')

    name = ma.String()
    phone_numbers = ma.List(ma.Integer())
    emails = ma.List(ma.Email())
    retail_shop_id = ma.Integer()

    retail_shop = ma.Nested('RetailShopSchema', many=False, dump_only=True, only=('id', 'name'))
    bills = ma.Nested('DistributorBillSchema', many=True, exclude=('distributor', 'distributor_id'))
Ejemplo n.º 6
0
class UserSchema(BaseSchema):

    class Meta:
        model = User
        exclude = ('created_on', 'updated_on', 'password', 'current_login_at', 'current_login_ip',
                   'last_login_at', 'last_login_ip', 'login_count', 'confirmed_at')

    id = ma.Integer(dump_only=True)
    email = ma.Email(unique=True, primary_key=True, required=True)
    username = ma.String(required=True)
    user_profile = ma.Nested('UserProfileSchema', load=True, many=False, exclude=('user',))
    roles = ma.Nested('RoleSchema', many=True, dump_only=True)
Ejemplo n.º 7
0
class RiderSchema(BaseSchema):
    class Meta:
        model = Rider
        #exclude = ('updated_on')

    id = ma.Integer(dump_only=True)
    email = ma.Email(required=False)
    first_name = ma.String(Load=True)
    last_name = ma.String(Load=True)
    mobile_number = ma.Integer(Load=True)
    device_limit = ma.Integer(Load=True)
    devices = ma.Nested('DeviceSchema',
                        many=False,
                        dump_only=True,
                        only=('id', 'name'))
Ejemplo n.º 8
0
class UserSchema(BaseSchema):
    class Meta:
        model = User
        exclude = ('updated_on', 'my_payments', 'my_dues')

    id = ma.Integer(dump_only=True)
    email = ma.Email(required=False)
    # username = ma.String(required=True)
    first_name = ma.String(load=True)
    roles = ma.Nested('RoleSchema',
                      many=True,
                      dump_only=True,
                      only=('id', 'name'))
    fixed_dues = ma.Integer(dump_only=True)
    subscriptions = ma.Integer(dump_only=True)
Ejemplo n.º 9
0
class UserSchema(BaseSchema):

    class Meta:
        model = User
        exclude = ('created_on', 'updated_on', 'password', 'current_login_at', 'current_login_ip',
                   'last_login_at', 'last_login_ip', 'login_count', 'confirmed_at')

    id = ma.Integer(dump_only=True)
    email = ma.Email(unique=True, primary_key=True, required=True)
    username = ma.String(required=True)
    name = ma.String(dump_only=True)
    brand_ids = ma.List(ma.Integer)
    retail_shop_ids = ma.List(ma.Integer)
    retail_shops = ma.Nested('RetailShopSchema', many=True)

    _links = ma.Hyperlinks({'shops': ma.URLFor('pos.retail_shop_view', __id__in='<retail_shop_ids>')})
    roles = ma.Nested('RoleSchema', many=True, dump_only=True)
Ejemplo n.º 10
0
class UserSchema(ma.ModelSchema):
    class Meta:
        model = User
        exclude = ('created_on', 'updated_on', 'password', 'current_login_at',
                   'current_login_ip', 'last_login_at', 'last_login_ip',
                   'login_count')

    id = ma.Integer(dump_only=True)
    email = ma.Email()
    user_profile = ma.Nested('UserProfileSchema', many=False)
    school = ma.Nested('SchoolSchema', many=False)
    authentication_token = ma.String()

    @pre_load
    def save_model(self, in_data):
        deserialized_data = deserialize_data(in_data['school_code'])
        in_data['school_id'] = deserialized_data[0]
        in_data['user_type'] = deserialized_data[1]
        return in_data
Ejemplo n.º 11
0
class UserSchema(BaseSchema):
    class Meta:
        model = User
        exclude = ('updated_on', 'password')

    id = ma.UUID(dump_only=True)
    email = ma.Email(unique=True, primary_key=True, required=True)
    username = ma.String(required=True)
    name = ma.String(load=True)
    brand_ids = ma.List(ma.UUID, dump_only=True)
    store_ids = ma.List(ma.UUID, dump_only=True)
    stores = ma.Nested('StoreSchema', many=True, dump_only=True)

    roles = ma.Nested('RoleSchema',
                      many=True,
                      dump_only=True,
                      only=('id', 'name'))
    permissions = ma.Nested('PermissionSchema',
                            many=True,
                            dump_only=True,
                            only=('id', 'name'))
Ejemplo n.º 12
0
class DistributorSchema(BaseSchema):
    class Meta:
        model = Distributor
        exclude = ('created_on', 'updated_on')

    id = ma.UUID()
    name = ma.String()
    phone_numbers = ma.List(ma.Integer())
    emails = ma.List(ma.Email())
    retail_shop_id = ma.UUID()
    products = ma.Nested('ProductSchema',
                         many=True,
                         dump_only=True,
                         only=('id', 'name', 'last_selling_amount', 'barcode',
                               'last_purchase_amount', 'stock_required',
                               'quantity_label'))

    retail_shop = ma.Nested('RetailShopSchema',
                            many=False,
                            dump_only=True,
                            only=('id', 'name'))
    bills = ma.Nested('DistributorBillSchema',
                      many=True,
                      exclude=('distributor', 'distributor_id'))