diff --git a/castellum/contacts/forms.py b/castellum/contacts/forms.py index ce5c12418931d2fa79dd75da1133705589ae4b92..446592f227297e5aae000d04503f51f9ada94f42 100644 --- a/castellum/contacts/forms.py +++ b/castellum/contacts/forms.py @@ -210,11 +210,13 @@ class SearchForm(forms.Form): label=_('Search for name, phone number or email address'), required=True, ) + action = forms.CharField(required=False) def clean(self): cleaned_data = super().clean() search = cleaned_data.get('search', '') + action = cleaned_data.get('action', 'search') names = [] phone_numbers = [] @@ -227,11 +229,15 @@ class SearchForm(forms.Form): else: names.append(part) - if not (len(names) > 1 or phone_numbers or emails): - self.add_error( - 'search', - _('At least full name, phone number or email address have to be provided'), - ) + if action in ['create', 'force-create']: + if not len(names) > 1: + self.add_error('search', _('The full name is required to create a subject')) + else: + if not (len(names) > 1 or phone_numbers or emails): + self.add_error( + 'search', + _('At least full name, phone number or email address have to be provided'), + ) cleaned_data['first_name'] = names[0] if names else '' cleaned_data['last_name'] = ' '.join(names[1:]) diff --git a/castellum/subjects/templates/subjects/maintenance_subjectcreationrequest.html b/castellum/subjects/templates/subjects/maintenance_subjectcreationrequest.html index abab69c41204b64a2ca0dcd97f27254356311080..c3048bc9e3e3d8f5e1d354f93516bbd710674711 100644 --- a/castellum/subjects/templates/subjects/maintenance_subjectcreationrequest.html +++ b/castellum/subjects/templates/subjects/maintenance_subjectcreationrequest.html @@ -32,6 +32,7 @@
diff --git a/castellum/subjects/templates/subjects/subject_search.html b/castellum/subjects/templates/subjects/subject_search.html index 199e6462d49e545b2aa4eddb2f0c4dabb38c4515..e364a6b12da3ac37b1efb57152131e5a83aaf442 100644 --- a/castellum/subjects/templates/subjects/subject_search.html +++ b/castellum/subjects/templates/subjects/subject_search.html @@ -4,220 +4,213 @@ {% block title %}{% translate "Subjects" %} · {{ block.super }}{% endblock %} {% block content %} + {% has_perm 'subjects.change_subject' user as can_change_subject %} + {% has_perm 'subjects.view_subject' user as can_view_subject %} + {% if subjectcreationrequest %} {% url 'subjects:maintenance-subjectcreationrequest-delete' subjectcreationrequest.pk as discard_url %}{% blocktranslate with name=subjectcreationrequest.contact.full_name discard_url=discard_url %}Please make sure that {{ name }} does not yet exist in the database. If you find duplicates, you can also discard this request.{% endblocktranslate %}
{% endif %} - +{% translate 'Please check these matches before creating a new subjects.' %}
+ {% endif %} + {% if not can_view_subject %} +{% translate 'This list may be restricted based on your permissions.' %}
{% endif %} -{% translate 'This list may be restricted based on your permissions.' %}
- {% endif %} - -{% translate 'Total number of subjects' %}: {{ count_total }}
+