From d899d0d86a020c461d65f2747ce49e2d839741a7 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 16 Feb 2026 14:24:07 +0000 Subject: [PATCH] Enhance ProcedureForm and ProcedureCreate: add form helper initialization, update procedure form action URL, and implement logging in dispatch method --- atlas/forms.py | 15 ++ atlas/templates/atlas/categories_list.html | 206 ++++++++++----------- atlas/templates/atlas/procedure_form.html | 4 +- atlas/views.py | 8 + 4 files changed, 128 insertions(+), 105 deletions(-) diff --git a/atlas/forms.py b/atlas/forms.py index f5f65a62..40c2129d 100755 --- a/atlas/forms.py +++ b/atlas/forms.py @@ -400,6 +400,16 @@ class ProcedureForm(ModelForm): class Meta: model = Procedure exclude = [] + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + try: + self.helper = FormHelper() + self.helper.form_method = "post" + # Prevent crispy from rendering its own
tag so our + # template-level form wrapper contains the submit buttons. + self.helper.form_tag = False + except Exception: + pass class SeriesFindingForm(ModelForm): @@ -624,6 +634,7 @@ class CaseForm(ModelForm): "presentation", "discussion", "report", + "procedures", "condition", "pathological_process", "open_access", @@ -655,6 +666,7 @@ class CaseForm(ModelForm): "history", "presentation", "discussion", + "procedures", "condition", "pathological_process", "report", @@ -684,6 +696,9 @@ class CaseForm(ModelForm): "subspecialty": CheckboxSelectMultiple(), "pathological_process": CheckboxSelectMultiple(), "previous_case": CaseSelect(), + "procedures": autocomplete.ModelSelect2Multiple( + url="atlas:procedure-autocomplete" + ), } def clean_cimar_uuid(self): diff --git a/atlas/templates/atlas/categories_list.html b/atlas/templates/atlas/categories_list.html index 216ac68a..1eda77d7 100644 --- a/atlas/templates/atlas/categories_list.html +++ b/atlas/templates/atlas/categories_list.html @@ -1,8 +1,8 @@ {% extends 'atlas/base.html' %} {% block content %} -

Categories

-

The platform has numberous different ways to tag and categorise content. These help with organsing cases and series, given the ability to find cases by a particuarly property (such as a finding) or find similar cases.

These can be browsed below.

+

Categories

+

The platform has numberous different ways to tag and categorise content. These help with organsing cases and series, given the ability to find cases by a particuarly property (such as a finding) or find similar cases.

These can be browsed below.

-
+
{# HTMX loading indicator styles: hide by default, show when HTMX adds the .htmx-request class #} - + -

Alternatively you can use the search function below

+

Alternatively you can use the search function below

- -
- + +
+ {# Spinner shown while HTMX request is in-flight (selector matched by hx-indicator) #} - - - -
- - {# Collapsed advanced filters block - defaults to collapsed #} -
- - -
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
-
- - {# Spinner shown while HTMX request is in-flight (selector matched by hx-indicator) #} + +
+ + {# Collapsed advanced filters block - defaults to collapsed #} +
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+ + {# Spinner shown while HTMX request is in-flight (selector matched by hx-indicator) #} + + {% comment %} {% endcomment %} - -
+ +
-
- {% if results is not None %} - {% include 'atlas/_categories_search_results.html' %} - {% endif %} -
- - {% if request.user.is_staff %} -

Manage Examinations -

+
+ {% if results is not None %} + {% include 'atlas/_categories_search_results.html' %} {% endif %} +
+ + {% if request.user.is_staff %} +

Manage Examinations +

+ {% endif %} {% endblock %} diff --git a/atlas/templates/atlas/procedure_form.html b/atlas/templates/atlas/procedure_form.html index e4079dbb..0cb36f1c 100644 --- a/atlas/templates/atlas/procedure_form.html +++ b/atlas/templates/atlas/procedure_form.html @@ -10,12 +10,12 @@

Use this form to create or edit a procedure.

Please check if it already exists before doing so!

-
+ {% csrf_token %} {% crispy form %}
- + Cancel
diff --git a/atlas/views.py b/atlas/views.py index 9672b930..34915078 100755 --- a/atlas/views.py +++ b/atlas/views.py @@ -2769,6 +2769,14 @@ class ProcedureCreate(RevisionMixin, LoginRequiredMixin, CreateView): model = Procedure form_class = ProcedureForm template_name = "atlas/procedure_form.html" + def dispatch(self, request, *args, **kwargs): + try: + logger.debug("ProcedureCreate dispatch: method=%s, user=%s", request.method, request.user) + if request.method == 'POST': + logger.debug("ProcedureCreate POST data: %s", request.POST.dict()) + except Exception: + logger.exception("Error logging ProcedureCreate dispatch") + return super().dispatch(request, *args, **kwargs) def form_valid(self, form): self.object = form.save() return super().form_valid(form)