diff --git a/compensation/views.py b/compensation/views.py index 98fe64c7..563c1f75 100644 --- a/compensation/views.py +++ b/compensation/views.py @@ -95,9 +95,9 @@ def open_view(request: HttpRequest, id: str): "sum_before_states": sum_before_states, "sum_after_states": sum_after_states, "diff_states": diff_states, - "is_default_member": in_group(_user, _(DEFAULT_GROUP)), - "is_zb_member": in_group(_user, _(ZB_GROUP)), - "is_ets_member": in_group(_user, _(ETS_GROUP)), + "is_default_member": in_group(_user, DEFAULT_GROUP), + "is_zb_member": in_group(_user, ZB_GROUP), + "is_ets_member": in_group(_user, ETS_GROUP), } context = BaseContext(request, context).context return render(request, template, context) diff --git a/intervention/views.py b/intervention/views.py index 9c8e3549..cbbcf834 100644 --- a/intervention/views.py +++ b/intervention/views.py @@ -122,9 +122,9 @@ def open_view(request: HttpRequest, id: str): "compensations": compensations, "has_access": is_data_shared, "geom_form": geom_form, - "is_default_member": in_group(_user, _(DEFAULT_GROUP)), - "is_zb_member": in_group(_user, _(ZB_GROUP)), - "is_ets_member": in_group(_user, _(ETS_GROUP)), + "is_default_member": in_group(_user, DEFAULT_GROUP), + "is_zb_member": in_group(_user, ZB_GROUP), + "is_ets_member": in_group(_user, ETS_GROUP), } if not is_data_shared: diff --git a/konova/forms.py b/konova/forms.py index c774e91b..72bc1838 100644 --- a/konova/forms.py +++ b/konova/forms.py @@ -37,12 +37,19 @@ class BaseForm(forms.Form): form_caption = None instance = None # The data holding model object form_attrs = {} # Holds additional attributes, that can be used in the template + has_required_fields = False # Automatically set. Triggers hint rendering in templates def __init__(self, *args, **kwargs): self.instance = kwargs.pop("instance", None) self.user = kwargs.pop("user", None) super().__init__(*args, **kwargs) + # Check for required fields + for _field_name, _field_val in self.fields.items(): + if _field_val.required: + self.has_required_fields = True + break + @abstractmethod def save(self): # To be implemented in subclasses! diff --git a/templates/table/generic_table_form_body.html b/templates/table/generic_table_form_body.html index ba618b8e..8c173481 100644 --- a/templates/table/generic_table_form_body.html +++ b/templates/table/generic_table_form_body.html @@ -17,4 +17,6 @@ {% endfor %} - {% trans 'Fields with * are required.' %} \ No newline at end of file + {% if form.has_required_fields %} + {% trans 'Fields with * are required.' %} + {% endif %} \ No newline at end of file