Skip to content

Commit

Permalink
pages recaps demande habilitation - WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
MarjolaineLB authored and christophehenry committed Oct 15, 2024
1 parent 9145ef0 commit cea8a54
Show file tree
Hide file tree
Showing 20 changed files with 437 additions and 281 deletions.
47 changes: 43 additions & 4 deletions aidants_connect_common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
from django.db.models import Choices, IntegerChoices, TextChoices
from django.db.models.enums import ChoicesMeta as DjangoChoicesMeta
from django.utils.functional import Promise, classproperty
from django.utils.safestring import mark_safe
from django.utils.timezone import now
from django.utils.version import PY311

if PY311:
from enum import property as enum_property
else:
from types import DynamicClassAttribute as enum_property

__all__ = [
"DictChoices",
Expand Down Expand Up @@ -253,13 +260,45 @@ class RequestOriginConstants(IntegerChoices):

class RequestStatusConstants(TextChoicesEnum):
NEW = "Brouillon"
AC_VALIDATION_PROCESSING = "En attente de validation par Aidants Connect"
VALIDATED = "Validée"
REFUSED = "Refusée"
AC_VALIDATION_PROCESSING = mark_safe(
"En attente de validation d’éligibilité avant inscription en "
"formation des aidants"
)
VALIDATED = "Éligibilité validée"
REFUSED = "Éligibilité Refusée"
CLOSED = "Clôturée"
CHANGES_REQUIRED = "Modifications demandées"
CHANGES_REQUIRED = "Demande de modifications par l’équipe Aidants Connect"
CHANGES_PROPOSED = "Modifications proposées par Aidants Connect"

@enum_property
def description(self):
match self:
case self.AC_VALIDATION_PROCESSING:
return mark_safe(
"<p>Votre demande d’habilitation est en cours d’instruction "
"par nos équipes. Vous serez prochainement notifié de la "
"décision de nos équipes concernant votre dossier."
)
case self.VALIDATED:
return mark_safe(
"<p>Félicitations, votre demande d’habilitation a été acceptée par "
"Aidants Connect !</p>"
"<p>Vous pouvez désormais inscrire le référent sur un webinaire "
"d’information dédié aux référents et inscrire les aidants en "
"formation.</p>"
)
case self.CHANGES_REQUIRED:
return mark_safe(
"<p>L'équipe Aidants Connect a étudié votre demande d’habilitation "
"et souhaite que vous y apportiez des modifications. N’oubliez pas "
"de valider à nouveau votre demande d’habilitation en cliquant sur "
"le bouton « Soumettre la demande » pour que l'équipe Aidants "
"Connect prenne en compte vos modifications et valide votre "
"demande</p>"
)
case _:
return ""

@classproperty
def aidant_registrable(cls):
"""Statuses that allow to add new aidants to an habilitation request"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,5 @@ details.request-card-details .details-content {
padding: inherit;
position: absolute;
width: 100%;
z-index: 0;
}

details.request-card-details .details-content .fr-btns-group .fr-btn {
margin-bottom: 0;
margin-top: 0;
z-index: 11;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
{# Prevent messing with the absolute positionning of the design #}
{# See https://stackoverflow.com/questions/17115344/absolute-positioning-ignoring-padding-of-parent #}
<div class="fr-col-12 fr-col-md-6 request-card" {% block container_args %}{% endblock %}>
<details {% if habilitation_request.details_id %}id="{{ habilitation_request.details_id }}" {% endif %}class="request-card-details">
<details
{% if habilitation_request.details_id %}id="{{ habilitation_request.details_id }}"{% endif %}
class="request-card-details"
name="generic-hab-request"
>
{% block details_introduction %}{% endblock %}
<summary
class="fr-grid-row fr-grid-row--middle fr-grid-row--gap-2v fr-tile--shadow fr-py-2v fr-px-4v"
Expand All @@ -12,9 +16,11 @@
<img src="{% static "images/avatar.svg" %}" width="36" height="36" alt="" />
<span class="fr-grid-row--center fr-text--overflow-hidden spacer">
<p class="fr-m-0 fr-text--bold">{{ habilitation_request.user.full_name }}</p>
{% if habilitation_request.user.email %}
<p class="details-summary-header fr-m-0 fr-text--overflow-hidden">{{ habilitation_request.user.email }}</p>
{% endif %}
{% block details_subtitles %}
{% if habilitation_request.user.email %}
<p class="details-summary-header fr-m-0 fr-text--overflow-hidden">{{ habilitation_request.user.email }}</p>
{% endif %}
{% endblock details_subtitles %}
</span>
<span
type="button"
Expand All @@ -31,7 +37,7 @@
</section>
{% endfor %}
</section>
<ul class="fr-btns-group fr-btns-group--sm fr-btns-group--right fr-btns-group--inline">
<ul class="fr-btns-group fr-btns-group--sm fr-btns-group--right fr-btns-group--inline fr-mb-n4v">
<li>
{% block action_buttons %}
<a
Expand Down
16 changes: 15 additions & 1 deletion aidants_connect_habilitation/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,8 @@ def save(self, commit=True) -> Tuple[Manager, List[AidantRequest]]:
save.alters_data = True


class ValidationForm(PatchedForm):
class ValidationForm(DsfrBaseForm):
template_name = "aidants_connect_habilitation/forms/validation.html" # noqa: E501
cgu = BooleanField(
required=True,
label='J’ai pris connaissance des <a href="{url}" class="fr-link">'
Expand Down Expand Up @@ -759,6 +760,19 @@ def save(
save.alters_data = True


class RequestViewForm(PatchedForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def save(
self, organisation: OrganisationRequest, commit=True
) -> OrganisationRequest:
organisation.prepare_request_for_ac_validation(self.cleaned_data)
return organisation

save.alters_data = True


class RequestMessageForm(PatchedModelForm):
content = CharField(label="Votre message", widget=Textarea(attrs={"rows": 2}))

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.15 on 2024-09-26 13:42

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('aidants_connect_habilitation', '0032_organisationrequest_not_free_and_more'),
]

operations = [
migrations.AlterField(
model_name='organisationrequest',
name='status',
field=models.CharField(choices=[('NEW', 'Brouillon'), ('AC_VALIDATION_PROCESSING', 'En attente de validation d’éligibilité avant inscription en formation des aidants'), ('VALIDATED', 'Éligibilité validée'), ('REFUSED', 'Éligibilité Refusée'), ('CLOSED', 'Clôturée'), ('CHANGES_REQUIRED', 'Demande de modifications par l’équipe Aidants Connect'), ('CHANGES_PROPOSED', 'Modifications proposées par Aidants Connect')], default='NEW', max_length=150, verbose_name='État'),
),
]
31 changes: 16 additions & 15 deletions aidants_connect_habilitation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ def is_draft(self):
return RequestStatusConstants[self.status] == RequestStatusConstants.NEW

@property
def status_label(self):
return RequestStatusConstants[self.status].label
def status_enum(self):
return RequestStatusConstants[self.status]

def __str__(self):
return self.name
Expand Down Expand Up @@ -481,19 +481,20 @@ def accept_request_and_create_organisation(self):
self.create_aidants(organisation)

if self.manager.is_aidant:
self.manager.habilitation_request, _ = (
HabilitationRequest.objects.get_or_create(
email=self.manager.email,
organisation=organisation,
defaults=dict(
origin=HabilitationRequest.ORIGIN_HABILITATION,
first_name=self.manager.first_name,
last_name=self.manager.last_name,
profession=self.manager.profession,
conseiller_numerique=self.manager.conseiller_numerique,
status=ReferentRequestStatuses.STATUS_PROCESSING,
),
)
(
self.manager.habilitation_request,
_,
) = HabilitationRequest.objects.get_or_create(
email=self.manager.email,
organisation=organisation,
defaults=dict(
origin=HabilitationRequest.ORIGIN_HABILITATION,
first_name=self.manager.first_name,
last_name=self.manager.last_name,
profession=self.manager.profession,
conseiller_numerique=self.manager.conseiller_numerique,
status=ReferentRequestStatuses.STATUS_PROCESSING,
),
)
self.manager.save(update_fields=("habilitation_request",))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
{% if aidant.habilitation_request.status in aidant.habilitation_request.ReferentRequestStatuses.formation_registerable %}
{% if organisation.manager.aidant.last_login %}
<a
href="{% url 'espace_responsable_organisation' %}"
class="fr-btn"
>
Gérer les formations sur mon espace référent
</a>
{% elif aidant.habilitation_request.formations.exists %}
<button class="fr-btn" disabled>
Cette personne est inscrite à une formation
</button>
{% if aidant.habilitation_request.formations.exists %}
<p class="fr-badge fr-badge--success">Inscrit</p>
{% else %}
{% block url_registration %}
<a
href="{% url 'habilitation_manager_formation_registration' issuer_id=organisation.issuer.issuer_id uuid=organisation.uuid %}"
class="fr-btn"
class="fr-link"
>
Inscrire à une formation
</a>
{% endblock %}
{% endblock url_registration %}
{% endif %}
{% endif %}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<h2>Information générales</h2>
<div class="fr-grid-row fr-grid-row--gutters fr-mb-4v">
<div class="fr-col-12 fr-col-md-4">
<h3 class="fr-h5">Personne effectuant la demande</h3>
<h3 class="fr-h5 fr-mb-0">Personne effectuant la demande</h3>
</div>
<div class="fr-col-12 fr-col-md-8">
<h3 class="fr-h5">Structure</h3>
<div class="fr-col-12 fr-col-md-8 fr-pb-0">
<h3 class="fr-h5 fr-mb-0">Structure</h3>
</div>
<div class="fr-col-12 fr-col-md-4">
<div class="fr-col-12 fr-col-md-4 fr-pb-0">
<div class="fr-bordered fr-p-4w flex flex-between flex-column fr-height-100 ">
<div>
<p>
<strong>{{ issuer.get_full_name }}</strong><br/>
<strong>{{ issuer.get_full_name }}</strong><br />
<span class="fr-text-mention--grey fr-text--sm">{{ issuer.profession }}</span>
</p>
<p class="fr-text--sm">
Expand All @@ -20,11 +20,11 @@ <h3 class="fr-h5">Structure</h3>
{% if show_edit_buttons %}
<div class="fr-mt-3w flex flex-right fr-link">
<a
class="fr-btn fr-btn--tertiary fr-btn--icon fr-icon-pencil-fill"
href="{% url 'habilitation_modify_issuer' issuer_id=issuer.issuer_id %}"
>
Éditer
</a>
class="fr-btn fr-btn--tertiary fr-btn--icon fr-icon-pencil-fill"
href="{% url 'habilitation_modify_issuer' issuer_id=issuer.issuer_id %}"
>
Éditer
</a>
</div>
{% endif %}
</div>
Expand All @@ -40,14 +40,14 @@ <h3 class="fr-h5">Structure</h3>
<div class="fr-col-12 fr-col-md-6 fr-mb-2w fr-text--md"><strong>{{ organisation.name }}</strong></div>
<div class="fr-col-12 fr-col-md-6 fr-mb-2w fr-text-mention--grey">Adresse postale</div>
<div class="fr-col-12 fr-col-md-6 fr-mb-2w">
{{ organisation.address|linebreaksbr }}<br/>
{{ organisation.address|linebreaksbr }}<br />
{{ organisation.zipcode }}
{{ organisation.city }}
</div>
<div class="fr-col-12 fr-col-md-6 fr-mb-2w fr-text-mention--grey">SIRET</div>
<div class="fr-col-12 fr-col-md-6 fr-mb-2w">{{ organisation.siret }}</div>
<div class="fr-col-12 fr-col-md-6 fr-mb-2w fr-text-mention--grey">Site web</div>
<div class="fr-col-12 fr-col-md-6 fr-mb-2w">{{ organisation.web_site}}</div>
<div class="fr-col-12 fr-col-md-6 fr-mb-2w">{{ organisation.web_site }}</div>
</div>
</div>
<div class="fr-col-12 fr-col-md-6">
Expand All @@ -61,14 +61,16 @@ <h3 class="fr-h5">Structure</h3>
<div>{{ organisation.mission_description|linebreaksbr }}</div>
</div>
</div>
<div class="fr-mt-3w flex flex-right fr-link">
<a
class="fr-btn fr-btn--tertiary fr-btn--icon fr-icon-pencil-fill"
href="{% url 'habilitation_modify_organisation' issuer_id=issuer.issuer_id uuid=organisation.uuid %}"
{% if show_edit_buttons or organisation.status == organisation.Status.CHANGES_REQUIRED %}
<div class="fr-mt-3w flex flex-right fr-link">
<a
class="fr-btn fr-btn--tertiary fr-btn--icon fr-icon-pencil-fill"
href="{% url 'habilitation_modify_organisation' issuer_id=issuer.issuer_id uuid=organisation.uuid %}"
>
Éditer
</a>
</div>
Éditer
</a>
</div>
{% endif %}
</div>
</div>
</div>
Loading

0 comments on commit cea8a54

Please sign in to comment.