From c133ba5f6ee61465263bad7ae0b89d952eb73265 Mon Sep 17 00:00:00 2001
From: berk76
Date: Wed, 13 Nov 2024 23:00:57 +0100
Subject: [PATCH] Fault report on behalf of (#112)
* Fault report on behalf of
* Translations
* Tests
---
svjis/articles/forms.py | 16 +-
.../articles/locale/cs/LC_MESSAGES/django.po | 8 +-
.../articles/locale/en/LC_MESSAGES/django.po | 8 +-
svjis/articles/templates/faults_create.html | 6 +
svjis/articles/templates/faults_edit.html | 1 +
svjis/articles/tests/factories/__init__.py | 4 +
svjis/articles/tests/factories/company.py | 18 +
svjis/articles/tests/factories/preferences.py | 11 +
svjis/articles/tests/test_articles.py | 195 +++++++++++
svjis/articles/tests/test_faults.py | 75 +++++
svjis/articles/tests/test_menu.py | 72 ++++
svjis/articles/tests/test_migrations.py | 17 +
svjis/articles/tests/test_views.py | 308 ------------------
svjis/articles/tests/testdata/__init__.py | 2 +
.../tests/testdata/preferences_data.py | 14 +
svjis/articles/tests/testdata/user_data.py | 17 +-
svjis/articles/utils.py | 2 +-
svjis/articles/views_faults.py | 68 ++--
18 files changed, 493 insertions(+), 349 deletions(-)
create mode 100644 svjis/articles/tests/factories/company.py
create mode 100644 svjis/articles/tests/factories/preferences.py
create mode 100644 svjis/articles/tests/test_articles.py
create mode 100644 svjis/articles/tests/test_faults.py
create mode 100644 svjis/articles/tests/test_menu.py
create mode 100644 svjis/articles/tests/test_migrations.py
delete mode 100644 svjis/articles/tests/test_views.py
create mode 100644 svjis/articles/tests/testdata/preferences_data.py
diff --git a/svjis/articles/forms.py b/svjis/articles/forms.py
index 0555cc8..b1d4922 100644
--- a/svjis/articles/forms.py
+++ b/svjis/articles/forms.py
@@ -245,7 +245,7 @@ def label_from_instance(self, obj):
class BoardForm(forms.ModelForm):
- member = MemberModelChoiceField(queryset=User.objects.filter(is_active=True).order_by('last_name'))
+ member = MemberModelChoiceField(queryset=User.objects.filter(is_active=True).order_by('last_name', 'first_name'))
class Meta:
model = models.Board
@@ -311,7 +311,7 @@ class Meta:
}
-class AssignedUserChoiceField(forms.ModelChoiceField):
+class UserChoiceField(forms.ModelChoiceField):
def label_from_instance(self, obj):
return f"{obj.last_name} {obj.first_name}"
@@ -323,24 +323,30 @@ class FaultReportForm(forms.ModelForm):
help_text=_(SELECT_ENTRANCE_TEXT),
label=_("Entrance"),
)
- assigned_to_user = AssignedUserChoiceField(
+ assigned_to_user = UserChoiceField(
queryset=User.objects.filter(groups__permissions__codename='svjis_fault_resolver')
.exclude(is_active=False)
.distinct()
- .order_by('last_name'),
+ .order_by('last_name', 'first_name'),
required=False,
label=_("Resolver"),
)
+ created_by_user = UserChoiceField(
+ queryset=User.objects.exclude(is_active=False).distinct().order_by('last_name', 'first_name'),
+ required=False,
+ label=_("On Behalf Of"),
+ )
class Meta:
model = models.FaultReport
- fields = ("subject", "entrance", "description", "assigned_to_user", "closed")
+ fields = ("subject", "entrance", "description", "created_by_user", "assigned_to_user", "closed")
widgets = {
'subject': forms.widgets.TextInput(attrs={'class': 'common-input', 'size': '80'}),
'entrance': forms.widgets.Select(attrs={'class': 'common-input'}),
'description': forms.widgets.Textarea(
attrs={'class': 'common-textarea', 'rows': '5', 'cols': '80', 'wrap': True}
),
+ 'created_by_user': forms.widgets.Select(attrs={'class': 'common-input'}),
'assigned_to_user': forms.widgets.Select(attrs={'class': 'common-input'}),
'closed': forms.widgets.CheckboxInput(attrs={'class': 'common-input', 'size': '50'}),
}
diff --git a/svjis/articles/locale/cs/LC_MESSAGES/django.po b/svjis/articles/locale/cs/LC_MESSAGES/django.po
index 9b25000..e413101 100644
--- a/svjis/articles/locale/cs/LC_MESSAGES/django.po
+++ b/svjis/articles/locale/cs/LC_MESSAGES/django.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2024-10-10 10:18+0200\n"
+"POT-Creation-Date: 2024-11-11 19:21+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -32,6 +32,10 @@ msgstr "Vchod"
msgid "Resolver"
msgstr "Řešitel"
+#: articles/forms.py:337
+msgid "On Behalf Of"
+msgstr "Za uživatele"
+
#: articles/models.py:14 articles/models.py:130 articles/models.py:440
#: articles/templates/redaction_useful_link.html:13
msgid "Header"
@@ -318,7 +322,7 @@ msgstr "Smazat"
#: articles/templates/admin_preferences_edit.html:27
#: articles/templates/admin_user_edit.html:94
#: articles/templates/advert_edit.html:41
-#: articles/templates/faults_create.html:31
+#: articles/templates/faults_create.html:37
#: articles/templates/faults_edit.html:34
#: articles/templates/personal_settings_edit.html:58
#: articles/templates/personal_settings_password.html:26
diff --git a/svjis/articles/locale/en/LC_MESSAGES/django.po b/svjis/articles/locale/en/LC_MESSAGES/django.po
index be61439..793eace 100644
--- a/svjis/articles/locale/en/LC_MESSAGES/django.po
+++ b/svjis/articles/locale/en/LC_MESSAGES/django.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2024-10-10 10:18+0200\n"
+"POT-Creation-Date: 2024-11-11 19:20+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -31,6 +31,10 @@ msgstr "Entrance"
msgid "Resolver"
msgstr "Resolver"
+#: articles/forms.py:337
+msgid "On Behalf Of"
+msgstr "On Behalf Of"
+
#: articles/models.py:14 articles/models.py:130 articles/models.py:440
#: articles/templates/redaction_useful_link.html:13
msgid "Header"
@@ -317,7 +321,7 @@ msgstr "Delete"
#: articles/templates/admin_preferences_edit.html:27
#: articles/templates/admin_user_edit.html:94
#: articles/templates/advert_edit.html:41
-#: articles/templates/faults_create.html:31
+#: articles/templates/faults_create.html:37
#: articles/templates/faults_edit.html:34
#: articles/templates/personal_settings_edit.html:58
#: articles/templates/personal_settings_password.html:26
diff --git a/svjis/articles/templates/faults_create.html b/svjis/articles/templates/faults_create.html
index f471c32..8b84c05 100644
--- a/svjis/articles/templates/faults_create.html
+++ b/svjis/articles/templates/faults_create.html
@@ -22,6 +22,12 @@ {% trans 'Fault report' %}
{{ form.description }}
{% if perms.articles.svjis_fault_resolver %}
+