Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/obligee action direct classification #438

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 135 additions & 10 deletions chcemvediet/apps/inforequests/forms/obligee_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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()
Expand All @@ -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',
Expand Down Expand Up @@ -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()
Expand All @@ -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',
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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()
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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 %}


<h4>Priame zaradenie odpovede</h4>
<p>
Zvoľte typ odpovede od inštitúcie.
</p>
Original file line number Diff line number Diff line change
@@ -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 %}


<h4>Chcete použiť na zaradenie odpovede sprievodcu?</h4>
<p>
Sprievodca vám pomocou položení jednoduchých otázok pomôže správne zaradiť prijatú správu.
</p>
39 changes: 39 additions & 0 deletions chcemvediet/locale/sk/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down