Fixes and improvements
* fixes group check on detail views * adds check for required fields in BaseForm for showing required field hint or not in template
This commit is contained in:
parent
cd5b2e264b
commit
d773c3b3d4
@ -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)
|
||||
|
@ -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:
|
||||
|
@ -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!
|
||||
|
@ -17,4 +17,6 @@
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<small>{% trans 'Fields with * are required.' %}</small>
|
||||
{% if form.has_required_fields %}
|
||||
<small>{% trans 'Fields with * are required.' %}</small>
|
||||
{% endif %}
|
Loading…
Reference in New Issue
Block a user