Ejemplo n.º 1
0
class UserSchema(ma.SQLAlchemySchema):
    class Meta:
        model = UserModel()

    username = ma.auto_field()
    explain = ma.auto_field()
    profile_image = ma.Nested('ImageSchema', only=["url"])
Ejemplo n.º 2
0
class KeywordSchema(ma.SQLAlchemySchema):
    class Meta:
        model = Keyword

    id = ma.auto_field()
    stocks = ma.auto_field()
    keyword = ma.auto_field()
Ejemplo n.º 3
0
    class Meta:
        model = SavedPost

        id = ma.auto_field()
        user_id = ma.auto_field()
        created = ma.auto_field()
        post_id = ma.auto_field()
Ejemplo n.º 4
0
class DelPetRecordSchema(ma.SQLAlchemySchema):
    class Meta:
        model = PetRecord
    
    timestamp = ma.auto_field()
    pet_id = ma.auto_field()
    user_id = ma.auto_field()
Ejemplo n.º 5
0
class SubcategorySchema(ma.SQLAlchemySchema):
    class Meta:
        model = Subcategory

    name = ma.auto_field()
    category_id = ma.auto_field()
    category = Nested(CategorySchema)
Ejemplo n.º 6
0
class Bankchema(ma.SQLAlchemySchema):
    class Meta:
        model = Bank

    id = ma.auto_field()
    name = ma.auto_field()
    description = ma.auto_field()
Ejemplo n.º 7
0
class GallerySchema(ma.SQLAlchemySchema):
    class Meta:
        model = GalleryModel

    name = ma.auto_field()
    explain = ma.auto_field()
    gallery_id = ma.auto_field()
    gallery_type = ma.auto_field()
Ejemplo n.º 8
0
class UserSchema(ma.SQLAlchemySchema):
    class Meta:
        model = User
        include_fk = True

    id = ma.auto_field()
    username = ma.auto_field()
    email = ma.auto_field()
Ejemplo n.º 9
0
class CategorySchema(ma.SQLAlchemySchema):
    """Схема данных категорий товара."""
    class Meta:
        model = Category

    id = ma.auto_field()
    name = ma.auto_field()
    products = ma.auto_field()
Ejemplo n.º 10
0
class User_schema(ma.SQLAlchemySchema):
    class Meta:
        model = User

    id = ma.auto_field(dump_only=True)
    name = ma.auto_field()
    password = ma.auto_field(allow_none=True, load_only=True)
    email = ma.auto_field()
Ejemplo n.º 11
0
class CartSchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = Cart
        load_instance = True

    id = ma.auto_field(dump_only=True)
    idUser = ma.auto_field(required=True)
    products = ma.auto_field(required=True)
Ejemplo n.º 12
0
class CustomerSchema(ma.SQLAlchemySchema):
    class Meta:
        model = Customer

    id = ma.auto_field()
    name = ma.auto_field()
    email = fields.Email()
    budgetItems = ma.auto_field()
Ejemplo n.º 13
0
class CartSchema(ma.SQLAlchemySchema):
    class Meta:
        model = Cart
        ordered = True

    id = ma.auto_field()
    store_id = ma.auto_field()
    products = ma.List(ma.Nested(CartProductSchema))
Ejemplo n.º 14
0
class ImageSchema(ma.SQLAlchemySchema):
    class Meta:
        model = Image

    id = ma.auto_field()
    name = ma.auto_field()
    categories = ma.auto_field()
    timestamp = ma.auto_field()
Ejemplo n.º 15
0
class CategorySchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = Category

    name = ma.auto_field()
    description = ma.auto_field()
    date_posted = ma.auto_field()
    products =  fields.List(fields.Nested(ProductSchema))
Ejemplo n.º 16
0
class StoreProductsSchema(ma.SQLAlchemySchema):
    class Meta:
        model = Store
        ordered = True

    id = ma.auto_field()
    name = ma.auto_field()
    products = ma.List(ma.Nested(ProductStockSchema))
Ejemplo n.º 17
0
class UserSchema(ma.SQLAlchemySchema):
    class Meta:
        model = User

    id = ma.auto_field()
    email = ma.auto_field()
    first_name = ma.auto_field()
    last_name = ma.auto_field()
Ejemplo n.º 18
0
class ChildParentSchema(ma.SQLAlchemySchema):
    id = ma.auto_field()
    name = ma.auto_field()
    createdAt = fields.DateTime(format='%Y-%m-%d %H:%M:%S%z')
    updatedAt = fields.DateTime(format='%Y-%m-%d %H:%M:%S%z')

    class Meta:
        model = Parent
        ordered = True
Ejemplo n.º 19
0
class ProductsSchema(ma.SQLAlchemySchema):
    class Meta:
        model = Products

    name = ma.auto_field()
    price = ma.auto_field()
    stock = ma.auto_field()
    width = ma.auto_field()
    height = ma.auto_field()
Ejemplo n.º 20
0
class BudgetItemSchema(ma.SQLAlchemySchema):
    class Meta:
        model = BudgetItem
        include_fk = True

    id = ma.auto_field()
    name = ma.auto_field()
    customer_id = ma.auto_field()
    amount = fields.Float()
Ejemplo n.º 21
0
class StoreDetailSchema(ma.SQLAlchemySchema):
    class Meta:
        model = Store
        ordered = True

    id = ma.auto_field()
    name = ma.auto_field()
    address = ma.auto_field()
    logo_url = ma.auto_field()
Ejemplo n.º 22
0
class RuntimeSchema(ma.SQLAlchemyAutoSchema):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

    class Meta:
        model = Runtime
        include_relationships = True
        include_fk = True
        sqla_session = db.session

    id = ma.auto_field(dump_only=True)

    runtime_type = EnumField(RuntimeTypeEnum, by_value=True)
    available_opts = fields.Nested(
        'AvailableOptionSchema',
        default=[],
        many=True,
        # exclude=('available_option_idddd',)
    )
    created_at = ma.auto_field(dump_only=True)
    updated_at = ma.auto_field(dump_only=True)

    @post_dump()
    def __post_dump(self, data, **kwargs):
        if 'webapps' in data:
            data['webapps'] = list(map(str, data['webapps']))
        if 'addons' in data:
            data['addons'] = list(map(str, data['addons']))

        if (data['uri_template'] is not None) \
                and (isinstance(data['uri_template'], str)) \
                and (len(data['uri_template']) > 0):
            # string =====================> json / object
            data['uri_template'] = json.loads(data['uri_template'])
        return data

    @pre_load()
    def __pre_load(self, data, **kwargs):
        if 'uri_template' in data and data['uri_template'] is not None:
            # ensure uri_template is correct
            variables = data['uri_template']['variables']
            for variable in variables:
                length = variable['length']
                unique = variable['unique']
                src = variable['src']
                if unique and src == 'random':
                    msg = "Uniqueness is not taken into account "\
                          "for a random variable."
                    raise BadRequest(description=msg)
                if unique and length < 16 and src == 'capsule':
                    msg = "Uniqueness of a variable required "\
                          "a length greater or equal to 16."
                    raise BadRequest(description=msg)
            # json / object =====================> string
            data['uri_template'] = json.dumps(data['uri_template'])
        return data
Ejemplo n.º 23
0
class UserSchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = UserModel
        load_instance = True

    username = ma.auto_field(required=True)
    password = ma.auto_field(required=True)
    email = ma.auto_field(required=True)
    isAdmin = ma.auto_field(required=True)
    address = ma.auto_field(required=True)
Ejemplo n.º 24
0
class TileStylesSchema(ma.SQLAlchemySchema):
    class Meta:
        model = TileStyles

    id = ma.auto_field()

    tile = ma.auto_field()

    background = ma.auto_field()
    border = ma.auto_field()
Ejemplo n.º 25
0
class VoucherSchema(ma.SQLAlchemySchema):
    class Meta:
        model = Voucher
        ordered = True

    id = ma.auto_field()
    code = ma.auto_field()
    store_id = ma.auto_field()
    start_date = ma.auto_field()
    end_date = ma.auto_field()
Ejemplo n.º 26
0
class CommentSchema(ma.SQLAlchemySchema):
    class Meta:
        model = CommentModel

    id = ma.auto_field()
    content = ma.auto_field()
    wrote_datetime = ma.auto_field()
    upper_comment_id = ma.auto_field()
    writer = ma.Nested('UserSchema', only=['username'])
    wrote_post = ma.Nested('PostSchema', only=['id'])
Ejemplo n.º 27
0
class SectorSchema(ma.SQLAlchemySchema):
    class Meta:
        model = Sector
        #fields = ("id", "name")

    id = ma.auto_field()
    name = ma.auto_field()
    #industries = ma.auto_field()
    #industries = ma.List(ma.HyperlinkRelated("industryresource", "industry_id"))
    industries = ma.Nested(industries_schema)
Ejemplo n.º 28
0
class ParentSchema(ma.SQLAlchemyAutoSchema):
    id = ma.auto_field()
    name = ma.auto_field()
    createdAt = fields.DateTime(format='%Y-%m-%d %H:%M:%S%z')
    updatedAt = fields.DateTime(format='%Y-%m-%d %H:%M:%S%z')
    child = ma.Nested(ParentChildSchema, many=True)

    class Meta:
        model = Parent
        ordered = True
Ejemplo n.º 29
0
class EmployerSchema(ma.SQLAlchemySchema):
    class Meta:
        model = Employer

    id = ma.auto_field()
    name = ma.auto_field()

    @post_load
    def make_employer(self, data, **kwargs):
        return Employer(**data)
Ejemplo n.º 30
0
class ImageSchema(ma.SQLAlchemySchema):
    class Meta:
        model = ImageModel()

    url = ma.Method(serialize='get_uri', deserialize='get_uri')
    filename = ma.auto_field()
    id = ma.auto_field()

    def get_uri(self, obj):
        return current_app.config["IMAGES_URL"] + obj.filename