Fix: Console outputs suppressed when not in debug mode to fix server errors caused by unnecessary outputs.
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -15,6 +15,7 @@ import lib.argument_validation as av
|
||||
from business_objects.base import Base
|
||||
from business_objects.region import Region
|
||||
from extensions import db
|
||||
from helpers.helper_app import Helper_App
|
||||
# external
|
||||
from typing import ClassVar
|
||||
from flask import jsonify
|
||||
@@ -92,7 +93,7 @@ class Address(db.Model, Base):
|
||||
return jsonify(self.to_json())
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
print(f'{cls.__name__}.from_json: {json}')
|
||||
Helper_App.console_log(f'{cls.__name__}.from_json: {json}')
|
||||
address = cls()
|
||||
address.id_address = json[cls.ATTR_ID_ADDRESS],
|
||||
address.region = Region.from_json(json[cls.FLAG_REGION]),
|
||||
|
||||
@@ -14,6 +14,7 @@ Business object for address region
|
||||
import lib.argument_validation as av
|
||||
from business_objects.base import Base
|
||||
from extensions import db
|
||||
from helpers.helper_app import Helper_App
|
||||
# external
|
||||
from typing import ClassVar
|
||||
|
||||
@@ -61,7 +62,7 @@ class Region(db.Model, Base):
|
||||
}
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
print(f'{cls.__name__}.from_json: {json}')
|
||||
Helper_App.console_log(f'{cls.__name__}.from_json: {json}')
|
||||
plant = cls()
|
||||
plant.id_region = json[cls.ATTR_ID_REGION]
|
||||
plant.code = json[cls.FLAG_CODE]
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -14,6 +14,7 @@ Business object for product
|
||||
import lib.argument_validation as av
|
||||
from business_objects.store.store_base import Store_Base
|
||||
from extensions import db
|
||||
from helpers.helper_app import Helper_App
|
||||
# external
|
||||
from pydantic import BaseModel
|
||||
from typing import ClassVar
|
||||
@@ -73,7 +74,7 @@ class Access_Level(db.Model, Store_Base):
|
||||
}
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
print(f'Access Level.from_json: {json}')
|
||||
Helper_App.console_log(f'Access Level.from_json: {json}')
|
||||
access_level = cls()
|
||||
access_level.id_access_level = json[cls.ATTR_ID_ACCESS_LEVEL],
|
||||
access_level.code = json[cls.FLAG_CODE],
|
||||
|
||||
@@ -27,6 +27,7 @@ from business_objects.store.store_base import Store_Base
|
||||
# from models.model_view_store import Model_View_Store # circular
|
||||
# from datastores.datastore_store import DataStore_Store # circular
|
||||
# from forms import Form_Basket_Add, Form_Basket_Edit # possibly circular
|
||||
from helpers.helper_app import Helper_App
|
||||
# external
|
||||
# from enum import Enum
|
||||
from flask import jsonify
|
||||
@@ -138,8 +139,8 @@ class Basket(Store_Base):
|
||||
quantities_permutation += ','
|
||||
ids_permutation += str(product.get_id_permutation())
|
||||
quantities_permutation += str(basket_item.quantity)
|
||||
print(f'ids_permutation_basket = {ids_permutation}')
|
||||
print(f'quantities_permutation_basket = {quantities_permutation}')
|
||||
Helper_App.console_log(f'ids_permutation_basket = {ids_permutation}')
|
||||
Helper_App.console_log(f'quantities_permutation_basket = {quantities_permutation}')
|
||||
return ids_permutation, quantities_permutation
|
||||
def to_json_list(self):
|
||||
json_list = []
|
||||
@@ -170,7 +171,7 @@ class Basket(Store_Base):
|
||||
def __repr__(self):
|
||||
repr = f'Basket:'
|
||||
for basket_item in self.items:
|
||||
print(f'{basket_item}')
|
||||
Helper_App.console_log(f'{basket_item}')
|
||||
repr = f'{repr}\n{basket_item}'
|
||||
return repr
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ Business object for product image
|
||||
# internal
|
||||
from business_objects.store.store_base import Store_Base
|
||||
from extensions import db
|
||||
from helpers.helper_app import Helper_App
|
||||
import lib.argument_validation as av
|
||||
# external
|
||||
from enum import Enum
|
||||
@@ -79,7 +80,7 @@ class Image(db.Model, Store_Base):
|
||||
"""
|
||||
def from_DB_get_many_product_catalogue(query_row):
|
||||
_m = 'Image.from_DB_get_many_product_catalogue'
|
||||
# print(f'image: {query_row}')
|
||||
# Helper_App.console_log(f'image: {query_row}')
|
||||
image = Image()
|
||||
image.id_image = query_row[0]
|
||||
image.id_product = query_row[1]
|
||||
|
||||
@@ -16,6 +16,7 @@ from business_objects.currency import Currency
|
||||
from business_objects.db_base import Get_Many_Parameters_Base
|
||||
from business_objects.store.store_base import Store_Base
|
||||
from extensions import db
|
||||
from helpers.helper_app import Helper_App
|
||||
# external
|
||||
from pydantic import BaseModel
|
||||
from typing import ClassVar, Optional
|
||||
@@ -89,7 +90,7 @@ class Manufacturing_Purchase_Order(db.Model, Store_Base):
|
||||
}
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
print(f'{cls.__name__}.from_json: {json}')
|
||||
Helper_App.console_log(f'{cls.__name__}.from_json: {json}')
|
||||
manufacturing_purchase_order = cls()
|
||||
manufacturing_purchase_order.id_order = json[cls.ATTR_ID_MANUFACTURING_PURCHASE_ORDER]
|
||||
manufacturing_purchase_order.id_currency = json[cls.ATTR_ID_CURRENCY]
|
||||
@@ -199,7 +200,7 @@ class Manufacturing_Purchase_Order_Product_Link(db.Model, Store_Base):
|
||||
}
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
print(f'{cls.__name__}.from_json: {json}')
|
||||
Helper_App.console_log(f'{cls.__name__}.from_json: {json}')
|
||||
link = cls()
|
||||
link.id_link = json[cls.ATTR_ID_MANUFACTURING_PURCHASE_ORDER_PRODUCT_LINK]
|
||||
link.id_order = json[cls.ATTR_ID_MANUFACTURING_PURCHASE_ORDER]
|
||||
|
||||
@@ -15,6 +15,7 @@ import lib.argument_validation as av
|
||||
from business_objects.address import Address
|
||||
from business_objects.store.store_base import Store_Base
|
||||
from extensions import db
|
||||
from helpers.helper_app import Helper_App
|
||||
# external
|
||||
from typing import ClassVar
|
||||
|
||||
@@ -81,7 +82,7 @@ class Plant(db.Model, Store_Base):
|
||||
}
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
print(f'{cls.__name__}.from_json: {json}')
|
||||
Helper_App.console_log(f'{cls.__name__}.from_json: {json}')
|
||||
plant = cls()
|
||||
plant.id_plant = json[cls.ATTR_ID_PLANT],
|
||||
plant.code = json[cls.FLAG_CODE],
|
||||
|
||||
@@ -28,6 +28,7 @@ from business_objects.store.product_variation_tree import Product_Variation_Tree
|
||||
from extensions import db
|
||||
from forms.base import Form_Base
|
||||
from forms.store.product import Filters_Product
|
||||
from helpers.helper_app import Helper_App
|
||||
# external
|
||||
from dataclasses import dataclass
|
||||
from typing import ClassVar, List
|
||||
@@ -141,7 +142,7 @@ class Product(SQLAlchemy_ABC, Store_Base):
|
||||
"""
|
||||
if self.index_permutation_selected is None:
|
||||
self.index_permutation_selected = self.permutation_index[permutation.id_permutation]
|
||||
print(f'setting selected permutation for product {self.id_product} to {self.index_permutation_selected}') # :\n{self.permutations[self.index_permutation_selected]}
|
||||
Helper_App.console_log(f'setting selected permutation for product {self.id_product} to {self.index_permutation_selected}') # :\n{self.permutations[self.index_permutation_selected]}
|
||||
"""
|
||||
def from_permutations(permutations):
|
||||
_m = 'Product.from_permutations'
|
||||
@@ -273,7 +274,7 @@ class Product(SQLAlchemy_ABC, Store_Base):
|
||||
"""
|
||||
def add_product_variation(self, variation):
|
||||
av.val_instance(variation, 'variation', 'Product.add_product_variation', Product_Variation)
|
||||
# print(f'variation: {variation}')
|
||||
# Helper_App.console_log(f'variation: {variation}')
|
||||
index_permutation = self.permutation_index[variation.id_permutation] # self.get_index_permutation_from_id(variation.id_permutation)
|
||||
self.permutations[index_permutation].add_product_variation(variation)
|
||||
def add_product_price(self, price):
|
||||
@@ -493,7 +494,7 @@ class Parameters_Product(Get_Many_Parameters_Base):
|
||||
has_category_filter = not (form.id_category.data == '0' or form.id_category.data == '' or form.id_category.data is None)
|
||||
has_product_filter = not (form.id_product.data == '0' or form.id_product.data == '' or form.id_product.data is None)
|
||||
get_permutations_stock_below_min = av.input_bool(form.is_out_of_stock.data, "is_out_of_stock", "Parameters_Product.from_form")
|
||||
print(f'form question: {type(form.is_out_of_stock)}\nbool interpretted: {get_permutations_stock_below_min}\ntype form: {type(form)}')
|
||||
Helper_App.console_log(f'form question: {type(form.is_out_of_stock)}\nbool interpretted: {get_permutations_stock_below_min}\ntype form: {type(form)}')
|
||||
return Parameters_Product(
|
||||
get_all_product_category = not has_category_filter,
|
||||
get_inactive_product_category = False,
|
||||
@@ -727,7 +728,7 @@ class Parameters_Product(Get_Many_Parameters_Base):
|
||||
has_category_filter = not (form.id_category.data is None or form.id_category.data == '0' or form.id_category.data == '')
|
||||
has_product_filter = not (form.id_product.data is None or form.id_product.data == '0' or form.id_product.data == '')
|
||||
get_permutations_stock_below_min = av.input_bool(form.is_out_of_stock.data, "is_out_of_stock", "Parameters_Product.from_form")
|
||||
print(f'form question: {type(form.is_out_of_stock)}\nbool interpretted: {get_permutations_stock_below_min}\type form: {type(form)}')
|
||||
Helper_App.console_log(f'form question: {type(form.is_out_of_stock)}\nbool interpretted: {get_permutations_stock_below_min}\type form: {type(form)}')
|
||||
return Parameters_Product(
|
||||
get_all_product_category = not has_category_filter,
|
||||
get_inactive_product_category = False,
|
||||
|
||||
@@ -21,6 +21,7 @@ from business_objects.store.discount import Discount
|
||||
from business_objects.store.stock_item import Stock_Item
|
||||
from business_objects.store.store_base import Store_Base
|
||||
from extensions import db
|
||||
from helpers.helper_app import Helper_App
|
||||
# external
|
||||
from pydantic import BaseModel
|
||||
from typing import ClassVar
|
||||
@@ -101,7 +102,7 @@ class Product_Category(SQLAlchemy_ABC, Store_Base):
|
||||
# self.product_index[Category.key_product_index_from_ids_product_permutation(product.id_product, product.id_permutation)] = len(self.products)
|
||||
try:
|
||||
self.get_index_product(product)
|
||||
print(f'category: {self}')
|
||||
Helper_App.console_log(f'category: {self}')
|
||||
raise ValueError(f"{av.error_msg_str(product, 'product', _m, Product)}\nProduct already in category.")
|
||||
except KeyError:
|
||||
self.product_index[product.id_product] = len(self.products)
|
||||
@@ -141,13 +142,13 @@ class Product_Category(SQLAlchemy_ABC, Store_Base):
|
||||
def get_all_product_variation_trees(self):
|
||||
for product in self.products:
|
||||
if product.has_variations:
|
||||
print(f'product with id:{product.id_product} has variations')
|
||||
Helper_App.console_log(f'product with id:{product.id_product} has variations')
|
||||
product.get_variation_trees()
|
||||
"""
|
||||
def index_product_from_ids_product_permutation(self, id_product, id_permutation):
|
||||
key = Category.key_product_index_from_ids_product_permutation(id_product, id_permutation)
|
||||
print(f'product_index: {self.product_index}')
|
||||
print(f'Key Error: {key}')
|
||||
Helper_App.console_log(f'product_index: {self.product_index}')
|
||||
Helper_App.console_log(f'Key Error: {key}')
|
||||
try:
|
||||
return self.product_index[key]
|
||||
except KeyError:
|
||||
@@ -167,7 +168,7 @@ class Product_Category(SQLAlchemy_ABC, Store_Base):
|
||||
"""
|
||||
def get_permutation_first(self):
|
||||
if not (len(self.products) == 0):
|
||||
print(f'getting first permutation from product')
|
||||
Helper_App.console_log(f'getting first permutation from product')
|
||||
return None if len(self.products) == 0 else self.products[0].get_permutation_selected()
|
||||
"""
|
||||
def is_available(self):
|
||||
@@ -204,7 +205,7 @@ class Product_Category(SQLAlchemy_ABC, Store_Base):
|
||||
}
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
print(f' Category.from_json: {json}')
|
||||
Helper_App.console_log(f' Category.from_json: {json}')
|
||||
category = cls()
|
||||
category.id_category = json[cls.ATTR_ID_PRODUCT_CATEGORY]
|
||||
category.code = json[cls.FLAG_CODE]
|
||||
@@ -382,9 +383,9 @@ class Product_Category_Container(Store_Base):
|
||||
return f'categories: {self.categories}'
|
||||
"""
|
||||
def get_permutation_first(self):
|
||||
print(f'getting first permutation from category list')
|
||||
Helper_App.console_log(f'getting first permutation from category list')
|
||||
if not (len(self.categories) == 0):
|
||||
print(f'getting first permutation from category')
|
||||
Helper_App.console_log(f'getting first permutation from category')
|
||||
return None if len(self.categories) == 0 else self.categories[0].get_permutation_first()
|
||||
"""
|
||||
def get_category_count(self):
|
||||
|
||||
@@ -25,6 +25,7 @@ from business_objects.store.product_variation import Product_Variation
|
||||
from business_objects.store.product_variation_tree import Product_Variation_Tree
|
||||
from business_objects.unit_measurement import Unit_Measurement
|
||||
from extensions import db
|
||||
from helpers.helper_app import Helper_App
|
||||
# external
|
||||
from datetime import datetime, timedelta
|
||||
import locale
|
||||
@@ -142,7 +143,7 @@ class Product_Permutation(db.Model, Store_Base):
|
||||
def from_DB_get_many_product_catalogue(cls, query_row):
|
||||
_m = f'{cls.__name__}.from_DB_get_many_product_catalogue'
|
||||
v_arg_type = 'class attribute'
|
||||
print(f'query_row: {query_row}')
|
||||
Helper_App.console_log(f'query_row: {query_row}')
|
||||
permutation = cls()
|
||||
permutation.id_permutation = query_row[0]
|
||||
permutation.id_product = query_row[1]
|
||||
@@ -469,7 +470,7 @@ class Product_Permutation(db.Model, Store_Base):
|
||||
Product_Permutation.FLAG_QUANTITY_MAX: self.quantity_max,
|
||||
Product_Permutation.FLAG_COST_LOCAL: f"<strong>{self.symbol_currency_cost}</strong>{self.cost_local}"
|
||||
}
|
||||
print('permutation row: ', a)
|
||||
Helper_App.console_log('permutation row: ', a)
|
||||
return a
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import lib.argument_validation as av
|
||||
from business_objects.store.store_base import Store_Base
|
||||
from business_objects.store.product_variation_type import Product_Variation_Type
|
||||
from extensions import db
|
||||
from helpers.helper_app import Helper_App
|
||||
# external
|
||||
from dataclasses import dataclass
|
||||
from typing import ClassVar
|
||||
@@ -201,7 +202,7 @@ class Product_Variation_Container(BaseModel):
|
||||
list_variations = []
|
||||
for variation in self.variations:
|
||||
list_variations.append(variation.to_json_option())
|
||||
print(f'list_variations: {list_variations}')
|
||||
Helper_App.console_log(f'list_variations: {list_variations}')
|
||||
return list_variations
|
||||
def to_list_variation_type_options(self):
|
||||
list_variation_types = []
|
||||
|
||||
@@ -13,6 +13,7 @@ Business object for product
|
||||
# internal
|
||||
from business_objects.store.product_variation import Product_Variation
|
||||
from extensions import db
|
||||
from helpers.helper_app import Helper_App
|
||||
# external
|
||||
|
||||
|
||||
@@ -133,16 +134,16 @@ class Product_Variation_Tree():
|
||||
variations.append(node.variation)
|
||||
return variations
|
||||
def to_preview_str(self):
|
||||
print(f'Product_Variation_Tree.to_preview_str')
|
||||
Helper_App.console_log(f'Product_Variation_Tree.to_preview_str')
|
||||
variations = self.get_product_variations()
|
||||
print(f'variations: {variations}')
|
||||
Helper_App.console_log(f'variations: {variations}')
|
||||
preview_str = ''
|
||||
for variation in variations:
|
||||
is_first = (preview_str == '')
|
||||
preview_str += f'{variation.variation_type.name_singular}: {variation.name}'
|
||||
if is_first:
|
||||
preview_str += '\n'
|
||||
print(f'preview_str: {preview_str}')
|
||||
Helper_App.console_log(f'preview_str: {preview_str}')
|
||||
return preview_str
|
||||
def to_json(self):
|
||||
variations = self.get_product_variations()
|
||||
@@ -179,7 +180,7 @@ class Product_Variation_Container(BaseModel):
|
||||
list_variations = []
|
||||
for variation in self.variations:
|
||||
list_variations.append(variation.to_json_option())
|
||||
print(f'list_variations: {list_variations}')
|
||||
Helper_App.console_log(f'list_variations: {list_variations}')
|
||||
return list_variations
|
||||
def to_list_variation_type_options(self):
|
||||
list_variation_types = []
|
||||
|
||||
@@ -19,6 +19,7 @@ from business_objects.store.product_variation_tree import Product_Variation_Tree
|
||||
from business_objects.store.storage_location import Storage_Location
|
||||
from business_objects.store.store_base import Store_Base
|
||||
from extensions import db
|
||||
from helpers.helper_app import Helper_App
|
||||
# external
|
||||
from dataclasses import dataclass
|
||||
from typing import ClassVar, Optional
|
||||
@@ -106,7 +107,7 @@ class Stock_Item(db.Model, Store_Base):
|
||||
stock_item.id_permutation = json.get(cls.ATTR_ID_PRODUCT_PERMUTATION, 0)
|
||||
stock_item.id_product = json[cls.ATTR_ID_PRODUCT]
|
||||
stock_item.id_category = json[cls.ATTR_ID_PRODUCT_CATEGORY]
|
||||
print(f'json: {json}\nhalf stock item: {stock_item}')
|
||||
Helper_App.console_log(f'json: {json}\nhalf stock item: {stock_item}')
|
||||
stock_item.variation_tree = Product_Variation_Tree.from_json_str(json[cls.FLAG_PRODUCT_VARIATIONS])
|
||||
stock_item.date_purchased = json[cls.FLAG_DATE_PURCHASED]
|
||||
stock_item.date_received = json[cls.FLAG_DATE_RECEIVED]
|
||||
|
||||
@@ -15,6 +15,7 @@ import lib.argument_validation as av
|
||||
from business_objects.store.plant import Plant
|
||||
from business_objects.store.store_base import Store_Base
|
||||
from extensions import db
|
||||
from helpers.helper_app import Helper_App
|
||||
# external
|
||||
from typing import ClassVar
|
||||
|
||||
@@ -74,7 +75,7 @@ class Storage_Location(db.Model, Store_Base):
|
||||
}
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
print(f'{cls.__name__}.from_json: {json}')
|
||||
Helper_App.console_log(f'{cls.__name__}.from_json: {json}')
|
||||
location = cls()
|
||||
location.id_location = json[cls.ATTR_ID_STORAGE_LOCATION],
|
||||
location.id_plant = json[cls.ATTR_ID_PLANT],
|
||||
|
||||
@@ -15,7 +15,7 @@ import lib.argument_validation as av
|
||||
from lib import data_types
|
||||
from forms.forms import Form_Basket_Add, Form_Basket_Edit # Form_Product
|
||||
from extensions import db
|
||||
|
||||
from helpers.helper_app import Helper_App
|
||||
# external
|
||||
from datetime import datetime, timedelta
|
||||
import locale
|
||||
@@ -61,7 +61,7 @@ class Stripe_Product(db.Model):
|
||||
av.val_str(id_stripe_product, 'id_stripe_product', _m, max_len=100, v_arg_type=v_arg_type)
|
||||
av.val_str(id_stripe_price, 'id_stripe_price', _m, max_len=100, v_arg_type=v_arg_type)
|
||||
av.full_val_bool(is_subscription, 'is_subscription', _m, v_arg_type=v_arg_type)
|
||||
print(f'is_subscription: {is_subscription}, {av.input_bool(is_subscription, "is_subscription", _m, v_arg_type=v_arg_type)}')
|
||||
Helper_App.console_log(f'is_subscription: {is_subscription}, {av.input_bool(is_subscription, "is_subscription", _m, v_arg_type=v_arg_type)}')
|
||||
is_subscription = av.input_bool(is_subscription, "is_subscription", _m, v_arg_type=v_arg_type)
|
||||
if is_subscription:
|
||||
av.val_str(name_recurring_interval, 'name_recurring_interval', _m, max_len=255, v_arg_type=v_arg_type)
|
||||
|
||||
@@ -17,6 +17,7 @@ from business_objects.currency import Currency
|
||||
from business_objects.db_base import Get_Many_Parameters_Base
|
||||
from business_objects.store.store_base import Store_Base
|
||||
from extensions import db
|
||||
from helpers.helper_app import Helper_App
|
||||
# external
|
||||
from pydantic import BaseModel
|
||||
from typing import ClassVar
|
||||
@@ -106,7 +107,7 @@ addresses: {self.addresses}
|
||||
}
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
print(f'{cls.__name__}.from_json: {json}')
|
||||
Helper_App.console_log(f'{cls.__name__}.from_json: {json}')
|
||||
supplier = cls()
|
||||
supplier.id_supplier = json[cls.ATTR_ID_SUPPLIER]
|
||||
supplier.id_currency = json[cls.ATTR_ID_CURRENCY]
|
||||
|
||||
@@ -15,6 +15,7 @@ import lib.argument_validation as av
|
||||
from business_objects.store.store_base import Store_Base
|
||||
from business_objects.region import Region
|
||||
from extensions import db
|
||||
from helpers.helper_app import Helper_App
|
||||
# external
|
||||
from typing import ClassVar
|
||||
from flask import jsonify
|
||||
@@ -71,7 +72,7 @@ class Supplier_Address(db.Model, Store_Base):
|
||||
{self.FLAG_ACTIVE}: {self.active}
|
||||
'''
|
||||
def to_json(self):
|
||||
print(f'{self.__class__.__name__}.to_json\n{self.__dict__}\n{self}')
|
||||
Helper_App.console_log(f'{self.__class__.__name__}.to_json\n{self.__dict__}\n{self}')
|
||||
return {
|
||||
**self.get_shared_json_attributes(self),
|
||||
self.ATTR_ID_ADDRESS: self.id_address,
|
||||
@@ -88,7 +89,7 @@ class Supplier_Address(db.Model, Store_Base):
|
||||
return jsonify(self.to_json())
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
print(f'{cls.__name__}.from_json: {json}')
|
||||
Helper_App.console_log(f'{cls.__name__}.from_json: {json}')
|
||||
address = cls()
|
||||
address.id_address = json[cls.ATTR_ID_ADDRESS]
|
||||
address.id_supplier = json[cls.ATTR_ID_SUPPLIER]
|
||||
|
||||
@@ -17,6 +17,7 @@ from business_objects.db_base import Get_Many_Parameters_Base
|
||||
from business_objects.store.store_base import Store_Base
|
||||
from business_objects.store.supplier import Supplier
|
||||
from extensions import db
|
||||
from helpers.helper_app import Helper_App
|
||||
# external
|
||||
from pydantic import BaseModel
|
||||
from typing import ClassVar, Optional
|
||||
@@ -92,7 +93,7 @@ class Supplier_Purchase_Order(db.Model, Store_Base):
|
||||
}
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
print(f'{cls.__name__}.from_json: {json}')
|
||||
Helper_App.console_log(f'{cls.__name__}.from_json: {json}')
|
||||
supplier_purchase_order = cls()
|
||||
supplier_purchase_order.id_order = json[cls.ATTR_ID_SUPPLIER_PURCHASE_ORDER]
|
||||
supplier_purchase_order.id_supplier = json[cls.ATTR_ID_SUPPLIER]
|
||||
@@ -197,7 +198,7 @@ class Supplier_Purchase_Order_Product_Link(db.Model, Store_Base):
|
||||
}
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
print(f'{cls.__name__}.from_json: {json}')
|
||||
Helper_App.console_log(f'{cls.__name__}.from_json: {json}')
|
||||
link = cls()
|
||||
link.id_link = json[cls.ATTR_ID_SUPPLIER_PURCHASE_ORDER_PRODUCT_LINK]
|
||||
link.id_order = json[cls.ATTR_ID_SUPPLIER_PURCHASE_ORDER]
|
||||
|
||||
@@ -12,6 +12,7 @@ from business_objects.base import Base
|
||||
from business_objects.db_base import SQLAlchemy_ABC, Get_Many_Parameters_Base
|
||||
from extensions import db
|
||||
# from forms.forms import Form_Filters_User
|
||||
from helpers.helper_app import Helper_App
|
||||
import lib.argument_validation as av
|
||||
# external
|
||||
from dataclasses import dataclass
|
||||
@@ -78,7 +79,7 @@ class Unit_Measurement(SQLAlchemy_ABC, Base):
|
||||
}
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
print(f' Unit_Measurement.from_json: {json}')
|
||||
Helper_App.console_log(f' Unit_Measurement.from_json: {json}')
|
||||
unit = cls()
|
||||
unit.id_unit_measurement = json[cls.ATTR_ID_UNIT_MEASUREMENT]
|
||||
unit.name_singular = json[cls.FLAG_NAME_SINGULAR]
|
||||
|
||||
@@ -12,6 +12,7 @@ from business_objects.base import Base
|
||||
import lib.argument_validation as av
|
||||
from forms.forms import Form_Filters_User
|
||||
from extensions import db
|
||||
from helpers.helper_app import Helper_App
|
||||
# external
|
||||
from dataclasses import dataclass
|
||||
from typing import ClassVar
|
||||
@@ -64,7 +65,7 @@ class User(db.Model, Base):
|
||||
_m = 'User.from_json'
|
||||
user = User()
|
||||
if json is None: return user
|
||||
print(f'{_m}\njson: {json}')
|
||||
Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
user.id_user = json['id_user']
|
||||
user.id_user_auth0 = json['id_user_auth0']
|
||||
user.firstname = json['firstname']
|
||||
@@ -78,16 +79,16 @@ class User(db.Model, Base):
|
||||
user.can_admin_store = av.input_bool(json['can_admin_store'], 'can_admin_store', _m)
|
||||
user.can_admin_user = av.input_bool(json['can_admin_user'], 'can_admin_user', _m)
|
||||
user.is_logged_in = (user.id_user_auth0 is not None)
|
||||
print(f'user: {user}')
|
||||
Helper_App.console_log(f'user: {user}')
|
||||
return user
|
||||
|
||||
# print(f'user: {user}')
|
||||
# Helper_App.console_log(f'user: {user}')
|
||||
@staticmethod
|
||||
def from_json_auth0(json):
|
||||
_m = 'User.from_json_auth0'
|
||||
user = User()
|
||||
if json is None: return user
|
||||
print(f'{_m}\njson: {json}')
|
||||
Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
user_info = json['userinfo']
|
||||
user.id_user = None
|
||||
user.id_user_auth0 = user_info['sub']
|
||||
@@ -102,7 +103,7 @@ class User(db.Model, Base):
|
||||
user.can_admin_store = None
|
||||
user.can_admin_user = None
|
||||
user.is_logged_in = (user.id_user_auth0 is not None and user.id_user_auth0 != '')
|
||||
print(f'user: {user}')
|
||||
Helper_App.console_log(f'user: {user}')
|
||||
return user
|
||||
|
||||
def to_json(self):
|
||||
@@ -120,7 +121,7 @@ class User(db.Model, Base):
|
||||
'can_admin_store': self.can_admin_store,
|
||||
'can_admin_user': self.can_admin_user
|
||||
}
|
||||
print(f'as_json: {as_json}')
|
||||
Helper_App.console_log(f'as_json: {as_json}')
|
||||
return as_json
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
Reference in New Issue
Block a user