Fix: Removal of filter methods from controllers.

This commit is contained in:
2024-11-17 15:17:57 +00:00
parent a2af292726
commit 197f6ec5bc
44 changed files with 1317 additions and 927 deletions

View File

@@ -42,38 +42,6 @@ def suppliers():
return redirect(url_for('routes_core.home'))
return render_template('pages/store/_suppliers.html', model = model, datetime = datetime)
@routes_store_supplier.route(Model_View_Store_Supplier.HASH_GET_STORE_SUPPLIER, methods=['POST'])
def filter_supplier():
data = Helper_App.get_request_data(request)
try:
form_filters = Filters_Supplier.from_json(data)
if not form_filters.validate_on_submit():
error_keys = list(form_filters.errors.keys())
try:
error_keys.remove(Supplier.ATTR_ID_PRODUCT_CATEGORY)
except:
pass
try:
error_keys.remove(Supplier.ATTR_ID_PRODUCT)
except:
pass
if error_keys:
return jsonify({
Model_View_Store_Supplier.FLAG_STATUS: Model_View_Store_Supplier.FLAG_FAILURE,
Model_View_Store_Supplier.FLAG_MESSAGE: f'Form invalid.\n{form_filters.errors}'
})
model = Model_View_Store_Supplier(form_filters_old = form_filters)
if not model.is_user_logged_in:
raise Exception('User not logged in.')
return jsonify({
Model_View_Store_Supplier.FLAG_STATUS: Model_View_Store_Supplier.FLAG_SUCCESS,
Model_View_Store_Supplier.FLAG_DATA: {supplier.id_supplier: supplier.to_json() for supplier in model.suppliers}
})
except Exception as e:
return jsonify({
Model_View_Store_Supplier.FLAG_STATUS: Model_View_Store_Supplier.FLAG_FAILURE,
Model_View_Store_Supplier.FLAG_MESSAGE: f'Bad data received by controller.\n{e}'
})
@routes_store_supplier.route(Model_View_Store_Supplier.HASH_SAVE_STORE_SUPPLIER, methods=['POST'])
def save_supplier():