Skip to content

Commit

Permalink
Merge pull request #107 from forza-mor-rotterdam/taak-annuleren
Browse files Browse the repository at this point in the history
taak annuleren url, view, template, permissie
  • Loading branch information
mguikema authored Sep 20, 2023
2 parents 9f8a2e4 + eec6713 commit 8a54c18
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 16 deletions.
5 changes: 5 additions & 0 deletions app/apps/authorisatie/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class TaakAfrondenPermissie(BasisPermissie):
codenaam = "taak_afronden"


class TaakAnnulerenPermissie(BasisPermissie):
naam = "Taak annuleren"
codenaam = "taak_annuleren"


class GebruikerAanmakenPermissie(BasisPermissie):
naam = "Gebruiker aanmaken"
codenaam = "gebruiker_aanmaken"
Expand Down
2 changes: 0 additions & 2 deletions app/apps/regie/constanten.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
"naam_overledene": "Naam overledene",
"telefoon_melder": "Telefoonnummer",
"terugkoppeling_gewenst": "Is terugkoppeling gewenst?",
"niet_opgelost": "Niet opgelost",
"opgelost": "Opgelost",
}

MSB_WIJKEN = [
Expand Down
44 changes: 38 additions & 6 deletions app/apps/regie/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,31 @@ class MultipleChoiceField(forms.MultipleChoiceField):
None,
),
)

TAAK_STATUS_VOLTOOID = "voltooid"
TAAK_RESOLUTIE_OPGELOST = "opgelost"
TAAK_RESOLUTIE_NIET_OPGELOST = "niet_opgelost"
TAAK_RESOLUTIE_GEANNULEERD = "geannuleerd"

TAAK_BEHANDEL_OPTIES = (
(
"ja",
"Ja",
"We zijn met uw melding aan de slag gegaan en hebben het probleem opgelost.",
"voltooid",
"opgelost",
TAAK_STATUS_VOLTOOID,
TAAK_RESOLUTIE_OPGELOST,
),
(
"nee",
"Nee, het probleem kan niet worden opgelost.",
"We zijn met uw melding aan de slag gegaan, maar konden het probleem helaas niet oplossen. Want...",
"voltooid",
None,
TAAK_STATUS_VOLTOOID,
TAAK_RESOLUTIE_NIET_OPGELOST,
),
)

TAAK_BEHANDEL_STATUS = {bo[0]: bo[3] for bo in TAAK_BEHANDEL_OPTIES}
TAAK_BEHANDEL_RESOLUTIE = {bo[0]: bo[4] for bo in TAAK_BEHANDEL_OPTIES}
BEHANDEL_STATUS = {bo[0]: bo[3] for bo in BEHANDEL_OPTIES}
BEHANDEL_RESOLUTIE = {bo[0]: bo[4] for bo in BEHANDEL_OPTIES}


class CheckboxSelectMultipleThumb(forms.CheckboxSelectMultiple):
Expand Down Expand Up @@ -213,6 +217,34 @@ class TaakAfrondenForm(forms.Form):
)


class TaakAnnulerenForm(forms.Form):
bijlagen = forms.FileField(
widget=forms.widgets.FileInput(
attrs={
"accept": ".jpg, .jpeg, .png, .heic",
"data-action": "change->bijlagen#updateImageDisplay",
"data-bijlagen-target": "bijlagenAfronden",
}
),
label="Foto's",
required=False,
)

omschrijving_intern = forms.CharField(
label="Interne opmerking",
help_text="Je kunt deze tekst aanpassen of eigen tekst toevoegen.",
widget=forms.Textarea(
attrs={
"class": "form-control",
"data-testid": "information",
"rows": "4",
"data-meldingbehandelformulier-target": "internalText",
}
),
required=False,
)


class MeldingAfhandelenForm(forms.Form):

omschrijving_extern = forms.CharField(
Expand Down
61 changes: 61 additions & 0 deletions app/apps/regie/templates/melding/part_taak_annuleren.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{% load rotterdam_formulier_html %}
{% load vind_in_dict from querystring_tags %}
{% load to_date from date_tags %}
{% load json_encode from json_tags %}

<turbo-frame id="melding_actie_form">
<div class="modal-dialog modal-dialog--small">
<div class="modal-content">
<div class="modal-header">
<h1>
<span>Taak annuleren</span>
</h1>
<p>
{{ taakopdracht.titel }}
</p>
<button
type="button"
class="btn-close"
aria-label="Sluit"
data-action="detail#closeModal">
</button>
</div>
<div class="modal-body">
<form
action="{% url 'taak_annuleren' melding.uuid taakopdracht.uuid %}"
method="post"
class="form--horizontal"
data-controller=""
data-turbo-frame="_top"
enctype="multipart/form-data"
>

{% csrf_token %}

<div data-controller="bijlagen">
{{ form.bijlagen|render_rotterdam_formulier }}
</div>
<div class="form-control__with-helptext">
{{ form.omschrijving_intern|render_rotterdam_formulier }}
</div>
<div class="form-row btn-row">
<button
type="reset"
class="btn btn-tertiary"
data-controller="detail"
data-action="detail#closeModal"
>
<span>Annuleren</span>
</button>
<button
type="submit"
class="btn btn-action"
>
<span>Taak annuleren</span>
</button>
</div>
</form>
</div>
</div>
</div>
</turbo-frame>
49 changes: 41 additions & 8 deletions app/apps/regie/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
from apps.regie.constanten import MSB_WIJKEN, VERTALINGEN
from apps.regie.forms import (
BEHANDEL_OPTIES,
BEHANDEL_RESOLUTIE,
BEHANDEL_STATUS,
TAAK_BEHANDEL_OPTIES,
TAAK_BEHANDEL_RESOLUTIE,
TAAK_BEHANDEL_STATUS,
TAAK_RESOLUTIE_GEANNULEERD,
TAAK_STATUS_VOLTOOID,
FilterForm,
InformatieToevoegenForm,
MeldingAanmakenForm,
MeldingAfhandelenForm,
MSBLoginForm,
MSBMeldingZoekenForm,
TaakAfrondenForm,
TaakAnnulerenForm,
TaakStartenForm,
)
from apps.regie.utils import melding_naar_tijdlijn, to_base64
Expand Down Expand Up @@ -257,11 +257,6 @@ def melding_afhandelen(request, id):
]
for meldinggebeurtenis in melding.get("meldinggebeurtenissen", [])
]
taakopdrachten = {
to.get("uuid"): to for to in melding.get("taakopdrachten_voor_melding", [])
}
print("===== > taakopdrachten")
print(taakopdrachten)

bijlagen_flat = [b for bl in melding_bijlagen for b in bl]
form = MeldingAfhandelenForm()
Expand Down Expand Up @@ -373,6 +368,44 @@ def taak_afronden(request, melding_uuid, taakopdracht_uuid):
)


@permission_required("authorisatie.taak_annuleren")
def taak_annuleren(request, melding_uuid, taakopdracht_uuid):
melding = MeldingenService().get_melding(melding_uuid)
taakopdrachten = {
to.get("uuid"): to for to in melding.get("taakopdrachten_voor_melding", [])
}
taakopdracht = taakopdrachten.get(str(taakopdracht_uuid), {})
form = TaakAnnulerenForm()
if request.POST:
form = TaakAnnulerenForm(request.POST)
if form.is_valid():
bijlagen = request.FILES.getlist("bijlagen_extra", [])
bijlagen_base64 = []
for f in bijlagen:
file_name = default_storage.save(f.name, f)
bijlagen_base64.append({"bestand": to_base64(file_name)})
MeldingenService().taak_status_aanpassen(
taakopdracht_url=taakopdracht.get("_links", {}).get("self"),
status=TAAK_STATUS_VOLTOOID,
resolutie=TAAK_RESOLUTIE_GEANNULEERD,
omschrijving_intern=form.cleaned_data.get("omschrijving_intern"),
bijlagen=bijlagen_base64,
gebruiker=request.user.email,
)

return redirect("melding_detail", id=melding_uuid)

return render(
request,
"melding/part_taak_annuleren.html",
{
"form": form,
"melding": melding,
"taakopdracht": taakopdracht,
},
)


@permission_required("authorisatie.melding_bekijken")
def informatie_toevoegen(request, id):
melding = MeldingenService().get_melding(id)
Expand Down
6 changes: 6 additions & 0 deletions app/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
msb_melding_zoeken,
root,
taak_afronden,
taak_annuleren,
taak_starten,
)
from django.conf import settings
Expand Down Expand Up @@ -51,6 +52,11 @@
taak_afronden,
name="taak_afronden",
),
path(
"part/melding/<uuid:melding_uuid>/taak-annuleren/<uuid:taakopdracht_uuid>/",
taak_annuleren,
name="taak_annuleren",
),
path(
"part/melding/<uuid:id>/informatie-toevoegen/",
informatie_toevoegen,
Expand Down

0 comments on commit 8a54c18

Please sign in to comment.