From 256ee795e13680079c4b8bf220c5392e0c52d2ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20Buja=C4=8Dek?= Date: Tue, 12 Dec 2023 20:47:39 +0100 Subject: [PATCH] Feature/obligee action direct classification (#438) * feat: Add obligee action wizard step * feat: Add Direct Classification to the Obligee action wizard --- .../apps/inforequests/forms/obligee_action.py | 145 ++++++++++++++++-- .../texts/direct_classification.html | 17 ++ .../obligee_action/texts/wizard.html | 17 ++ chcemvediet/locale/sk/LC_MESSAGES/django.po | 39 +++++ 4 files changed, 208 insertions(+), 10 deletions(-) create mode 100644 chcemvediet/apps/inforequests/templates/inforequests/obligee_action/texts/direct_classification.html create mode 100644 chcemvediet/apps/inforequests/templates/inforequests/obligee_action/texts/wizard.html diff --git a/chcemvediet/apps/inforequests/forms/obligee_action.py b/chcemvediet/apps/inforequests/forms/obligee_action.py index 2c1ba49e9..69df2050e 100644 --- a/chcemvediet/apps/inforequests/forms/obligee_action.py +++ b/chcemvediet/apps/inforequests/forms/obligee_action.py @@ -20,6 +20,18 @@ from chcemvediet.apps.inforequests.forms import BranchField, RefusalReasonField +def set_clarification_request(res): + res.globals[u'result'] = u'action' + res.globals[u'action'] = Action.TYPES.CLARIFICATION_REQUEST + res.next = Categorized + + +def set_confirmation(res): + res.globals[u'result'] = u'action' + res.globals[u'action'] = Action.TYPES.CONFIRMATION + res.next = Categorized + + class ObligeeActionStep(Step): template = u'inforequests/obligee_action/wizard.html' form_template = u'main/forms/form_horizontal.html' @@ -259,7 +271,7 @@ def pre_transition(self): class IsItExtension(ObligeeActionStep): label = _(u'inforequests:obligee_action:IsItExtension:label') text_template = u'inforequests/obligee_action/texts/is_extension.html' - global_fields = [u'extension'] + global_fields = [u'is_extension', u'extension'] def add_fields(self): super(IsItExtension, self).add_fields() @@ -271,6 +283,7 @@ def add_fields(self): (1, _(u'inforequests:obligee_action:IsItExtension:yes')), (0, _(u'inforequests:obligee_action:IsItExtension:no')), ), + initial=1 if self.wizard.values.get(u'is_extension') else None, widget=forms.RadioSelect(attrs={ u'class': u'pln-toggle-changed', u'data-container': u'form', @@ -339,7 +352,7 @@ def pre_transition(self): class IsItAdvancement(ObligeeActionStep): label = _(u'inforequests:obligee_action:IsItAdvancement:label') text_template = u'inforequests/obligee_action/texts/is_advancement.html' - global_fields = [u'advanced_to'] + global_fields = [u'is_advancement', u'advanced_to'] def add_fields(self): super(IsItAdvancement, self).add_fields() @@ -351,6 +364,7 @@ def add_fields(self): (1, _(u'inforequests:obligee_action:IsItAdvancement:yes')), (0, _(u'inforequests:obligee_action:IsItAdvancement:no')), ), + initial=1 if self.wizard.values.get(u'is_advancement') else None, widget=forms.RadioSelect(attrs={ u'class': u'pln-toggle-changed', u'data-container': u'form', @@ -838,9 +852,7 @@ def post_transition(self): if not self.is_valid(): res.next = CanAddRemandmentAffirmationOrReversion elif self.cleaned_data[u'is_confirmation']: - res.globals[u'result'] = u'action' - res.globals[u'action'] = Action.TYPES.CONFIRMATION - res.next = Categorized + set_confirmation(res) else: res.next = CanAddRemandmentAffirmationOrReversion @@ -886,9 +898,7 @@ def post_transition(self): if not self.is_valid(): res.next = CanAddConfirmation elif self.cleaned_data[u'is_question']: - res.globals[u'result'] = u'action' - res.globals[u'action'] = Action.TYPES.CLARIFICATION_REQUEST - res.next = Categorized + set_clarification_request(res) else: res.next = CanAddConfirmation @@ -913,11 +923,126 @@ def pre_transition(self): # Prologue +class DirectClassification(ObligeeActionStep): + label = _(u'inforequests:obligee_action:DirectClassification:label') + text_template = u'inforequests/obligee_action/texts/direct_classification.html' + + def add_fields(self): + super(DirectClassification, self).add_fields() + branch = self.wizard.values.get(u'branch', None) + + choices = [] + + if branch and branch.can_add_clarification_request: + choices.append( + (u'question', _(u'inforequests:obligee_action:DirectClassification:question')) + ) + + if branch and branch.can_add_confirmation: + choices.append( + (u'confirmation', _(u'inforequests:obligee_action:DirectClassification:confirmation')) + ) + + if branch.can_add_remandment_affirmation_or_reversion: + choices.append( + (u'appeal_decision', _(u'inforequests:obligee_action:DirectClassification:appeal_decision')) + ) + + if branch.can_add_advancement: + choices.append( + (u'advancement', _(u'inforequests:obligee_action:DirectClassification:advancement')) + ) + + if branch.can_add_extension: + choices.append( + (u'extension', _(u'inforequests:obligee_action:DirectClassification:extension')) + ) + + choices.extend([ + (u'contains_info:full', _(u'inforequests:obligee_action:DirectClassification:contains_info:full')), + (u'contains_info:partial', _(u'inforequests:obligee_action:DirectClassification:contains_info:partial')), + (u'contains_info:none', _(u'inforequests:obligee_action:DirectClassification:contains_info:none')), + (u'off_topic', _(u'inforequests:obligee_action:DirectClassification:off_topic')), + ]) + + self.fields[u'type'] = forms.ChoiceField( + label=u' ', + choices=choices, + widget=forms.RadioSelect(), + ) + + def post_transition(self): + res = super(DirectClassification, self).post_transition() + + if not self.is_valid(): + res.next = CanAddClarificationRequest + elif self.is_type(u'question'): + set_clarification_request(res) + elif self.is_type(u'confirmation'): + set_confirmation(res) + elif self.is_type(u'appeal_decision'): + res.next = ContainsAppealInfo + elif self.is_type(u'contains_info:full'): + res.globals[u'disclosure_level'] = Action.DISCLOSURE_LEVELS.FULL + res.next = CanAddDisclosure + elif self.is_type(u'contains_info:partial'): + res.globals[u'disclosure_level'] = Action.DISCLOSURE_LEVELS.PARTIAL + res.next = IsItDecision + elif self.is_type(u'contains_info:none'): + res.globals[u'disclosure_level'] = Action.DISCLOSURE_LEVELS.NONE + res.next = IsItDecision + elif self.is_type(u'off_topic'): + res.next = NotCategorized + elif self.is_type(u'advancement'): + res.globals[u'is_advancement'] = 1 + res.next = IsItAdvancement + elif self.is_type(u'extension'): + res.globals[u'is_extension'] = 1 + res.next = IsItExtension + else: + res.next = CanAddClarificationRequest + + return res + + def is_type(self, value): + return self.cleaned_data[u'type'] == value + + +class ShouldUseWizard(ObligeeActionStep): + label = _(u'inforequests:obligee_action:ShouldUseWizard:label') + text_template = u'inforequests/obligee_action/texts/wizard.html' + + def add_fields(self): + super(ShouldUseWizard, self).add_fields() + + self.fields[u'use_wizard'] = forms.TypedChoiceField( + label=u' ', + coerce=int, + choices=( + (1, _(u'inforequests:obligee_action:ShouldUseWizard:yes')), + (0, _(u'inforequests:obligee_action:ShouldUseWizard:no')) + ), + widget=forms.RadioSelect(), + ) + + def post_transition(self): + res = super(ShouldUseWizard, self).post_transition() + + if not self.is_valid(): + res.next = CanAddClarificationRequest + elif not self.cleaned_data[u'use_wizard']: + res.next = DirectClassification + else: + res.next = CanAddClarificationRequest + + return res + + class InputBasics(ObligeeActionStep): label = _(u'inforequests:obligee_action:InputBasics:label') text_template = u'inforequests/obligee_action/texts/basics.html' global_fields = [u'delivered_date', u'attachments'] - post_step_class = CanAddClarificationRequest + post_step_class = ShouldUseWizard def add_fields(self): super(InputBasics, self).add_fields() @@ -982,7 +1107,7 @@ def pre_transition(self): if self.wizard.email: res.globals[u'delivered_date'] = local_date(self.wizard.email.processed) res.globals[u'attachments'] = None - res.next = CanAddClarificationRequest + res.next = ShouldUseWizard else: res.next = InputBasics diff --git a/chcemvediet/apps/inforequests/templates/inforequests/obligee_action/texts/direct_classification.html b/chcemvediet/apps/inforequests/templates/inforequests/obligee_action/texts/direct_classification.html new file mode 100644 index 000000000..1aad8dc76 --- /dev/null +++ b/chcemvediet/apps/inforequests/templates/inforequests/obligee_action/texts/direct_classification.html @@ -0,0 +1,17 @@ +{# vim: set filetype=htmldjango shiftwidth=2 :#} + +{% comment %} + % + % Context: + % -- wizard: chcemvediet.apps.inforequests.forms.obligee_action.ObligeeActionWizard + % -- step: chcemvediet.apps.inforequests.forms.obligee_action.DirectClassification + % -- inforequest: chcemvediet.apps.inforequests.models.Inforequest + % -- email: poleno.mail.models.Message | None + % +{% endcomment %} + + +

Priame zaradenie odpovede

+

+ Zvoľte typ odpovede od inštitúcie. +

diff --git a/chcemvediet/apps/inforequests/templates/inforequests/obligee_action/texts/wizard.html b/chcemvediet/apps/inforequests/templates/inforequests/obligee_action/texts/wizard.html new file mode 100644 index 000000000..f185c1667 --- /dev/null +++ b/chcemvediet/apps/inforequests/templates/inforequests/obligee_action/texts/wizard.html @@ -0,0 +1,17 @@ +{# vim: set filetype=htmldjango shiftwidth=2 :#} + +{% comment %} + % + % Context: + % -- wizard: chcemvediet.apps.inforequests.forms.obligee_action.ObligeeActionWizard + % -- step: chcemvediet.apps.inforequests.forms.obligee_action.ShouldUseWizard + % -- inforequest: chcemvediet.apps.inforequests.models.Inforequest + % -- email: poleno.mail.models.Message | None + % +{% endcomment %} + + +

Chcete použiť na zaradenie odpovede sprievodcu?

+

+ Sprievodca vám pomocou položení jednoduchých otázok pomôže správne zaradiť prijatú správu. +

diff --git a/chcemvediet/locale/sk/LC_MESSAGES/django.po b/chcemvediet/locale/sk/LC_MESSAGES/django.po index 3398c728f..ffe89a992 100644 --- a/chcemvediet/locale/sk/LC_MESSAGES/django.po +++ b/chcemvediet/locale/sk/LC_MESSAGES/django.po @@ -521,6 +521,45 @@ msgstr "Popíšte adminovi, čo sa stalo" msgid "inforequests:obligee_action:ReversionReasons:label" msgstr "Predĺženie lehoty" +msgid "inforequests:obligee_action:ShouldUseWizard:label" +msgstr "Použiť sprievodcu?" + +msgid "inforequests:obligee_action:ShouldUseWizard:yes" +msgstr "Áno, chcem použiť sprievodcu." + +msgid "inforequests:obligee_action:ShouldUseWizard:no" +msgstr "Nie, chcem odpoveď zaradiť priamo." + +msgid "inforequests:obligee_action:DirectClassification:label" +msgstr "Priame zaradenie odpovede" + +msgid "inforequests:obligee_action:DirectClassification:question" +msgstr "Výzva na doplnenie žiadosti: odpoveď je otázka a inštitúcia vyžaduje doplnenie žiadosti o ďalšie informácie." + +msgid "inforequests:obligee_action:DirectClassification:confirmation" +msgstr "Potvrdenie prijatia žiadosti: odpoveď je iba potvrdenie, že inštitúcia dostala moju žiadosť." + +msgid "inforequests:obligee_action:DirectClassification:appeal_decision" +msgstr "Odpoveď je rozhodnutie o mojom odvolaní." + +msgid "inforequests:obligee_action:DirectClassification:contains_info:full" +msgstr "Sprístupnenie informácií: inštitúcia mi poslala všetky požadované informácie." + +msgid "inforequests:obligee_action:DirectClassification:contains_info:partial" +msgstr "Čiastočné sprístupnenie informácií: inštitúcia mi poslala časť požadovaných informácií." + +msgid "inforequests:obligee_action:DirectClassification:contains_info:none" +msgstr "Nesprístupnenie informácií: inštitúcia mi neposlala žiadne informácie." + +msgid "inforequests:obligee_action:DirectClassification:off_topic" +msgstr "Správa sa nijak netýka mojej žiadosti." + +msgid "inforequests:obligee_action:DirectClassification:advancement" +msgstr "Postúpenie žiadosti: inštitúcia postupuje moju žiadosť inej inštitúcii." + +msgid "inforequests:obligee_action:DirectClassification:extension" +msgstr "Predĺženie lehoty: inštitúcia predlžuje lehotu na vybavenie žiadosti." + msgid "inforequests:obligee_action:WasItReturned:label" msgstr "Vrátenie"