diff --git a/reqs/app.in b/reqs/app.in index 80ebe50..e56dc32 100644 Binary files a/reqs/app.in and b/reqs/app.in differ diff --git a/reqs/app.txt b/reqs/app.txt index 7936622..6c215c9 100644 --- a/reqs/app.txt +++ b/reqs/app.txt @@ -32,7 +32,7 @@ flask-login==0.6.2 # shopyo flask-mailman==0.3.0 # via shopyo -flask-marshmallow==0.14.0 +flask-marshmallow==1.0.0 # via shopyo flask-migrate==3.1.0 # via shopyo @@ -71,7 +71,9 @@ marshmallow==3.14.1 # marshmallow-sqlalchemy # shopyo marshmallow-sqlalchemy==0.26.1 - # via shopyo + # via + # -r reqs/app.in + # shopyo mkdocs-material-extensions==1.0.3 # via flask-mailman numpy==2.1.1 @@ -80,6 +82,8 @@ numpy==2.1.1 # pandas openpyxl==3.0.10 # via -r reqs/app.in +packaging==24.1 + # via flask-marshmallow pandas==2.2.2 # via -r reqs/app.in pillow==10.4.0 @@ -95,9 +99,7 @@ pytz==2022.2.1 shopyo==4.8.6 # via pythoncms six==1.16.0 - # via - # flask-marshmallow - # python-dateutil + # via python-dateutil sqlalchemy==1.4.46 # via # alembic diff --git a/src/shopcube/init.py b/src/shopcube/init.py index ae50082..8b4b566 100644 --- a/src/shopcube/init.py +++ b/src/shopcube/init.py @@ -5,7 +5,6 @@ from flask_login import LoginManager from flask_mailman import Mail -#from flask_marshmallow import Marshmallow from flask_migrate import Migrate from flask_sqlalchemy import SQLAlchemy from flask_uploads import DOCUMENTS @@ -21,9 +20,7 @@ installed_packages = [] db = SQLAlchemy() -# ma = Marshmallow() - -ma = None + login_manager = LoginManager() migrate = Migrate() mail = Mail() @@ -46,7 +43,6 @@ def configure_all_uploads(app): def load_extensions(app): migrate.init_app(app, db) db.init_app(app) - # ma.init_app(app) mail.init_app(app) login_manager.init_app(app) csrf.init_app(app) diff --git a/src/shopcube/modules/box__ecommerce/product/view.py b/src/shopcube/modules/box__ecommerce/product/view.py index ba9651c..73f1280 100644 --- a/src/shopcube/modules/box__ecommerce/product/view.py +++ b/src/shopcube/modules/box__ecommerce/product/view.py @@ -19,7 +19,6 @@ from werkzeug.utils import secure_filename from init import db -from init import ma from init import productphotos from modules.box__ecommerce.category.models import SubCategory @@ -28,6 +27,9 @@ from modules.box__ecommerce.product.models import Size from modules.resource.models import Resource +from marshmallow_sqlalchemy import SQLAlchemySchema, auto_field + + dirpath = os.path.dirname(os.path.abspath(__file__)) module_info = {} @@ -42,23 +44,23 @@ url_prefix=module_info["url_prefix"], ) - -class Productchema(ma.Schema): +class ProductSchema(SQLAlchemySchema): class Meta: - # Fields to expose - fields = ( - "barcode", - "name", - "description", - "price", - "selling_price", - "in_stock", - "discontinued", - ) + model = Product + load_instance = True # Optional: deserialize to model instances + + barcode = auto_field() + name = auto_field() + description = auto_field() + price = auto_field() + selling_price = auto_field() + in_stock = auto_field() + discontinued = auto_field() + -product_schema = Productchema() -product_schema = Productchema(many=True) +product_schema = ProductSchema() +product_schema = ProductSchema(many=True) module_blueprint = globals()["{}_blueprint".format(module_info["module_name"])]