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

Ajout de la page de récap d'habilitation #533

Merged
merged 4 commits into from
Feb 8, 2022
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
9 changes: 8 additions & 1 deletion aidants_connect/common/forms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.forms import ModelForm
from django.forms import Form, ModelForm
from django.forms.utils import ErrorList
from django.utils.html import format_html

Expand All @@ -19,3 +19,10 @@ def __init__(self, **kwargs):
kwargs.setdefault("label_suffix", "")
kwargs.setdefault("error_class", PatchedErrorList)
super().__init__(**kwargs)


class PatchedForm(Form):
def __init__(self, **kwargs):
kwargs.setdefault("error_class", PatchedErrorList)
kwargs.setdefault("label_suffix", "")
super().__init__(**kwargs)
57 changes: 40 additions & 17 deletions aidants_connect_habilitation/forms.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
from django.conf import settings
from django.core.exceptions import ValidationError
from django.forms import (
Form,
formset_factory,
ChoiceField,
CharField,
BaseFormSet,
BooleanField,
FileField,
)
from django.urls import reverse
from django.utils.html import format_html
from phonenumber_field.formfields import PhoneNumberField
from phonenumber_field.widgets import PhoneNumberInternationalFallbackWidget

from aidants_connect.common.constants import RequestOriginConstants
from aidants_connect.common.forms import PatchedErrorListForm, PatchedErrorList
from aidants_connect.common.forms import (
PatchedErrorListForm,
PatchedErrorList,
PatchedForm,
)
from aidants_connect_habilitation import models
from aidants_connect_habilitation.models import (
AidantRequest,
Expand All @@ -36,6 +42,7 @@ class IssuerForm(PatchedErrorListForm):
)

def __init__(self, render_non_editable=False, **kwargs):
kwargs.setdefault("label_suffix", "")
super().__init__(**kwargs)
self.render_non_editable = render_non_editable
if self.render_non_editable:
Expand Down Expand Up @@ -168,19 +175,9 @@ class Meta:


class BaseAidantRequestFormSet(BaseFormSet):
def __init__(
self,
data=None,
files=None,
auto_id="id_%s",
prefix=None,
initial=None,
error_class=PatchedErrorList,
form_kwargs=None,
):
super().__init__(
data, files, auto_id, prefix, initial, error_class, form_kwargs
)
def __init__(self, **kwags):
kwags.setdefault("error_class", PatchedErrorList)
super().__init__(**kwags)
Comment on lines +178 to +180
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tut-tuuut Alors attention, je viens de me faire avoir : cette méthode marche bien mais elle rend impossible de passer les argument positionnellement.


def save(self, organisation: OrganisationRequest, commit=True):
result = []
Expand Down Expand Up @@ -226,5 +223,31 @@ def save(self, organisation: OrganisationRequest, commit=True):
)


class ValidationForm(Form):
pass
class ValidationForm(PatchedForm):
cgu = BooleanField(
required=True,
label='J’ai pris connaissance des <a href="{url}">'
"conditions générales d’utilisation</a> et je les valide.",
)
dpo = BooleanField(
required=True,
label="Je confirme que le délégué à la protection des données "
"de mon organisation est informé de ma demande.",
)
professionals_only = BooleanField(
required=True,
label="Je confirme que la liste des aidants à habiliter contient "
"exclusivement des aidants professionnels. Elle ne contient "
"donc ni service civique, ni bénévole, ni apprenti, ni stagiaire.",
)
without_elected = BooleanField(
required=True,
label="Je confirme qu’aucun élu n’est impliqué dans l’habilitation "
"Aidants Connect. Le responsable Aidants Connect ainsi que les aidants "
"à habiliter ne sont pas des élus.",
)

def __init__(self, **kwargs):
super().__init__(**kwargs)
cgu = self["cgu"]
cgu.label = format_html(cgu.label, url=reverse("cgu"))
3 changes: 3 additions & 0 deletions aidants_connect_habilitation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class Person(models.Model):
def __str__(self):
return f"{self.first_name} {self.last_name}"

def get_full_name(self):
return str(self)

class Meta:
abstract = True

Expand Down
111 changes: 111 additions & 0 deletions aidants_connect_habilitation/templates/validation_form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{% extends 'layouts/main-habilitation.html' %}
{% load static form_extras %}

{% block title %}
Aidants Connect — Récapitulatif
{% endblock %}

{% block content %}
<h2>Récapitulatif de la demande</h2>
<p>
Vous trouverez ici les informations principales saisies dans le formulaire.
Il est possible de les éditer si besoin.
</p>

<h3>Informations générales</h3>

<section>
<h4>Vous êtes :</h4>

<strong>{{ issuer.get_full_name }}</strong>
<p>{{ issuer.profession }}</p>

<a href="mailto:{{ issuer.email }}">{{ issuer.email }}</a>
<a href="tel:{{ issuer.phone }}">{{ issuer.phone }}</a>

<a href="{% url 'habilitation_modify_issuer' issuer_id=issuer.issuer_id %}">Éditer</a>
</section>

<section>
<h4>Vous faites cette demande pour :</h4>

<address>
{{ organisation.address }}<br/>
{{ organisation.zipcode }}<br/>
{{ organisation.city }}<br/>
</address>

<p>SIRET : {{ organisation.siret }}</p>

<a href="{% url 'habilitation_modify_organisation' issuer_id=issuer.issuer_id draft_id=organisation.draft_id %}">
Éditer
</a>
</section>

<section>
<h4>Responsable de structure</h4>

<strong>{{ organisation.manager.get_full_name }}</strong>
<p>{{ organisation.manager.profession }}</p>

<a href="mailto:{{ organisation.manager.email }}">{{ organisation.manager.email }}</a>
<a href="tel:{{ organisation.manager.phone }}">{{ organisation.manager.phone }}</a>

<address>
{{ organisation.manager.address }}<br/>
{{ organisation.manager.zipcode }}<br/>
{{ organisation.manager.city }}<br/>
</address>

<p>Ce responsable est aussi aidant : {{ organisation.manager.is_aidant|yesno:"Oui,Non" }}</p>

<a href="{% url 'habilitation_new_aidants' issuer_id=issuer.issuer_id draft_id=organisation.draft_id %}">Éditer</a>
</section>

{% if organisation.data_privacy_officer %}
<section>
<h4>Délégué à la protection des données</h4>

<strong>{{ organisation.data_privacy_officer.get_full_name }}</strong>
<p>{{ organisation.data_privacy_officer.profession }}</p>

<a href="mailto:{{ organisation.data_privacy_officer.email }}">{{ organisation.data_privacy_officer.email }}</a>
<a href="tel:{{ organisation.data_privacy_officer.phone }}">{{ organisation.data_privacy_officer.phone }}</a>

<a href="{% url 'habilitation_new_aidants' issuer_id=issuer.issuer_id draft_id=organisation.draft_id %}">
Éditer
</a>
</section>
{% endif %}

{% for aidant_request in organisation.aidant_requests.all %}
<section>
<h4>Aidant</h4>

<strong>{{ aidant_request.get_full_name }}</strong>
<p>{{ aidant_request.profession }}</p>

<a href="mailto:{{ aidant_request.email }}">{{ aidant_request.email }}</a>
<a href="tel:{{ aidant_request.phone }}">{{ aidant_request.phone }}</a>

<a href="{% url 'habilitation_new_aidants' issuer_id=issuer.issuer_id draft_id=organisation.draft_id %}">
Éditer
</a>
</section>
{% endfor %}

<form method="post">
{% csrf_token %}
{{ form.non_field_errors }}

{% field_as_p form.cgu %}
{% field_as_p form.dpo %}
{% field_as_p form.professionals_only %}
{% field_as_p form.without_elected %}

<a href="{% url 'habilitation_validation' issuer_id=issuer.issuer_id draft_id=organisation.draft_id %}">
Revenir à l’étape précédente
</a>
<input type="submit" value="Soumettre la demande"/>
</form>
{% endblock %}
Loading