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

Générer et sauvegarder un data_pass_id lors de l'envoi de la demande à AC #609

Merged
merged 1 commit into from
Apr 5, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.12 on 2022-04-05 13:21

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('aidants_connect_habilitation', '0015_remove_dpo_model'),
]

operations = [
migrations.AddField(
model_name='organisationrequest',
name='data_pass_id',
field=models.IntegerField(default=None, null=True, unique=True, verbose_name='Numéro Datapass'),
),
]
9 changes: 9 additions & 0 deletions aidants_connect_habilitation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
RequestStatusConstants,
)
from aidants_connect_web.models import OrganisationType
from aidants_connect_web.utilities import generate_new_datapass_id

__all__ = [
"PersonWithResponsibilities",
Expand Down Expand Up @@ -183,6 +184,13 @@ class OrganisationRequest(models.Model):
unique=True,
)

data_pass_id = models.IntegerField(
"Numéro Datapass",
null=True,
default=None,
unique=True,
)

status = models.CharField(
"État",
max_length=150,
Expand Down Expand Up @@ -270,6 +278,7 @@ def prepare_request_for_ac_validation(self, form_data: dict):
self.professionals_only = form_data["professionals_only"]
self.without_elected = form_data["without_elected"]
self.status = RequestStatusConstants.AC_VALIDATION_PROCESSING.name
self.data_pass_id = int(f"{self.zipcode[:3]}{generate_new_datapass_id()}")
self.save()

class Meta:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

{% block content %}
<div class="fr-container">
<h1>Demande d’habilitation n° {{ organisation.id }}</h1>
<h1>Demande d’habilitation n° {{ organisation.data_pass_id }}</h1>
<p class="subtitle">

</p>
Expand All @@ -23,7 +23,7 @@ <h2>Rappel de votre saisie</h2>
<div class="fr-grid-row fr-grid-row--gutters">
<p class="fr-col more-info">
Pour modifier cette demande, envoyez un e-mail à l'équipe Aidants Connect : contact@aidantsconnect.beta.gouv.fr
en précisant le n° de votre demande d'habilitation : {{ organisation.id }}
en précisant le n° de votre demande d'habilitation : {{ organisation.data_pass_id }}
</p>
</div>

Expand Down
3 changes: 3 additions & 0 deletions aidants_connect_habilitation/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,8 @@ def test_template(self):
self.assertContains(response, "Éditer", 5)

def test_do_the_job_and_redirect_valid_post_to_org_view(self):
self.assertIsNone(self.organisation.data_pass_id)

cleaned_data = {
"cgu": True,
"dpo": True,
Expand All @@ -839,6 +841,7 @@ def test_do_the_job_and_redirect_valid_post_to_org_view(self):
self.organisation.get_absolute_url(),
)
self.organisation.refresh_from_db()
self.assertIsNotNone(self.organisation.data_pass_id)
self.assertEqual(
self.organisation.status,
RequestStatusConstants.AC_VALIDATION_PROCESSING.name,
Expand Down