diff --git a/app.log.1 b/app.log.1 index 6569f8a3..5478ae66 100644 --- a/app.log.1 +++ b/app.log.1 @@ -1,110 +1,50 @@ -User.from_json -json: {'can_admin_store': True, 'can_admin_user': True, 'email': 'edward.middletonsmith@gmail.com', 'firstname': 'Teddy', 'id_currency_default': None, 'id_region_default': None, 'id_user': 1, 'id_user_auth0': 'auth0|6582b95c895d09a70ba10fef', 'is_email_verified': False, 'is_included_VAT_default': True, 'is_super_user': True, 'surname': 'Middleton-Smith'} -user: - id_user: 1 - id_user_auth0: auth0|6582b95c895d09a70ba10fef - firstname: Teddy - surname: Middleton-Smith - email: edward.middletonsmith@gmail.com - is_email_verified: False - is_super_user: True - id_currency_default: None - id_region_default: None - is_included_VAT_default: True - can_admin_store: True - can_admin_user: True - -argument_dict: {'a_id_user': 1, 'a_id_user_auth0': 'auth0|6582b95c895d09a70ba10fef', 'get_all_user': False, 'get_inactive_user': False, 'ids_user': 1, 'ids_user_auth0': '', 'a_debug': 0} -executing p_get_many_user -DataStore_Base.db_procedure_execute -proc_string: CALL p_get_many_user(:a_id_user, :a_id_user_auth0, :get_all_user, :get_inactive_user, :ids_user, :ids_user_auth0, :a_debug) -args: {'a_id_user': 1, 'a_id_user_auth0': 'auth0|6582b95c895d09a70ba10fef', 'get_all_user': False, 'get_inactive_user': False, 'ids_user': 1, 'ids_user_auth0': '', 'a_debug': 0} -result: -data received -raw users: ((1, 'auth0|6582b95c895d09a70ba10fef', 'Teddy', 'Middleton-Smith', 'edward.middletonsmith@gmail.com', b'\x00', None, None, b'\x01', b'\x01', b'\x01', b'\x01', b'\x00'),) +raw units of measurement: ((1, 'metre', 'metres', 'm', b'\x01', b'\x01', b'\x01', b'\x00', b'\x00', b'\x00', b'\x01'), (2, 'millimetre', 'millimetres', 'mm', b'\x01', b'\x00', b'\x01', b'\x00', b'\x00', b'\x00', b'\x01'), (3, 'kilogram', 'kilograms', 'kg', b'\x01', b'\x01', b'\x00', b'\x01', b'\x00', b'\x00', b'\x01'), (4, 'gram', 'grams', 'g', b'\x01', b'\x00', b'\x00', b'\x01', b'\x00', b'\x00', b'\x01'), (5, 'litre', 'litres', 'L', b'\x01', b'\x00', b'\x00', b'\x00', b'\x00', b'\x01', b'\x01'), (6, 'millilitre', 'millilitres', 'mL', b'\x01', b'\x00', b'\x00', b'\x00', b'\x00', b'\x01', b'\x01'), (7, 'item', 'items', 'x', b'\x01', b'\x00', b'\x00', b'\x00', b'\x00', b'\x00', b'\x01'), (8, 'hour', 'hours', 'h', b'\x01', b'\x01', b'\x00', b'\x00', b'\x01', b'\x00', b'\x01'), (9, 'day', 'days', 'd', b'\x01', b'\x00', b'\x00', b'\x00', b'\x01', b'\x00', b'\x01')) raw errors: () +executing p_shop_get_many_currency +DataStore_Base.db_procedure_execute +proc_string: CALL p_shop_get_many_currency(:a_get_inactive_currency) +args: {'a_get_inactive_currency': 0} +result: +data received +currencies: [ + id: 1 + name: Great British Pound + code: GBP + symbol: £ + factor from GBP: 1.0 + display_order: 1 + active: True + , + id: 2 + name: Euro + code: EUR + symbol: € + factor from GBP: 1.17 + display_order: 2 + active: True + ] new result set: () -model_view_base init end - model.user: - id_user: 1 - id_user_auth0: auth0|6582b95c895d09a70ba10fef - firstname: Teddy - surname: Middleton-Smith - email: edward.middletonsmith@gmail.com - is_email_verified: False - is_super_user: True - id_currency_default: None - id_region_default: None - is_included_VAT_default: True - can_admin_store: True - can_admin_user: True - -argument_dict: {'active': 1} -executing p_shop_get_many_access_level -DataStore_Base.db_procedure_execute -proc_string: CALL p_shop_get_many_access_level(:active) -args: {'active': 1} -result: -data received -raw access levels: ((1, 'VIEW', 'View', 3, 1, b'\x01'), (2, 'EDIT', 'Edit', 2, 2, b'\x01'), (3, 'ADMIN', 'Admin', 1, 3, b'\x01')) -raw errors: () -DataStore_Base.get_user_session -User.from_json -json: {'can_admin_store': True, 'can_admin_user': True, 'email': 'edward.middletonsmith@gmail.com', 'firstname': 'Teddy', 'id_currency_default': None, 'id_region_default': None, 'id_user': 1, 'id_user_auth0': 'auth0|6582b95c895d09a70ba10fef', 'is_email_verified': False, 'is_included_VAT_default': True, 'is_super_user': True, 'surname': 'Middleton-Smith'} -user: - id_user: 1 - id_user_auth0: auth0|6582b95c895d09a70ba10fef - firstname: Teddy - surname: Middleton-Smith - email: edward.middletonsmith@gmail.com - is_email_verified: False - is_super_user: True - id_currency_default: None - id_region_default: None - is_included_VAT_default: True - can_admin_store: True - can_admin_user: True - -User.from_json -json: {'can_admin_store': True, 'can_admin_user': True, 'email': 'edward.middletonsmith@gmail.com', 'firstname': 'Teddy', 'id_currency_default': None, 'id_region_default': None, 'id_user': 1, 'id_user_auth0': 'auth0|6582b95c895d09a70ba10fef', 'is_email_verified': False, 'is_included_VAT_default': True, 'is_super_user': True, 'surname': 'Middleton-Smith'} -user: - id_user: 1 - id_user_auth0: auth0|6582b95c895d09a70ba10fef - firstname: Teddy - surname: Middleton-Smith - email: edward.middletonsmith@gmail.com - is_email_verified: False - is_super_user: True - id_currency_default: None - id_region_default: None - is_included_VAT_default: True - can_admin_store: True - can_admin_user: True - -argument_dict: {'a_id_user': 1, 'a_id_user_auth0': 'auth0|6582b95c895d09a70ba10fef', 'get_all_user': False, 'get_inactive_user': False, 'ids_user': 1, 'ids_user_auth0': '', 'a_debug': 0} -executing p_get_many_user -DataStore_Base.db_procedure_execute -proc_string: CALL p_get_many_user(:a_id_user, :a_id_user_auth0, :get_all_user, :get_inactive_user, :ids_user, :ids_user_auth0, :a_debug) -args: {'a_id_user': 1, 'a_id_user_auth0': 'auth0|6582b95c895d09a70ba10fef', 'get_all_user': False, 'get_inactive_user': False, 'ids_user': 1, 'ids_user_auth0': '', 'a_debug': 0} -result: -data received -raw users: ((1, 'auth0|6582b95c895d09a70ba10fef', 'Teddy', 'Middleton-Smith', 'edward.middletonsmith@gmail.com', b'\x00', None, None, b'\x01', b'\x01', b'\x01', b'\x01', b'\x00'),) -raw errors: () -new result set: () -argument_dict: {'a_id_user': 1, 'a_get_all_product_category': True, 'a_get_inactive_product_category': False, 'a_ids_product_category': '', 'a_get_all_product': True, 'a_get_inactive_product': False, 'a_ids_product': '', 'a_get_all_permutation': True, 'a_get_inactive_permutation': False, 'a_ids_permutation': '', 'a_get_all_image': False, 'a_get_inactive_image': False, 'a_ids_image': '', 'a_get_products_quantity_stock_below_min': False, 'a_debug': 0} -executing p_shop_get_many_product -DataStore_Base.db_procedure_execute -proc_string: CALL p_shop_get_many_product(:a_id_user, :a_get_all_product_category, :a_get_inactive_product_category, :a_ids_product_category, :a_get_all_product, :a_get_inactive_product, :a_ids_product, :a_get_all_permutation, :a_get_inactive_permutation, :a_ids_permutation, :a_get_all_image, :a_get_inactive_image, :a_ids_image, :a_get_products_quantity_stock_below_min, :a_debug) -args: {'a_id_user': 1, 'a_get_all_product_category': True, 'a_get_inactive_product_category': False, 'a_ids_product_category': '', 'a_get_all_product': True, 'a_get_inactive_product': False, 'a_ids_product': '', 'a_get_all_permutation': True, 'a_get_inactive_permutation': False, 'a_ids_permutation': '', 'a_get_all_image': False, 'a_get_inactive_image': False, 'a_ids_image': '', 'a_get_products_quantity_stock_below_min': False, 'a_debug': 0} -result: -data received -initial category_list: categories: [] -raw categories: () -category-loaded category_list: categories: [] -raw products: () -raw errors: () -new result set: () -get many category_list: categories: [] +{1: {'NAME_ATTR_OPTION_TEXT': 'name_singular', 'NAME_ATTR_OPTION_VALUE': 'id_unit_measurement', 'id_unit_measurement': 1, 'name_singular': 'metre', 'name_plural': 'metres', 'symbol': 'm', 'symbol_is_suffix_not_prefix': True, 'is_base_unit': True, 'is_unit_of_distance': True, 'is_unit_of_mass': False, 'is_unit_of_time': False, 'is_unit_of_volume': False, 'active': True}, 2: {'NAME_ATTR_OPTION_TEXT': 'name_singular', 'NAME_ATTR_OPTION_VALUE': 'id_unit_measurement', 'id_unit_measurement': 2, 'name_singular': 'millimetre', 'name_plural': 'millimetres', 'symbol': 'mm', 'symbol_is_suffix_not_prefix': True, 'is_base_unit': False, 'is_unit_of_distance': True, 'is_unit_of_mass': False, 'is_unit_of_time': False, 'is_unit_of_volume': False, 'active': True}, 3: {'NAME_ATTR_OPTION_TEXT': 'name_singular', 'NAME_ATTR_OPTION_VALUE': 'id_unit_measurement', 'id_unit_measurement': 3, 'name_singular': 'kilogram', 'name_plural': 'kilograms', 'symbol': 'kg', 'symbol_is_suffix_not_prefix': True, 'is_base_unit': True, 'is_unit_of_distance': False, 'is_unit_of_mass': True, 'is_unit_of_time': False, 'is_unit_of_volume': False, 'active': True}, 4: {'NAME_ATTR_OPTION_TEXT': 'name_singular', 'NAME_ATTR_OPTION_VALUE': 'id_unit_measurement', 'id_unit_measurement': 4, 'name_singular': 'gram', 'name_plural': 'grams', 'symbol': 'g', 'symbol_is_suffix_not_prefix': True, 'is_base_unit': False, 'is_unit_of_distance': False, 'is_unit_of_mass': True, 'is_unit_of_time': False, 'is_unit_of_volume': False, 'active': True}, 5: {'NAME_ATTR_OPTION_TEXT': 'name_singular', 'NAME_ATTR_OPTION_VALUE': 'id_unit_measurement', 'id_unit_measurement': 5, 'name_singular': 'litre', 'name_plural': 'litres', 'symbol': 'L', 'symbol_is_suffix_not_prefix': True, 'is_base_unit': False, 'is_unit_of_distance': False, 'is_unit_of_mass': False, 'is_unit_of_time': False, 'is_unit_of_volume': True, 'active': True}, 6: {'NAME_ATTR_OPTION_TEXT': 'name_singular', 'NAME_ATTR_OPTION_VALUE': 'id_unit_measurement', 'id_unit_measurement': 6, 'name_singular': 'millilitre', 'name_plural': 'millilitres', 'symbol': 'mL', 'symbol_is_suffix_not_prefix': True, 'is_base_unit': False, 'is_unit_of_distance': False, 'is_unit_of_mass': False, 'is_unit_of_time': False, 'is_unit_of_volume': True, 'active': True}, 7: {'NAME_ATTR_OPTION_TEXT': 'name_singular', 'NAME_ATTR_OPTION_VALUE': 'id_unit_measurement', 'id_unit_measurement': 7, 'name_singular': 'item', 'name_plural': 'items', 'symbol': 'x', 'symbol_is_suffix_not_prefix': True, 'is_base_unit': False, 'is_unit_of_distance': False, 'is_unit_of_mass': False, 'is_unit_of_time': False, 'is_unit_of_volume': False, 'active': True}, 8: {'NAME_ATTR_OPTION_TEXT': 'name_singular', 'NAME_ATTR_OPTION_VALUE': 'id_unit_measurement', 'id_unit_measurement': 8, 'name_singular': 'hour', 'name_plural': 'hours', 'symbol': 'h', 'symbol_is_suffix_not_prefix': True, 'is_base_unit': True, 'is_unit_of_distance': False, 'is_unit_of_mass': False, 'is_unit_of_time': True, 'is_unit_of_volume': False, 'active': True}, 9: {'NAME_ATTR_OPTION_TEXT': 'name_singular', 'NAME_ATTR_OPTION_VALUE': 'id_unit_measurement', 'id_unit_measurement': 9, 'name_singular': 'day', 'name_plural': 'days', 'symbol': 'd', 'symbol_is_suffix_not_prefix': True, 'is_base_unit': False, 'is_unit_of_distance': False, 'is_unit_of_mass': False, 'is_unit_of_time': True, 'is_unit_of_volume': False, 'active': True}} +{8: {'NAME_ATTR_OPTION_TEXT': 'name_singular', 'NAME_ATTR_OPTION_VALUE': 'id_unit_measurement', 'id_unit_measurement': 8, 'name_singular': 'hour', 'name_plural': 'hours', 'symbol': 'h', 'symbol_is_suffix_not_prefix': True, 'is_base_unit': True, 'is_unit_of_distance': False, 'is_unit_of_mass': False, 'is_unit_of_time': True, 'is_unit_of_volume': False, 'active': True}, 9: {'NAME_ATTR_OPTION_TEXT': 'name_singular', 'NAME_ATTR_OPTION_VALUE': 'id_unit_measurement', 'id_unit_measurement': 9, 'name_singular': 'day', 'name_plural': 'days', 'symbol': 'd', 'symbol_is_suffix_not_prefix': True, 'is_base_unit': False, 'is_unit_of_distance': False, 'is_unit_of_mass': False, 'is_unit_of_time': True, 'is_unit_of_volume': False, 'active': True}} Model_View_Store.__init__ starting session: DataStore_Base.get_user_session +User.from_json +json: {'can_admin_store': True, 'can_admin_user': True, 'email': 'edward.middletonsmith@gmail.com', 'firstname': 'Teddy', 'id_currency_default': None, 'id_region_default': None, 'id_user': 1, 'id_user_auth0': 'auth0|6582b95c895d09a70ba10fef', 'is_email_verified': False, 'is_included_VAT_default': True, 'is_super_user': True, 'surname': 'Middleton-Smith'} +user: + id_user: 1 + id_user_auth0: auth0|6582b95c895d09a70ba10fef + firstname: Teddy + surname: Middleton-Smith + email: edward.middletonsmith@gmail.com + is_email_verified: False + is_super_user: True + id_currency_default: None + id_region_default: None + is_included_VAT_default: True + can_admin_store: True + can_admin_user: True + +User.from_json +json: {'can_admin_store': True, 'can_admin_user': True, 'email': 'edward.middletonsmith@gmail.com', 'firstname': 'Teddy', 'id_currency_default': None, 'id_region_default': None, 'id_user': 1, 'id_user_auth0': 'auth0|6582b95c895d09a70ba10fef', 'is_email_verified': False, 'is_included_VAT_default': True, 'is_super_user': True, 'surname': 'Middleton-Smith'} diff --git a/app.log.2 b/app.log.2 index 90e7a1db..dde08f22 100644 --- a/app.log.2 +++ b/app.log.2 @@ -1,4 +1,123 @@ -session: +User.from_json +json: {'can_admin_store': True, 'can_admin_user': True, 'email': 'edward.middletonsmith@gmail.com', 'firstname': 'Teddy', 'id_currency_default': None, 'id_region_default': None, 'id_user': 1, 'id_user_auth0': 'auth0|6582b95c895d09a70ba10fef', 'is_email_verified': False, 'is_included_VAT_default': True, 'is_super_user': True, 'surname': 'Middleton-Smith'} +user: + id_user: 1 + id_user_auth0: auth0|6582b95c895d09a70ba10fef + firstname: Teddy + surname: Middleton-Smith + email: edward.middletonsmith@gmail.com + is_email_verified: False + is_super_user: True + id_currency_default: None + id_region_default: None + is_included_VAT_default: True + can_admin_store: True + can_admin_user: True + +argument_dict: {'a_id_user': 1, 'a_id_user_auth0': 'auth0|6582b95c895d09a70ba10fef', 'get_all_user': False, 'get_inactive_user': False, 'ids_user': 1, 'ids_user_auth0': '', 'a_debug': 0} +executing p_get_many_user +DataStore_Base.db_procedure_execute +proc_string: CALL p_get_many_user(:a_id_user, :a_id_user_auth0, :get_all_user, :get_inactive_user, :ids_user, :ids_user_auth0, :a_debug) +args: {'a_id_user': 1, 'a_id_user_auth0': 'auth0|6582b95c895d09a70ba10fef', 'get_all_user': False, 'get_inactive_user': False, 'ids_user': 1, 'ids_user_auth0': '', 'a_debug': 0} +result: +data received +raw users: ((1, 'auth0|6582b95c895d09a70ba10fef', 'Teddy', 'Middleton-Smith', 'edward.middletonsmith@gmail.com', b'\x00', None, None, b'\x01', b'\x01', b'\x01', b'\x01', b'\x00'),) +raw errors: () +new result set: () +argument_dict: {'a_id_user': 1, 'a_get_all_product_category': True, 'a_get_inactive_product_category': False, 'a_ids_product_category': '', 'a_get_all_product': True, 'a_get_inactive_product': False, 'a_ids_product': '', 'a_get_all_permutation': True, 'a_get_inactive_permutation': False, 'a_ids_permutation': '', 'a_get_all_image': False, 'a_get_inactive_image': False, 'a_ids_image': '', 'a_get_products_quantity_stock_below_min': False, 'a_debug': 0} +executing p_shop_get_many_product +DataStore_Base.db_procedure_execute +proc_string: CALL p_shop_get_many_product(:a_id_user, :a_get_all_product_category, :a_get_inactive_product_category, :a_ids_product_category, :a_get_all_product, :a_get_inactive_product, :a_ids_product, :a_get_all_permutation, :a_get_inactive_permutation, :a_ids_permutation, :a_get_all_image, :a_get_inactive_image, :a_ids_image, :a_get_products_quantity_stock_below_min, :a_debug) +args: {'a_id_user': 1, 'a_get_all_product_category': True, 'a_get_inactive_product_category': False, 'a_ids_product_category': '', 'a_get_all_product': True, 'a_get_inactive_product': False, 'a_ids_product': '', 'a_get_all_permutation': True, 'a_get_inactive_permutation': False, 'a_ids_permutation': '', 'a_get_all_image': False, 'a_get_inactive_image': False, 'a_ids_image': '', 'a_get_products_quantity_stock_below_min': False, 'a_debug': 0} +result: +data received +initial category_list: categories: [] +raw categories: ((4, 'CHOCOLATE', 'Chocolates and sweets', 'Confectionery', 1, 'View', 1, b'\x01', None, None, None),) +new_category: + id: 4 + code: CHOCOLATE + name: Chocolates and sweets + description: Confectionery + access_level: View + display_order: 1 + active: True + products: [] + +category-loaded category_list: categories: [ + id: 4 + code: CHOCOLATE + name: Chocolates and sweets + description: Confectionery + access_level: View + display_order: 1 + active: True + products: [] + ] +raw products: ((6, 4, 'Digestives', b'\x01', 1, 'View', b'\x01', 1, None, None, None),) +row: (6, 4, 'Digestives', b'\x01', 1, 'View', b'\x01', 1, None, None, None) +new_product: Product + id_product: 6 + id_category: 4 + name: Digestives + display_order: 1 + can_view: False + can_edit: False + can_admin: False + has_variations: True + permutations: [] + variation trees: [] + active: True + +raw errors: () +product with id:6 has variations +new result set: () +get many category_list: categories: [ + id: 4 + code: CHOCOLATE + name: Chocolates and sweets + description: Confectionery + access_level: View + display_order: 1 + active: True + products: [Product + id_product: 6 + id_category: 4 + name: Digestives + display_order: 1 + can_view: False + can_edit: False + can_admin: False + has_variations: True + permutations: [] + variation trees: [] + active: True + ] + ] +category filters: [ + id: 4 + code: CHOCOLATE + name: Chocolates and sweets + description: Confectionery + access_level: View + display_order: 1 + active: True + products: [Product + id_product: 6 + id_category: 4 + name: Digestives + display_order: 1 + can_view: False + can_edit: False + can_admin: False + has_variations: True + permutations: [] + variation trees: [] + active: True + ] + ] +category options: [('', ''), ('4', 'Chocolates and sweets')] +product options: [{'value': 6, 'text': 'Digestives', 'id_category': 4}] +DataStore_Store_Base.get_many_product_variation DataStore_Base.get_user_session User.from_json json: {'can_admin_store': True, 'can_admin_user': True, 'email': 'edward.middletonsmith@gmail.com', 'firstname': 'Teddy', 'id_currency_default': None, 'id_region_default': None, 'id_user': 1, 'id_user_auth0': 'auth0|6582b95c895d09a70ba10fef', 'is_email_verified': False, 'is_included_VAT_default': True, 'is_super_user': True, 'surname': 'Middleton-Smith'} @@ -37,47 +156,22 @@ executing p_get_many_user DataStore_Base.db_procedure_execute proc_string: CALL p_get_many_user(:a_id_user, :a_id_user_auth0, :get_all_user, :get_inactive_user, :ids_user, :ids_user_auth0, :a_debug) args: {'a_id_user': 1, 'a_id_user_auth0': 'auth0|6582b95c895d09a70ba10fef', 'get_all_user': False, 'get_inactive_user': False, 'ids_user': 1, 'ids_user_auth0': '', 'a_debug': 0} -result: +result: data received raw users: ((1, 'auth0|6582b95c895d09a70ba10fef', 'Teddy', 'Middleton-Smith', 'edward.middletonsmith@gmail.com', b'\x00', None, None, b'\x01', b'\x01', b'\x01', b'\x01', b'\x00'),) raw errors: () new result set: () -model_view_base init end - model.user: - id_user: 1 - id_user_auth0: auth0|6582b95c895d09a70ba10fef - firstname: Teddy - surname: Middleton-Smith - email: edward.middletonsmith@gmail.com - is_email_verified: False - is_super_user: True - id_currency_default: None - id_region_default: None - is_included_VAT_default: True - can_admin_store: True - can_admin_user: True - -config_env: development -categories -form_filters=Filters_Product_Category(is_not_empty=False, active=True) -Model_View_Store_Product_Category.__init__ -starting... -Model_View_Store.__init__ -starting -session: -DataStore_Base.get_user_session -User.from_json -json: {'can_admin_store': True, 'can_admin_user': True, 'email': 'edward.middletonsmith@gmail.com', 'firstname': 'Teddy', 'id_currency_default': None, 'id_region_default': None, 'id_user': 1, 'id_user_auth0': 'auth0|6582b95c895d09a70ba10fef', 'is_email_verified': False, 'is_included_VAT_default': True, 'is_super_user': True, 'surname': 'Middleton-Smith'} -user: - id_user: 1 - id_user_auth0: auth0|6582b95c895d09a70ba10fef - firstname: Teddy - surname: Middleton-Smith - email: edward.middletonsmith@gmail.com - is_email_verified: False - is_super_user: True - id_currency_default: None - id_region_default: None - is_included_VAT_default: True - can_admin_store: True - can_admin_user: True - +DataStore_Base.db_procedure_execute +proc_string: CALL p_shop_get_many_product_variation(:a_id_user, :a_get_all_variation_type, :a_get_inactive_variation_type, :a_ids_variation_type, :a_get_all_variation, :a_get_inactive_variation, :a_ids_variation, :a_debug) +args: {'a_id_user': 1, 'a_get_all_variation_type': True, 'a_get_inactive_variation_type': False, 'a_ids_variation_type': '', 'a_get_all_variation': True, 'a_get_inactive_variation': False, 'a_ids_variation': '', 'a_debug': 0} +result: +index_variation_type: {1: 0, 2: 1} +raw errors: () +new result set: () +argument_dict: {'active': True} +executing p_shop_get_many_unit_measurement +DataStore_Base.db_procedure_execute +proc_string: CALL p_shop_get_many_unit_measurement(:active) +args: {'active': True} +result: +data received diff --git a/app.log.3 b/app.log.3 index d9b10a64..aa268209 100644 --- a/app.log.3 +++ b/app.log.3 @@ -1,3 +1,17 @@ +user: + id_user: 1 + id_user_auth0: auth0|6582b95c895d09a70ba10fef + firstname: Teddy + surname: Middleton-Smith + email: edward.middletonsmith@gmail.com + is_email_verified: False + is_super_user: True + id_currency_default: None + id_region_default: None + is_included_VAT_default: True + can_admin_store: True + can_admin_user: True + User.from_json json: {'can_admin_store': True, 'can_admin_user': True, 'email': 'edward.middletonsmith@gmail.com', 'firstname': 'Teddy', 'id_currency_default': None, 'id_region_default': None, 'id_user': 1, 'id_user_auth0': 'auth0|6582b95c895d09a70ba10fef', 'is_email_verified': False, 'is_included_VAT_default': True, 'is_super_user': True, 'surname': 'Middleton-Smith'} user: @@ -19,7 +33,7 @@ executing p_get_many_user DataStore_Base.db_procedure_execute proc_string: CALL p_get_many_user(:a_id_user, :a_id_user_auth0, :get_all_user, :get_inactive_user, :ids_user, :ids_user_auth0, :a_debug) args: {'a_id_user': 1, 'a_id_user_auth0': 'auth0|6582b95c895d09a70ba10fef', 'get_all_user': False, 'get_inactive_user': False, 'ids_user': 1, 'ids_user_auth0': '', 'a_debug': 0} -result: +result: data received raw users: ((1, 'auth0|6582b95c895d09a70ba10fef', 'Teddy', 'Middleton-Smith', 'edward.middletonsmith@gmail.com', b'\x00', None, None, b'\x01', b'\x01', b'\x01', b'\x01', b'\x00'),) raw errors: () @@ -38,15 +52,11 @@ model_view_base init end - model.user: can_admin_store: True can_admin_user: True -argument_dict: {'active': 1} -executing p_shop_get_many_access_level -DataStore_Base.db_procedure_execute -proc_string: CALL p_shop_get_many_access_level(:active) -args: {'active': 1} -result: -data received -raw access levels: ((1, 'VIEW', 'View', 3, 1, b'\x01'), (2, 'EDIT', 'Edit', 2, 2, b'\x01'), (3, 'ADMIN', 'Admin', 1, 3, b'\x01')) -raw errors: () +form question: +bool interpretted: False +form question: +get_inactive:False +type form: DataStore_Base.get_user_session User.from_json json: {'can_admin_store': True, 'can_admin_user': True, 'email': 'edward.middletonsmith@gmail.com', 'firstname': 'Teddy', 'id_currency_default': None, 'id_region_default': None, 'id_user': 1, 'id_user_auth0': 'auth0|6582b95c895d09a70ba10fef', 'is_email_verified': False, 'is_included_VAT_default': True, 'is_super_user': True, 'surname': 'Middleton-Smith'} @@ -85,108 +95,94 @@ executing p_get_many_user DataStore_Base.db_procedure_execute proc_string: CALL p_get_many_user(:a_id_user, :a_id_user_auth0, :get_all_user, :get_inactive_user, :ids_user, :ids_user_auth0, :a_debug) args: {'a_id_user': 1, 'a_id_user_auth0': 'auth0|6582b95c895d09a70ba10fef', 'get_all_user': False, 'get_inactive_user': False, 'ids_user': 1, 'ids_user_auth0': '', 'a_debug': 0} -result: +result: data received raw users: ((1, 'auth0|6582b95c895d09a70ba10fef', 'Teddy', 'Middleton-Smith', 'edward.middletonsmith@gmail.com', b'\x00', None, None, b'\x01', b'\x01', b'\x01', b'\x01', b'\x00'),) raw errors: () new result set: () -argument_dict: {'a_id_user': 1, 'a_get_all_product_category': True, 'a_get_inactive_product_category': True, 'a_ids_product_category': '', 'a_get_all_product': True, 'a_get_inactive_product': False, 'a_ids_product': '', 'a_get_all_permutation': True, 'a_get_inactive_permutation': False, 'a_ids_permutation': '', 'a_get_all_image': False, 'a_get_inactive_image': False, 'a_ids_image': '', 'a_get_products_quantity_stock_below_min': False, 'a_debug': 0} +argument_dict: {'a_id_user': 1, 'a_get_all_product_category': True, 'a_get_inactive_product_category': False, 'a_ids_product_category': '', 'a_get_all_product': True, 'a_get_inactive_product': False, 'a_ids_product': '', 'a_get_all_permutation': True, 'a_get_inactive_permutation': False, 'a_ids_permutation': '', 'a_get_all_image': False, 'a_get_inactive_image': False, 'a_ids_image': '', 'a_get_products_quantity_stock_below_min': False, 'a_debug': 0} executing p_shop_get_many_product DataStore_Base.db_procedure_execute proc_string: CALL p_shop_get_many_product(:a_id_user, :a_get_all_product_category, :a_get_inactive_product_category, :a_ids_product_category, :a_get_all_product, :a_get_inactive_product, :a_ids_product, :a_get_all_permutation, :a_get_inactive_permutation, :a_ids_permutation, :a_get_all_image, :a_get_inactive_image, :a_ids_image, :a_get_products_quantity_stock_below_min, :a_debug) -args: {'a_id_user': 1, 'a_get_all_product_category': True, 'a_get_inactive_product_category': True, 'a_ids_product_category': '', 'a_get_all_product': True, 'a_get_inactive_product': False, 'a_ids_product': '', 'a_get_all_permutation': True, 'a_get_inactive_permutation': False, 'a_ids_permutation': '', 'a_get_all_image': False, 'a_get_inactive_image': False, 'a_ids_image': '', 'a_get_products_quantity_stock_below_min': False, 'a_debug': 0} -result: +args: {'a_id_user': 1, 'a_get_all_product_category': True, 'a_get_inactive_product_category': False, 'a_ids_product_category': '', 'a_get_all_product': True, 'a_get_inactive_product': False, 'a_ids_product': '', 'a_get_all_permutation': True, 'a_get_inactive_permutation': False, 'a_ids_permutation': '', 'a_get_all_image': False, 'a_get_inactive_image': False, 'a_ids_image': '', 'a_get_products_quantity_stock_below_min': False, 'a_debug': 0} +result: data received initial category_list: categories: [] -raw categories: ((1, 'ASS', 'Assistive Devices', 'Braille product line and other assistive devices', 1, 'View', 1, b'\x00', None, None, None), (3, 'TECH', 'Technology', 'Technological devices', 1, 'View', 2, b'\x00', None, None, None), (2, 'MISC', 'Miscellaneous', 'Not category allocated products', 1, 'View', 99, b'\x00', None, None, None)) +raw categories: ((4, 'CHOCOLATE', 'Chocolates and sweets', 'Confectionery', 1, 'View', 1, b'\x01', None, None, None),) new_category: - id: 1 - code: ASS - name: Assistive Devices - description: Braille product line and other assistive devices + id: 4 + code: CHOCOLATE + name: Chocolates and sweets + description: Confectionery access_level: View display_order: 1 - active: False - products: [] - -new_category: - id: 3 - code: TECH - name: Technology - description: Technological devices - access_level: View - display_order: 2 - active: False - products: [] - -new_category: - id: 2 - code: MISC - name: Miscellaneous - description: Not category allocated products - access_level: View - display_order: 99 - active: False + active: True products: [] category-loaded category_list: categories: [ - id: 1 - code: ASS - name: Assistive Devices - description: Braille product line and other assistive devices + id: 4 + code: CHOCOLATE + name: Chocolates and sweets + description: Confectionery access_level: View display_order: 1 - active: False - products: [] - , - id: 3 - code: TECH - name: Technology - description: Technological devices - access_level: View - display_order: 2 - active: False - products: [] - , - id: 2 - code: MISC - name: Miscellaneous - description: Not category allocated products - access_level: View - display_order: 99 - active: False + active: True products: [] ] -raw products: () +raw products: ((6, 4, 'Digestives', b'\x01', 1, 'View', b'\x01', 1, None, None, None),) +row: (6, 4, 'Digestives', b'\x01', 1, 'View', b'\x01', 1, None, None, None) +new_product: Product + id_product: 6 + id_category: 4 + name: Digestives + display_order: 1 + can_view: False + can_edit: False + can_admin: False + has_variations: True + permutations: [] + variation trees: [] + active: True + raw errors: () +product with id:6 has variations new result set: () get many category_list: categories: [ - id: 1 - code: ASS - name: Assistive Devices - description: Braille product line and other assistive devices + id: 4 + code: CHOCOLATE + name: Chocolates and sweets + description: Confectionery access_level: View display_order: 1 - active: False - products: [] - , - id: 3 - code: TECH - name: Technology - description: Technological devices - access_level: View - display_order: 2 - active: False - products: [] - , - id: 2 - code: MISC - name: Miscellaneous - description: Not category allocated products - access_level: View - display_order: 99 - active: False - products: [] + active: True + products: [Product + id_product: 6 + id_category: 4 + name: Digestives + display_order: 1 + can_view: False + can_edit: False + can_admin: False + has_variations: True + permutations: [] + variation trees: [] + active: True ] -Model_View_Store.__init__ -starting + ] +DataStore_Base.get_user_session +User.from_json +json: {'can_admin_store': True, 'can_admin_user': True, 'email': 'edward.middletonsmith@gmail.com', 'firstname': 'Teddy', 'id_currency_default': None, 'id_region_default': None, 'id_user': 1, 'id_user_auth0': 'auth0|6582b95c895d09a70ba10fef', 'is_email_verified': False, 'is_included_VAT_default': True, 'is_super_user': True, 'surname': 'Middleton-Smith'} +user: + id_user: 1 + id_user_auth0: auth0|6582b95c895d09a70ba10fef + firstname: Teddy + surname: Middleton-Smith + email: edward.middletonsmith@gmail.com + is_email_verified: False + is_super_user: True + id_currency_default: None + id_region_default: None + is_included_VAT_default: True + can_admin_store: True + can_admin_user: True + diff --git a/business_objects/store/__pycache__/product.cpython-312.pyc b/business_objects/store/__pycache__/product.cpython-312.pyc index 6d5ec767..45216788 100644 Binary files a/business_objects/store/__pycache__/product.cpython-312.pyc and b/business_objects/store/__pycache__/product.cpython-312.pyc differ diff --git a/business_objects/store/product.py b/business_objects/store/product.py index 03d2c9e2..4888216d 100644 --- a/business_objects/store/product.py +++ b/business_objects/store/product.py @@ -500,19 +500,20 @@ class Parameters_Product(Get_Many_Parameters_Base): # av.val_instance(form, 'form', 'Parameters_Product.from_form', Filters_Product_Permutation) 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") - Helper_App.console_log(f'form question: {type(form.is_out_of_stock)}\nbool interpretted: {get_permutations_stock_below_min}\ntype form: {type(form)}') + get_permutations_stock_below_min = av.input_bool(form.is_out_of_stock.data, "is_out_of_stock", "Parameters_Product.from_form_filters_product_permutation") + get_inactive = not av.input_bool(form.active.data, "active", "Parameters_Product.from_form_filters_product_permutation") + Helper_App.console_log(f'form question: {type(form.is_out_of_stock)}\nbool interpretted: {get_permutations_stock_below_min}\nform question: {type(form.active)}\nget_inactive:{get_inactive}\ntype form: {type(form)}') return Parameters_Product( get_all_product_category = not has_category_filter, - get_inactive_product_category = False, + get_inactive_product_category = get_inactive, # get_first_product_category_only = False, ids_product_category = form.id_category.data if form.id_category.data is not None else '', get_all_product = not has_product_filter, - get_inactive_product = False, + get_inactive_product = get_inactive, # get_first_product_only = False, ids_product = form.id_product.data if form.id_product.data is not None else '', get_all_permutation = not get_permutations_stock_below_min, - get_inactive_permutation = False, + get_inactive_permutation = get_inactive, # get_first_permutation_only = False, ids_permutation = '', get_all_image = False, diff --git a/controllers/store/__pycache__/product_permutation.cpython-312.pyc b/controllers/store/__pycache__/product_permutation.cpython-312.pyc index 946c74fc..09bc7ab5 100644 Binary files a/controllers/store/__pycache__/product_permutation.cpython-312.pyc and b/controllers/store/__pycache__/product_permutation.cpython-312.pyc differ diff --git a/controllers/store/product_permutation.py b/controllers/store/product_permutation.py index 66fbed19..65448ba1 100644 --- a/controllers/store/product_permutation.py +++ b/controllers/store/product_permutation.py @@ -33,7 +33,8 @@ routes_store_product_permutation = Blueprint('routes_store_product_permutation', @routes_store_product_permutation.route(Model_View_Store_Product_Permutation.HASH_PAGE_STORE_PRODUCT_PERMUTATIONS, methods=['GET']) def permutations(): Helper_App.console_log('permutations') - data = Helper_App.get_request_data(request) + data = request.args + # Helper_App.console_log(f'data={data}\nrequest.args={request.args}\nrequest.form={request.form}\nrequest.data={request.data}\nrequest.values={request.values}\nrequest.headers={request.headers}') try: form_filters = Filters_Product_Permutation.from_json(data) except Exception as e: diff --git a/forms/store/__pycache__/product_permutation.cpython-312.pyc b/forms/store/__pycache__/product_permutation.cpython-312.pyc index a03cfe0f..14d4c745 100644 Binary files a/forms/store/__pycache__/product_permutation.cpython-312.pyc and b/forms/store/__pycache__/product_permutation.cpython-312.pyc differ diff --git a/forms/store/product_permutation.py b/forms/store/product_permutation.py index f32abac3..2fcd9d91 100644 --- a/forms/store/product_permutation.py +++ b/forms/store/product_permutation.py @@ -29,6 +29,7 @@ class Filters_Product_Permutation(Form_Base): id_category = SelectField('Category', validators=[Optional()], choices=[('', 'All')], default='') id_product = SelectField('Product', validators=[Optional()], choices=[('', 'All')], default='') is_out_of_stock = BooleanField('Out of stock only?') + active = BooleanField('Active only?', default=True) quantity_min = FloatField('Min stock') quantity_max = FloatField('Max stock') # submit = SubmitField('Submit') @@ -49,6 +50,7 @@ class Filters_Product_Permutation(Form_Base): id_category={self.id_category.data}, id_product={self.id_product.data}, is_out_of_stock={self.is_out_of_stock.data}, + active={self.active.data}, quantity_min={self.quantity_min.data}, quantity_max={self.quantity_max.data}) ''' @@ -60,6 +62,7 @@ class Filters_Product_Permutation(Form_Base): form.id_product.choices = [(json[Store_Base.ATTR_ID_PRODUCT], json[Store_Base.ATTR_ID_PRODUCT])] form.id_product.data = json[Store_Base.ATTR_ID_PRODUCT] form.is_out_of_stock.data = av.input_bool(json[Store_Base.FLAG_IS_OUT_OF_STOCK], Store_Base.FLAG_IS_OUT_OF_STOCK, f'{cls.__name__}.from_json') + form.active.data = av.input_bool(json[Store_Base.FLAG_ACTIVE], Store_Base.FLAG_ACTIVE, f'{cls.__name__}.from_json') form.quantity_min.data = json[Store_Base.FLAG_QUANTITY_MIN] form.quantity_max.data = json[Store_Base.FLAG_QUANTITY_MAX] return form \ No newline at end of file diff --git a/static/MySQL/6500_p_shop_calc_user.sql b/static/MySQL/6500_p_shop_calc_user.sql index ffea81a4..98dc5680 100644 --- a/static/MySQL/6500_p_shop_calc_user.sql +++ b/static/MySQL/6500_p_shop_calc_user.sql @@ -65,10 +65,9 @@ BEGIN -- Clear previous proc results DROP TABLE IF EXISTS tmp_Calc_User; - DROP TABLE IF EXISTS tmp_Shop_Calc_User; + DROP TABLE IF EXISTS tmp_User_Calc_User; DROP TABLE IF EXISTS tmp_Product_Calc_User; - DROP TABLE IF EXISTS tmp_Product_p_Shop_User_Eval_Temp; - -- DROP TABLE IF EXISTS tmp_Split; + DROP TABLE IF EXISTS tmp_Split; -- Permanent Table CREATE TEMPORARY TABLE tmp_Calc_User ( @@ -92,7 +91,14 @@ BEGIN -- guid BINARY(36) NOT NULL, -- rank_product INT NOT NULL ); - + + CREATE TEMPORARY TABLE tmp_User_Calc_User ( + id_user INT NOT NULL + , is_super_user BIT NOT NULL + -- , id_access_level INT + , priority_access_level INT NOT NULL + ); + CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, -- guid BINARY(36) NOT NULL, @@ -131,122 +137,314 @@ BEGIN ; END IF; - IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN - IF v_has_filter_access_level THEN - CALL partsltd_prod.p_split(a_guid, a_ids_access_level, ',', a_debug); - - INSERT INTO tmp_Split ( - substring - , as_int + # Access levels + IF v_has_filter_access_level THEN + CALL partsltd_prod.p_split(a_guid, a_ids_access_level, ',', a_debug); + + INSERT INTO tmp_Split ( + substring + , as_int + ) + SELECT + substring + , CONVERT(substring, DECIMAL(10,0)) -- AS as_int + FROM Split_Temp + WHERE 1=1 + AND GUID = a_guid + AND NOT ISNULL(substring) + AND substring != '' + ; + + CALL partsltd_prod.p_clear_split_temp( a_guid ); + + # Invalid IDs + IF EXISTS ( + SELECT t_S.substring + FROM tmp_Split t_S + LEFT JOIN partsltd_prod.Shop_Access_Level AL ON t_S.as_int = AL.id_access_level + WHERE + ISNULL(t_S.as_int) + OR ISNULL(AL.id_access_level) + OR AL.active = 0 + ) THEN + INSERT INTO tmp_Msg_Error ( + -- guid, + id_type, + code, + msg ) - SELECT - substring - , CONVERT(substring, DECIMAL(10,0)) -- AS as_int - FROM Split_Temp - WHERE 1=1 - AND GUID = a_guid - AND NOT ISNULL(substring) - AND substring != '' - ; - - CALL partsltd_prod.p_clear_split_temp( a_guid ); - - # Invalid IDs - IF EXISTS ( - SELECT t_S.substring - FROM tmp_Split t_S - LEFT JOIN partsltd_prod.Shop_Access_Level AL ON t_S.as_int = AL.id_access_level - WHERE - ISNULL(t_S.as_int) - OR ISNULL(AL.id_access_level) - OR AL.active = 0 - ) THEN - INSERT INTO tmp_Msg_Error ( - -- guid, - id_type, - code, - msg - ) - SELECT - -- a_guid, - v_id_type_error_bad_data, - v_code_type_error_bad_data, - CONCAT('Invalid or inactive access level IDs: ', GROUP_CONCAT(t_S.substring SEPARATOR ', ')) - FROM tmp_Split t_S - LEFT JOIN partsltd_prod.Shop_Access_Level AL ON t_S.as_int = AL.id_access_level - WHERE - ISNULL(t_S.as_int) - OR ISNULL(AL.id_access_level) - OR AL.active = 0 - ; + SELECT + -- a_guid, + v_id_type_error_bad_data, + v_code_type_error_bad_data, + CONCAT('Invalid or inactive access level IDs: ', GROUP_CONCAT(t_S.substring SEPARATOR ', ')) + FROM tmp_Split t_S + LEFT JOIN partsltd_prod.Shop_Access_Level AL ON t_S.as_int = AL.id_access_level + WHERE + ISNULL(t_S.as_int) + OR ISNULL(AL.id_access_level) + OR AL.active = 0 + ; + ELSE + IF v_has_filter_access_level THEN + SET v_id_access_level := ( + SELECT AL.id_access_level + FROM tmp_Split t_S + INNER JOIN partsltd_prod.Shop_Access_Level AL + ON t_S.as_int = AL.id_access_level + AND AL.active + ORDER BY AL.priority ASC + LIMIT 1 + ); + ELSE + SET v_id_access_level = v_id_access_level_view; END IF; + SET v_priority_access_level := (SELECT priority FROM partsltd_prod.Shop_Access_Level WHERE id_access_level = v_id_access_level LIMIT 1); END IF; END IF; - - IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN - IF v_has_filter_access_level THEN - SET v_id_access_level := ( - SELECT AL.id_access_level - FROM tmp_Split t_S - INNER JOIN partsltd_prod.Shop_Access_Level AL - ON t_S.as_int = AL.id_access_level - AND AL.active - ORDER BY AL.priority ASC - LIMIT 1 - ); - ELSE - SET v_id_access_level = v_id_access_level_view; - END IF; - SET v_priority_access_level := (SELECT priority FROM partsltd_prod.Shop_Access_Level WHERE id_access_level = v_id_access_level LIMIT 1); - END IF; - DELETE FROM tmp_Split; - IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN - IF v_has_filter_product = 1 THEN - CALL partsltd_prod.p_split(a_guid, a_ids_product, ',', a_debug); - - INSERT INTO tmp_Split ( - substring - , as_int + -- Permission IDs + IF v_has_filter_permission THEN + CALL partsltd_prod.p_split(a_guid, a_ids_permission, ',', a_debug); + + INSERT INTO tmp_Split ( + substring + , as_int + ) + SELECT + substring + , CONVERT(substring, DECIMAL(10,0)) AS as_int + FROM Split_Temp + WHERE 1=1 + AND GUID = a_guid + AND NOT ISNULL(substring) + AND substring != '' + ; + + CALL partsltd_prod.p_clear_split_temp( a_guid ); + + # Invalid or inactive + IF EXISTS (SELECT PERM.id_permission FROM tmp_Split t_S LEFT JOIN partsltd_prod.Shop_Permission PERM ON t_S.as_int = PERM.id_permission WHERE ISNULL(t_S.as_int) OR ISNULL(PERM.id_permission) OR PERM.active = 0) THEN + INSERT INTO tmp_Msg_Error ( + -- guid, + id_type, + code, + msg ) - SELECT - substring - , CONVERT(substring, DECIMAL(10,0)) AS as_int - FROM Split_Temp - WHERE 1=1 - AND GUID = a_guid - AND NOT ISNULL(substring) - AND substring != '' - ; - - CALL partsltd_prod.p_clear_split_temp( a_guid ); - - # Invalid product IDs - IF EXISTS (SELECT * FROM tmp_Split t_S LEFT JOIN partsltd_prod.Shop_Product P ON t_S.as_int = P.id_product WHERE ISNULL(t_S.as_int) OR ISNULL(P.id_product) OR P.active = 0) THEN - INSERT INTO tmp_Msg_Error ( - -- guid, - id_type, - code, - msg - ) - SELECT - -- a_guid, - v_id_type_error_bad_data, - v_code_type_error_bad_data, - CONCAT('Invalid or inactive product IDs: ', IFNULL(GROUP_CONCAT(t_S.substring SEPARATOR ', '), 'NULL')) - FROM tmp_Split t_S - LEFT JOIN partsltd_prod.Shop_Product P ON t_S.as_int = P.id_product - WHERE - ISNULL(t_S.as_int) - OR ISNULL(P.id_product) - OR P.active = 0 - ; - END IF; + SELECT + -- a_guid, + v_id_type_error_bad_data, + v_code_type_error_bad_data, + CONCAT('Invalid or inactive permission IDs: ', IFNULL(GROUP_CONCAT(t_S.substring SEPARATOR ', '), 'NULL')) + FROM tmp_Split t_S + LEFT JOIN partsltd_prod.Shop_Permission PERM ON t_S.as_int = PERM.id_permission + WHERE + ISNULL(t_S.as_int) + OR ISNULL(PERM.id_permission) + OR PERM.active = 0 + ; + ELSE + SET v_id_permission_required := ( + SELECT PERM.id_permission + FROM partsltd_prod.Shop_Permission PERM + INNER JOIN partsltd_prod.Shop_Access_Level AL ON PERM.id_access_level_required = AL.id_access_level + ORDER BY AL.priority ASC + LIMIT 1 + ); END IF; END IF; - IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN - IF (v_has_filter_product = 1 AND EXISTS (SELECT * FROM tmp_Split)) THEN + DELETE FROM tmp_Split; + + # Users + CALL partsltd_prod.p_split(a_guid, a_ids_user, ',', a_debug); + + INSERT INTO tmp_Split ( + substring + , as_int + ) + SELECT + substring + , CONVERT(substring, DECIMAL(10,0)) AS as_int + FROM Split_Temp + WHERE 1=1 + AND GUID = a_guid + AND NOT ISNULL(substring) + AND substring != '' + ; + + CALL partsltd_prod.p_clear_split_temp( a_guid ); + + # Invalid or inactive + IF EXISTS (SELECT U.id_user FROM tmp_Split t_S LEFT JOIN partsltd_prod.Shop_User U ON t_S.as_int = U.id_user WHERE ISNULL(t_S.as_int) OR ISNULL(U.id_user) OR (a_get_inactive_user = 0 AND U.active = 0)) THEN + INSERT INTO tmp_Msg_Error ( + -- guid, + id_type, + code, + msg + ) + SELECT + -- a_guid, + v_id_type_error_bad_data, + v_code_type_error_bad_data, + CONCAT('Invalid or inactive user IDs: ', IFNULL(GROUP_CONCAT(t_S.substring SEPARATOR ', '), 'NULL')) + FROM tmp_Split t_S + LEFT JOIN partsltd_prod.Shop_User U ON t_S.as_int = U.id_user + WHERE + ISNULL(t_S.as_int) + OR ISNULL(U.id_user) + OR ( + a_get_inactive_user = 0 + AND U.active = 0 + ) + ; + ELSE + /* + SET a_ids_user = ( + SELECT U.id_user + FROM tmp_Split t_S + INNER JOIN partsltd_prod.Shop_User U ON t_S.as_int = U.id_user + ); + SET v_has_filter_user = ISNULL(a_ids_user); + */ + IF NOT EXISTS (SELECT * FROM tmp_Split) THEN + INSERT INTO tmp_Split (substring, as_int) + VALUES ( '', NULL ); + END IF; + + IF a_debug = 1 THEN + SELECT * + FROM tmp_Split; + END IF; + + INSERT INTO tmp_User_Calc_User ( + id_user + -- , id_access_level + , is_super_user + , priority_access_level + ) + SELECT + U.id_user + , U.is_super_user + -- , IFNULL(AL_U.id_access_level, v_id_access_level_view) AS id_access_level + , IFNULL(MIN(AL_U.priority), v_priority_access_level_view) AS priority_access_level + FROM tmp_Split t_S + INNER JOIN partsltd_prod.Shop_User U ON t_S.as_int = U.id_user + LEFT JOIN partsltd_prod.Shop_User_Role_Link URL + ON U.id_user = URL.id_user + AND URL.active + LEFT JOIN partsltd_prod.Shop_Role_Permission_Link RPL + ON URL.id_role = RPL.id_role + AND RPL.active + LEFT JOIN partsltd_prod.Shop_Access_Level AL_U + ON RPL.id_access_level = AL_U.id_access_level + AND AL_U.active + GROUP BY U.id_user + ; + + INSERT INTO tmp_Calc_User ( + id_user + , id_permission_required + , priority_access_level_required + , id_product + , is_super_user + , priority_access_level_user + ) + SELECT + t_UCU.id_user + , v_id_permission_required + , v_priority_access_level AS priority_access_level_required + , NULL + , t_UCU.priority_access_level AS priority_access_level_user + , t_UCU.is_super_user AS is_super_user + FROM tmp_User_Calc_User t_UCU + ; + + /* + INSERT INTO tmp_Calc_User ( + id_user + , id_permission_required + , priority_access_level_required + -- , id_product + , priority_access_level_user + , is_super_user + ) + SELECT + U.id_user + , v_id_permission_required + , v_priority_access_level AS priority_access_level_required + -- , t_P.id_product + , CASE WHEN MIN(IFNULL(AL_U.priority, 0)) = 0 THEN v_priority_access_level_view ELSE MIN(IFNULL(AL_U.priority, 0)) END AS priority_access_level_user + , IFNULL(U.is_super_user, 0) AS is_super_user + FROM tmp_Split t_S + LEFT JOIN partsltd_prod.Shop_User U + ON t_S.as_int = U.id_user + AND U.active + LEFT JOIN partsltd_prod.Shop_User_Role_Link URL + ON U.id_user = URL.id_user + AND URL.active + LEFT JOIN partsltd_prod.Shop_Role_Permission_Link RPL + ON URL.id_role = RPL.id_role + AND RPL.active + LEFT JOIN partsltd_prod.Shop_Access_Level AL_U + ON RPL.id_access_level = AL_U.id_access_level + AND AL_U.active + * + CROSS JOIN tmp_Product_Calc_User t_P + LEFT JOIN partsltd_prod.Shop_Access_Level AL_P + ON t_P.id_access_level_required = AL_P.id_access_level + AND AL_P.active + * + GROUP BY t_S.as_int, U.id_user + ; + */ + + # SET v_has_filter_user = EXISTS ( SELECT * FROM tmp_User_Calc_User LIMIT 1 ); + END IF; + DELETE FROM tmp_Split; + + # Products + IF v_has_filter_product = 1 THEN + CALL partsltd_prod.p_split(a_guid, a_ids_product, ',', a_debug); + + INSERT INTO tmp_Split ( + substring + , as_int + ) + SELECT + substring + , CONVERT(substring, DECIMAL(10,0)) AS as_int + FROM Split_Temp + WHERE 1=1 + AND GUID = a_guid + AND NOT ISNULL(substring) + AND substring != '' + ; + + CALL partsltd_prod.p_clear_split_temp( a_guid ); + + # Invalid product IDs + IF EXISTS (SELECT * FROM tmp_Split t_S LEFT JOIN partsltd_prod.Shop_Product P ON t_S.as_int = P.id_product WHERE ISNULL(t_S.as_int) OR ISNULL(P.id_product)) THEN + INSERT INTO tmp_Msg_Error ( + -- guid, + id_type, + code, + msg + ) + SELECT + -- a_guid, + v_id_type_error_bad_data, + v_code_type_error_bad_data, + CONCAT('Invalid Product IDs: ', IFNULL(GROUP_CONCAT(t_S.substring SEPARATOR ', '), 'NULL')) + FROM tmp_Split t_S + LEFT JOIN partsltd_prod.Shop_Product P ON t_S.as_int = P.id_product + WHERE + ISNULL(t_S.as_int) + OR ISNULL(P.id_product) + OR P.active = 0 + ; + END IF; + IF (EXISTS (SELECT * FROM tmp_Split)) THEN INSERT INTO tmp_Product_Calc_User ( id_product, -- id_permutation, @@ -294,177 +492,35 @@ BEGIN ); END IF; END IF; - DELETE FROM tmp_Split; - -- Permission IDs - IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN - IF v_has_filter_permission THEN - CALL partsltd_prod.p_split(a_guid, a_ids_permission, ',', a_debug); - - INSERT INTO tmp_Split ( - substring - , as_int - ) - SELECT - substring - , CONVERT(substring, DECIMAL(10,0)) AS as_int - FROM Split_Temp - WHERE 1=1 - AND GUID = a_guid - AND NOT ISNULL(substring) - AND substring != '' - ; - - CALL partsltd_prod.p_clear_split_temp( a_guid ); - - # Invalid or inactive - IF EXISTS (SELECT PERM.id_permission FROM tmp_Split t_S LEFT JOIN partsltd_prod.Shop_Permission PERM ON t_S.as_int = PERM.id_permission WHERE ISNULL(t_S.as_int) OR ISNULL(PERM.id_permission) OR PERM.active = 0) THEN - INSERT INTO tmp_Msg_Error ( - -- guid, - id_type, - code, - msg - ) - SELECT - -- a_guid, - v_id_type_error_bad_data, - v_code_type_error_bad_data, - CONCAT('Invalid or inactive permission IDs: ', IFNULL(GROUP_CONCAT(t_S.substring SEPARATOR ', '), 'NULL')) - FROM tmp_Split t_S - LEFT JOIN partsltd_prod.Shop_Permission PERM ON t_S.as_int = PERM.id_permission - WHERE - ISNULL(t_S.as_int) - OR ISNULL(PERM.id_permission) - OR PERM.active = 0 - ; - ELSE - SET v_id_permission_required := ( - SELECT PERM.id_permission - FROM partsltd_prod.Shop_Permission PERM - INNER JOIN partsltd_prod.Shop_Access_Level AL ON PERM.id_access_level_required = AL.id_access_level - ORDER BY AL.priority ASC - LIMIT 1 - ); - END IF; - END IF; - END IF; - - DELETE FROM tmp_Split; - - IF a_debug = 1 THEN - SELECT * FROM tmp_Product_Calc_User; - END IF; - - IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN - -- Invalid user ID - CALL partsltd_prod.p_split(a_guid, a_ids_user, ',', a_debug); - - INSERT INTO tmp_Split ( - substring - , as_int - ) - SELECT - substring - , CONVERT(substring, DECIMAL(10,0)) AS as_int - FROM Split_Temp - WHERE 1=1 - AND GUID = a_guid - AND NOT ISNULL(substring) - AND substring != '' - ; - - CALL partsltd_prod.p_clear_split_temp( a_guid ); - - # Invalid or inactive - IF EXISTS (SELECT U.id_user FROM tmp_Split t_S LEFT JOIN partsltd_prod.Shop_User U ON t_S.as_int = U.id_user WHERE ISNULL(t_S.as_int) OR ISNULL(U.id_user) OR U.active = 0) THEN - INSERT INTO tmp_Msg_Error ( - -- guid, - id_type, - code, - msg - ) - SELECT - -- a_guid, - v_id_type_error_bad_data, - v_code_type_error_bad_data, - CONCAT('Invalid or inactive user IDs: ', IFNULL(GROUP_CONCAT(t_S.substring SEPARATOR ', '), 'NULL')) - FROM tmp_Split t_S - LEFT JOIN partsltd_prod.Shop_User U ON t_S.as_int = U.id_user - WHERE - ISNULL(t_S.as_int) - OR ISNULL(U.id_user) - OR U.active = 0 - ; - ELSE - /* - SET a_ids_user = ( - SELECT U.id_user - FROM tmp_Split t_S - INNER JOIN partsltd_prod.Shop_User U ON t_S.as_int = U.id_user - ); - SET v_has_filter_user = ISNULL(a_ids_user); - */ - IF NOT EXISTS (SELECT * FROM tmp_Split) THEN - INSERT INTO tmp_Split (substring, as_int) - VALUES ( '', NULL ); - END IF; - - IF a_debug = 1 THEN - SELECT * - FROM tmp_Split; - END IF; - - INSERT INTO tmp_Calc_User ( - id_user - , id_permission_required - , priority_access_level_required - , id_product - , priority_access_level_user - , is_super_user - ) - SELECT - U.id_user - , v_id_permission_required - , CASE WHEN v_priority_access_level < AL_P.priority THEN v_priority_access_level ELSE AL_P.priority END AS priority_access_level_required - , t_P.id_product - , CASE WHEN MIN(IFNULL(AL_U.priority, 0)) = 0 THEN v_priority_access_level_view ELSE MIN(IFNULL(AL_U.priority, 0)) END AS priority_access_level_user - , IFNULL(U.is_super_user, 0) AS is_super_user - FROM tmp_Split t_S - LEFT JOIN partsltd_prod.Shop_User U - ON t_S.as_int = U.id_user - AND U.active - LEFT JOIN partsltd_prod.Shop_User_Role_Link URL - ON U.id_user = URL.id_user - AND URL.active - LEFT JOIN partsltd_prod.Shop_Role_Permission_Link RPL - ON URL.id_role = RPL.id_role - AND RPL.active - LEFT JOIN partsltd_prod.Shop_Access_Level AL_U - ON RPL.id_access_level = AL_U.id_access_level - AND AL_U.active - CROSS JOIN tmp_Product_Calc_User t_P - LEFT JOIN partsltd_prod.Shop_Access_Level AL_P - ON t_P.id_access_level_required = AL_P.id_access_level - AND AL_P.active - GROUP BY t_S.as_int, U.id_user, t_P.id_product, AL_P.priority - ; - - SET v_has_filter_user = EXISTS ( SELECT * FROM tmp_Calc_User LIMIT 1 ); - END IF; - END IF; - - DELETE FROM tmp_Split; + INSERT INTO tmp_Calc_User ( + id_user + , id_permission_required + , priority_access_level_required + , id_product + , is_super_user + , priority_access_level_user + ) + SELECT + t_U.id_user + , v_id_permission_required + , CASE WHEN AL.priority < v_priority_access_level THEN AL.priority ELSE v_priority_access_level END AS priority_access_level_required + , t_P.id_product + , t_U.priority_access_level AS priority_access_level_user + , t_U.is_super_user AS is_super_user + FROM tmp_User_Calc_User t_U + CROSS JOIN tmp_Product_Calc_User t_P + LEFT JOIN partsltd_prod.Shop_Access_Level AL ON t_P.id_access_level_required = AL.id_access_level + ; -- Calculated fields - IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN - UPDATE tmp_Calc_User t_U - SET - t_U.can_view = t_U.is_super_user = 1 OR (t_U.priority_access_level_user <= v_priority_access_level_view AND t_U.priority_access_level_user <= t_U.priority_access_level_required) - , t_U.can_edit = t_U.is_super_user = 1 OR (t_U.priority_access_level_user <= v_priority_access_level_edit AND t_U.priority_access_level_user <= t_U.priority_access_level_required) - , t_U.can_admin = t_U.is_super_user = 1 OR (t_U.priority_access_level_user <= v_priority_access_level_admin AND t_U.priority_access_level_user <= t_U.priority_access_level_required) - ; - END IF; + UPDATE tmp_Calc_User t_CU + SET + t_CU.can_view = t_CU.is_super_user = 1 OR (t_CU.priority_access_level_user <= v_priority_access_level_view AND t_CU.priority_access_level_user <= t_CU.priority_access_level_required) + , t_CU.can_edit = t_CU.is_super_user = 1 OR (t_CU.priority_access_level_user <= v_priority_access_level_edit AND t_CU.priority_access_level_user <= t_CU.priority_access_level_required) + , t_CU.can_admin = t_CU.is_super_user = 1 OR (t_CU.priority_access_level_user <= v_priority_access_level_admin AND t_CU.priority_access_level_user <= t_CU.priority_access_level_required) + ; -- Export data to staging table IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN @@ -500,6 +556,7 @@ BEGIN IF a_debug = 1 THEN SELECT * FROM tmp_Msg_Error; SELECT * FROM tmp_Calc_User; + SELECT * FROM tmp_User_Calc_User; SELECT * FROM tmp_Product_Calc_User; SELECT * FROM partsltd_prod.Shop_Calc_User_Temp WHERE GUID = a_guid; CALL partsltd_prod.p_shop_clear_calc_user ( a_guid, a_debug ); @@ -507,10 +564,11 @@ BEGIN -- Clean up DROP TABLE IF EXISTS tmp_Calc_User; - DROP TABLE IF EXISTS tmp_Shop_Calc_User; + DROP TABLE IF EXISTS tmp_User_Calc_User; DROP TABLE IF EXISTS tmp_Product_Calc_User; - DROP TABLE IF EXISTS tmp_Product_p_Shop_User_Eval_Temp; - -- DROP TABLE IF EXISTS tmp_Split; + # Don't destroy common tables in nested Stored Procedures! + -- DROP TABLE IF EXISTS tmp_Split; + DELETE FROM tmp_Split; IF a_debug = 1 THEN CALL partsltd_prod.p_debug_timing_reporting( v_time_start ); @@ -518,19 +576,20 @@ BEGIN END // DELIMITER ;; -/* +/* CALL partsltd_prod.p_shop_calc_user ( 'chips ' - , NULL + , 1 , 0 , '2' , '1' , '1,2,3,4,5' , 0 ); - - +SELECT * FROM partsltd_prod.Shop_Calc_User_Temp WHERE GUID = 'chips '; +DELETE FROM partsltd_prod.Shop_Calc_User_Temp WHERE GUID = 'chips '; + -- SELECT * FROM partsltd_prod.Shop_Calc_User_Temp; SELECT * FROM partsltd_prod.Shop_Calc_User_Temp WHERE GUID = 'chips '; diff --git a/static/MySQL/7200_p_shop_save_product_category.sql b/static/MySQL/7200_p_shop_save_product_category.sql index 8642eae8..a14f69fa 100644 --- a/static/MySQL/7200_p_shop_save_product_category.sql +++ b/static/MySQL/7200_p_shop_save_product_category.sql @@ -126,7 +126,7 @@ BEGIN SELECT v_id_type_error_bad_data , v_code_type_error_bad_data - , CONCAT('The following category(s) do not have a code: ', GROUP_CONCAT(t_C.name_error SEPARATOR ', ')) AS msg + , CONCAT('The following Product Category(s) do not have a code: ', GROUP_CONCAT(t_C.name_error SEPARATOR ', ')) AS msg FROM tmp_Category t_C WHERE ISNULL(t_C.code) ; @@ -141,7 +141,7 @@ BEGIN SELECT v_id_type_error_bad_data , v_code_type_error_bad_data - , CONCAT('The following category(s) do not have a name: ', GROUP_CONCAT(t_C.name_error SEPARATOR ', ')) AS msg + , CONCAT('The following Product Category(s) do not have a name: ', GROUP_CONCAT(t_C.name_error SEPARATOR ', ')) AS msg FROM tmp_Category t_C WHERE ISNULL(t_C.name) ; @@ -156,7 +156,7 @@ BEGIN SELECT v_id_type_error_bad_data , v_code_type_error_bad_data - , CONCAT('The following category(s) do not have a display order: ', GROUP_CONCAT(t_C.name_error SEPARATOR ', ')) AS msg + , CONCAT('The following Product Category(s) do not have a display order: ', GROUP_CONCAT(t_C.name_error SEPARATOR ', ')) AS msg FROM tmp_Category t_C WHERE ISNULL(t_C.display_order) ; @@ -165,7 +165,7 @@ BEGIN -- Permissions SET v_ids_product_permission := ( SELECT GROUP_CONCAT(P.id_product SEPARATOR ',') - FROM Shop_Product P + FROM partsltd_prod.Shop_Product P INNER JOIN tmp_Category t_C ON P.id_category = t_C.id_category AND t_C.is_new = 0 @@ -185,7 +185,7 @@ BEGIN ; END IF; - CALL p_shop_calc_user( + CALL partsltd_prod.p_shop_calc_user( a_guid , a_id_user , FALSE -- a_get_inactive_user @@ -196,8 +196,8 @@ BEGIN ); UPDATE tmp_Category t_C - INNER JOIN Shop_Product P ON t_C.id_category = P.id_product - INNER JOIN Shop_Calc_User_Temp UE_T + INNER JOIN partsltd_prod.Shop_Product P ON t_C.id_category = P.id_product + INNER JOIN partsltd_prod.Shop_Calc_User_Temp UE_T ON P.id_product = UE_T.id_product AND UE_T.GUID = a_guid SET @@ -205,8 +205,43 @@ BEGIN , t_C.can_edit = UE_T.can_edit , t_C.can_admin = UE_T.can_admin ; + + IF EXISTS (SELECT * FROM tmp_Category WHERE IFNULL(can_edit, 0) = 0 AND is_new = 0 LIMIT 1) THEN + INSERT INTO tmp_Msg_Error ( + id_type + , code + , msg + ) + SELECT + v_id_type_error_no_permission + , v_code_type_error_no_permission + , CONCAT('You do not have permission to edit the following Product Catogory(s): ', IFNULL(GROUP_CONCAT(IFNULL(t_C.name_error, 'NULL') SEPARATOR ', '), 'NULL')) + FROM tmp_Category t_C + WHERE + IFNULL(can_edit, 0) = 0 + AND is_new = 0 + ; + END IF; + + IF EXISTS (SELECT * FROM partsltd_prod.Shop_Calc_User_Temp WHERE ISNULL(id_product) AND GUID = a_guid AND can_edit = 0 LIMIT 1) THEN + DELETE t_ME + FROM tmp_Msg_Error t_ME + WHERE t_ME.id_type <> v_id_type_error_no_permission + ; + INSERT INTO tmp_Msg_Error ( + id_type + , code + , msg + ) + VALUES ( + v_id_type_error_no_permission + , v_code_type_error_no_permission + , 'You do not have permission to edit Product Catogories.' + ) + ; + END IF; - CALL p_shop_clear_calc_user( + CALL partsltd_prod.p_shop_clear_calc_user( a_guid , 0 -- a_debug ); diff --git a/static/MySQL/7203_p_shop_save_product.sql b/static/MySQL/7203_p_shop_save_product.sql index b26f0f74..01ff95c7 100644 --- a/static/MySQL/7203_p_shop_save_product.sql +++ b/static/MySQL/7203_p_shop_save_product.sql @@ -216,60 +216,90 @@ BEGIN -- Permissions - IF NOT EXISTS (SELECT * FROM tmp_Msg_Error LIMIT 1) THEN -- (SELECT * FROM tmp_Product WHERE is_new = 0 LIMIT 1) THEN - SET v_ids_product_permission := (SELECT GROUP_CONCAT(id_product SEPARATOR ',') FROM tmp_Product WHERE is_new = 0); - IF NOT ISNULL(v_ids_product_permission) THEN - SET v_id_permission_product = (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_PRODUCT' LIMIT 1); - - CALL partsltd_prod.p_shop_calc_user( - a_guid - , a_id_user - , FALSE -- get_inactive_users - , v_id_permission_product - , v_id_access_level_edit - , v_ids_product_permission - , 0 -- debug - ); - - UPDATE tmp_Product t_P - INNER JOIN Shop_Calc_User_Temp UE_T - ON t_P.id_product = UE_T.id_product - AND UE_T.GUID = a_guid - SET - t_P.can_view = UE_T.can_view - , t_P.can_edit = UE_T.can_edit - , t_P.can_admin = UE_T.can_admin - ; - - CALL partsltd_prod.p_shop_clear_calc_user( - a_guid - , 0 -- debug - ); - END IF; + SET v_ids_product_permission := (SELECT GROUP_CONCAT(id_product SEPARATOR ',') FROM tmp_Product WHERE is_new = 0); + + SET v_id_permission_product = (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_PRODUCT' LIMIT 1); + + CALL partsltd_prod.p_shop_calc_user( + a_guid + , a_id_user + , FALSE -- get_inactive_users + , v_id_permission_product + , v_id_access_level_edit + , v_ids_product_permission + , 0 -- debug + ); + + UPDATE tmp_Product t_P + INNER JOIN partsltd_prod.Shop_Calc_User_Temp UE_T + ON t_P.id_product = UE_T.id_product + AND UE_T.GUID = a_guid + SET + t_P.can_view = UE_T.can_view + , t_P.can_edit = UE_T.can_edit + , t_P.can_admin = UE_T.can_admin + ; + + IF EXISTS (SELECT * FROM tmp_Product WHERE IFNULL(can_edit, 0) = 0 AND is_new = 0 LIMIT 1) THEN + INSERT INTO tmp_Msg_Error ( + id_type + , code + , msg + ) + SELECT + v_id_type_error_no_permission + , v_code_type_error_no_permission + , CONCAT('You do not have permission to edit the following Product(s): ', IFNULL(GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', '), 'NULL')) + FROM tmp_Product t_P + WHERE + IFNULL(can_edit, 0) = 0 + AND is_new = 0 + ; END IF; + IF EXISTS (SELECT * FROM partsltd_prod.Shop_Calc_User_Temp WHERE ISNULL(id_product) AND GUID = a_guid AND can_edit = 0) THEN + DELETE t_ME + FROM tmp_Msg_Error t_ME + WHERE t_ME.id_type <> v_id_type_error_no_permission + ; + INSERT INTO tmp_Msg_Error ( + id_type + , code + , msg + ) + VALUES ( + v_id_type_error_no_permission + , v_code_type_error_no_permission + , 'You do not have permission to edit Products' + ) + ; + END IF; + + CALL partsltd_prod.p_shop_clear_calc_user( + a_guid + , 0 -- debug + ); IF NOT EXISTS (SELECT * FROM tmp_Msg_Error LIMIT 1) THEN START TRANSACTION; - IF NOT ISNULL(v_ids_product_permission) THEN - INSERT INTO partsltd_prod.Shop_Product_Change_Set ( comment ) - VALUES ( a_comment ) - ; - - SET v_id_change_set := LAST_INSERT_ID(); - - UPDATE partsltd_prod.Shop_Product P - INNER JOIN tmp_Product t_P ON P.id_product = t_P.id_product - SET - P.id_category = t_P.id_category - , P.name = t_P.name - , P.has_variations = t_P.has_variations - , P.id_access_level_required = t_P.id_access_level_required - , P.display_order = t_P.display_order - , P.active = t_P.active - , P.id_change_set = v_id_change_set - ; - END IF; + + INSERT INTO partsltd_prod.Shop_Product_Change_Set ( comment ) + VALUES ( a_comment ) + ; + + SET v_id_change_set := LAST_INSERT_ID(); + + UPDATE partsltd_prod.Shop_Product P + INNER JOIN tmp_Product t_P ON P.id_product = t_P.id_product + SET + P.id_category = t_P.id_category + , P.name = t_P.name + , P.has_variations = t_P.has_variations + , P.id_access_level_required = t_P.id_access_level_required + , P.display_order = t_P.display_order + , P.active = t_P.active + , P.id_change_set = v_id_change_set + ; INSERT INTO partsltd_prod.Shop_Product ( id_category @@ -297,7 +327,7 @@ BEGIN START TRANSACTION; - DELETE FROM partsltd_prod.Shop_Product_Category_Temp + DELETE FROM partsltd_prod.Shop_Product_Temp WHERE GUID = a_guid; COMMIT; diff --git a/static/MySQL/7206_p_shop_save_product_permutation.sql b/static/MySQL/7206_p_shop_save_product_permutation.sql index ea78182b..aa61e81c 100644 --- a/static/MySQL/7206_p_shop_save_product_permutation.sql +++ b/static/MySQL/7206_p_shop_save_product_permutation.sql @@ -440,11 +440,6 @@ BEGIN LEFT JOIN Shop_Product P ON t_PP.id_product = P.id_product ; END IF; - - CALL p_shop_clear_calc_user( - a_guid - , 0 -- a_debug - ); IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.can_edit) LIMIT 1) THEN INSERT INTO tmp_Msg_Error ( @@ -461,13 +456,36 @@ BEGIN ISNULL(t_P.can_edit) ; END IF; + + IF EXISTS (SELECT * FROM partsltd_prod.Shop_User_Eval_Temp WHERE ISNULL(id_product) AND GUID = a_guid AND can_edit = 0) THEN + DELETE FROM tmp_Msg_Error + WHERE id_type <> v_id_type_error_no_permission + ; - IF a_debug = 1 THEN - SELECT * - FROM partsltd_prod.Shop_Product_Permutation_Variation_Link_Temp - WHERE GUID = a_guid - ; - END IF; + INSERT INTO tmp_Msg_Error ( + id_type + , code + , msg + ) + VALUES ( + v_id_type_error_bad_data + , v_code_type_error_bad_data + , 'You do not have permission to edit Product Permutations' + ) + ; + END IF; + + CALL p_shop_clear_calc_user( + a_guid + , 0 -- a_debug + ); + + IF a_debug = 1 THEN + SELECT * + FROM partsltd_prod.Shop_Product_Permutation_Variation_Link_Temp + WHERE GUID = a_guid + ; + END IF; IF NOT EXISTS (SELECT * FROM tmp_Msg_Error LIMIT 1) THEN START TRANSACTION; diff --git a/templates/pages/store/_product_permutations.html b/templates/pages/store/_product_permutations.html index 493154bc..07eef05c 100644 --- a/templates/pages/store/_product_permutations.html +++ b/templates/pages/store/_product_permutations.html @@ -40,6 +40,15 @@ {% endfor %} +
+
+ {{ model.form_filters.active.label }} + {{ model.form_filters.active() }} + {% for error in model.form_filters.active.errors %} +

{{ error }}

+ {% endfor %} +
+
{{ model.form_filters.quantity_min.label }}