From dbeec9962d7bd72c4d8fe882e4dcb09d27602586 Mon Sep 17 00:00:00 2001 From: pjpatil12 Date: Tue, 24 Mar 2026 15:19:38 +0530 Subject: [PATCH] hold type updated , delete done by prajkta --- controllers/hold_types_controller.py | 12 +- model/ItemCRUD.py | 6 +- model/Utilities.py | 1 + static/js/hold_types.js | 2 +- templates/add_hold_type.html | 106 ++++---- templates/edit_hold_type.html | 17 +- templates/edit_invoice.html | 368 ++++++++++++++------------- 7 files changed, 269 insertions(+), 243 deletions(-) diff --git a/controllers/hold_types_controller.py b/controllers/hold_types_controller.py index 0b163ab..40b2b20 100644 --- a/controllers/hold_types_controller.py +++ b/controllers/hold_types_controller.py @@ -10,21 +10,21 @@ hold_bp = Blueprint("hold_types", __name__) @hold_bp.route('/add_hold_type', methods=['GET','POST']) @login_required def add_hold_type(): - - hold = HoldTypes() + hold = HoldTypes() if request.method == 'POST': - hold.AddHoldType(request) # ✅ - return hold.resultMessage + hold.AddHoldType(request) + # ✅ Always redirect to same page (NO JSON) + return redirect(url_for("hold_types.add_hold_type")) - hold_types = hold.GetAllHoldTypes() # ✅ + # GET request → show data + hold_types = hold.GetAllHoldTypes() return render_template( "add_hold_type.html", Hold_Types_data=hold_types ) - # ---------------- CHECK HOLD TYPE (OPTIONAL LIKE BLOCK) ---------------- @hold_bp.route('/check_hold_type', methods=['POST']) @login_required diff --git a/model/ItemCRUD.py b/model/ItemCRUD.py index 19f8dfb..59d7469 100644 --- a/model/ItemCRUD.py +++ b/model/ItemCRUD.py @@ -135,7 +135,7 @@ class ItemCRUD: # ====================================================== # NORMAL (Village / Block / State) # ====================================================== - if not re.match(RegEx.patternAlphabetOnly, childname): + if not re.match(RegEx.allPattern, childname): self.isSuccess = False self.resultMessage = HtmlHelper.json_response( ResponseHandler.invalid_name(self.itemCRUDMapping.name), 400 @@ -226,7 +226,7 @@ class ItemCRUD: # ====================================================== # NORMAL # ====================================================== - if not re.match(RegEx.patternAlphabetOnly, childname): + if not re.match(RegEx.allPattern, childname): self.isSuccess = False self.resultMessage = ResponseHandler.update_failure(self.itemCRUDMapping.name)['message'] return @@ -324,7 +324,7 @@ class ItemCRUD: f"User {current_user.id} checked '{childname}'" ) - if not re.match(RegEx.patternAlphabetOnly, childname): + if not re.match(RegEx.allPattern, childname): return HtmlHelper.json_response( ResponseHandler.invalid_name(self.itemCRUDMapping.name), 400 ) diff --git a/model/Utilities.py b/model/Utilities.py index 1b88456..a96e800 100644 --- a/model/Utilities.py +++ b/model/Utilities.py @@ -12,6 +12,7 @@ class ItemCRUDType(Enum): class RegEx: patternAlphabetOnly = "^[A-Za-z ]+$" + allPattern = "^(?!\s*$).+" class ResponseHandler: diff --git a/static/js/hold_types.js b/static/js/hold_types.js index 47f7e18..492a824 100644 --- a/static/js/hold_types.js +++ b/static/js/hold_types.js @@ -3,7 +3,7 @@ $(document).ready(function () { let holdType = $(this).val().replace(/^\s+/, ""); $(this).val(holdType); - let reg = /^[A-Za-z]/; + let reg = /^.+$/; // all pattern allow if (!reg.test(holdType)) { $("#holdTypeMessage").text("Hold Type must start with a letter.").css("color", "red"); diff --git a/templates/add_hold_type.html b/templates/add_hold_type.html index 1a60ea5..a65d0e4 100644 --- a/templates/add_hold_type.html +++ b/templates/add_hold_type.html @@ -1,59 +1,73 @@ {% extends 'base.html' %} {% block content %} + Manage Hold Types - + + -
- - -
+
+ + +
-
-

Add Hold Types

-
- - - - -
-
- - + -{% endblock %} - +{% endblock %} \ No newline at end of file diff --git a/templates/edit_hold_type.html b/templates/edit_hold_type.html index 525e5b1..a0a2123 100644 --- a/templates/edit_hold_type.html +++ b/templates/edit_hold_type.html @@ -1,7 +1,7 @@ - {% extends 'base.html' %} {% block content %} + Edit Hold Type @@ -10,10 +10,10 @@

Edit Hold Type

-
- + + - +
@@ -37,7 +37,7 @@ formData.append('hold_type', newHoldType); $.ajax({ - url: '/update_hold_type/' + holdTypeId, + url: '/edit_hold_type/' + holdTypeId, method: 'POST', data: formData, processData: false, @@ -54,9 +54,4 @@ }); }); -{% endblock %} - - - - - +{% endblock %} \ No newline at end of file diff --git a/templates/edit_invoice.html b/templates/edit_invoice.html index c2a5f7a..6d1c245 100644 --- a/templates/edit_invoice.html +++ b/templates/edit_invoice.html @@ -2,8 +2,8 @@ {% block content %} - - + + Edit Invoice @@ -12,158 +12,174 @@ -
-

Edit Invoice

+
+

Edit Invoice

- - -
- - -
-
- - - - -
-
- - -
-
- - - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- {% set seen_types = [] %} - {% for hold in invoice.hold_amounts %} - {% if hold.hold_type not in seen_types %} - {% set _ = seen_types.append(hold.hold_type) %} -
- - - - - -
- {% endif %} - {% endfor %} -
- - -
- -
- - -
-
- - -
-
- - -
-
- - - -
-
- - - + {% endblock %} \ No newline at end of file