-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Page validation habilitation : modale back
- Loading branch information
1 parent
5df4e11
commit da37e0d
Showing
17 changed files
with
406 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.urls import path | ||
|
||
from aidants_connect_habilitation.api.views import PersonnelRequestEditView | ||
|
||
urlpatterns = [ | ||
path( | ||
"demandeur/<str:issuer_id>/organisation/<str:uuid>/aidant/<int:aidant_id>/edit/", # noqa: E501 | ||
PersonnelRequestEditView.as_view(), | ||
name="api_habilitation_aidant_edit", | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
from django.http import HttpResponse | ||
from django.shortcuts import get_object_or_404 | ||
from django.urls import reverse | ||
from django.views.generic import FormView | ||
|
||
from aidants_connect_habilitation.constants import HabilitationFormStep | ||
from aidants_connect_habilitation.forms import AidantRequestForm | ||
from aidants_connect_habilitation.models import AidantRequest | ||
from aidants_connect_habilitation.views import ( | ||
OnlyNewRequestsView, | ||
ProfileCardAidantRequestPresenter, | ||
) | ||
|
||
|
||
class PersonnelRequestEditView(OnlyNewRequestsView, FormView): | ||
form_class = AidantRequestForm | ||
template_name = "forms/form.html" | ||
|
||
@property | ||
def step(self) -> HabilitationFormStep: | ||
return HabilitationFormStep.SUMMARY | ||
|
||
def setup(self, request, *args, **kwargs): | ||
self.success = False | ||
super().setup(request, *args, **kwargs) | ||
self.aidant_request = get_object_or_404( | ||
AidantRequest, | ||
organisation=self.organisation, | ||
pk=self.kwargs.get("aidant_id"), | ||
) | ||
|
||
def get_form_kwargs(self): | ||
return { | ||
"organisation": self.organisation, | ||
"instance": self.aidant_request, | ||
**super().get_form_kwargs(), | ||
} | ||
|
||
def get_context_data(self, **kwargs): | ||
if "habilitation_request" in kwargs: | ||
kwargs["habilitation_request"] = ProfileCardAidantRequestPresenter( | ||
kwargs["habilitation_request"] | ||
) | ||
|
||
kwargs.update( | ||
{ | ||
"action": reverse( | ||
"api_habilitation_aidant_edit", | ||
kwargs={ | ||
"issuer_id": self.organisation.issuer.issuer_id, | ||
"uuid": self.organisation.uuid, | ||
"aidant_id": self.aidant_request.pk, | ||
}, | ||
) | ||
} | ||
) | ||
return super().get_context_data(**kwargs) | ||
|
||
def get_template_names(self): | ||
if self.success: | ||
return "aidants_connect_habilitation/common/_habilitation-request-profile-card.html" # noqa: E501 | ||
|
||
return super().get_template_names() | ||
|
||
def form_invalid(self, form): | ||
return self.render_to_response(self.get_context_data(form=form), status=422) | ||
|
||
def form_valid(self, form): | ||
habilitation_request = form.save() | ||
self.success = True | ||
return self.render_to_response( | ||
self.get_context_data(habilitation_request=habilitation_request) | ||
) | ||
|
||
def delete(self, request, *args, **kwargs): | ||
self.aidant_request.delete() | ||
return HttpResponse(status=202) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
aidants_connect_habilitation/migrations/0033_alter_organisationrequest_status.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.