Skip to content

Commit

Permalink
Affichage du demandeur sur le forumaire Aidants #515
Browse files Browse the repository at this point in the history
  • Loading branch information
christophehenry authored Jan 26, 2022
2 parents ec01ce3 + 77552a4 commit 69c8200
Show file tree
Hide file tree
Showing 42 changed files with 131 additions and 49 deletions.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
2 changes: 1 addition & 1 deletion aidants_connect_habilitation/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ class AidantConnectHabilitationConfig(AppConfig):
name = "aidants_connect_habilitation"

def ready(self):
import aidants_connect.lookups # noqa
import aidants_connect.common.lookups # noqa
27 changes: 25 additions & 2 deletions aidants_connect_habilitation/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from phonenumber_field.formfields import PhoneNumberField
from phonenumber_field.widgets import PhoneNumberInternationalFallbackWidget

from aidants_connect.constants import RequestOriginConstants
from aidants_connect.forms import PatchedErrorListForm, PatchedErrorList
from aidants_connect.common.constants import RequestOriginConstants
from aidants_connect.common.forms import PatchedErrorListForm, PatchedErrorList
from aidants_connect_habilitation import models
from aidants_connect_habilitation.models import AidantRequest
from aidants_connect_web.models import OrganisationType
Expand All @@ -21,6 +21,29 @@ class IssuerForm(PatchedErrorListForm):
required=False,
)

def __init__(self, render_non_editable=False, **kwargs):
super().__init__(**kwargs)
self.render_non_editable = render_non_editable
if self.render_non_editable:
self.auto_id = False
for name, field in self.fields.items():
field.disabled = True
field.widget.attrs.update(id=f"id_{name}")

def add_prefix(self, field_name):
"""
Return empty ``name`` HTML attribute when ``self.render_non_editable is True``
"""
return "" if self.render_non_editable else super().add_prefix(field_name)

def add_initial_prefix(self, field_name):
"""
Return empty ``name`` HTML attribute when ``self.render_non_editable is True``
"""
return (
"" if self.render_non_editable else super().add_initial_prefix(field_name)
)

class Meta:
model = models.Issuer
exclude = ["issuer_id"]
Expand Down
2 changes: 1 addition & 1 deletion aidants_connect_habilitation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.db.models import Q, SET_NULL
from phonenumber_field.modelfields import PhoneNumberField

from aidants_connect.constants import (
from aidants_connect.common.constants import (
RequestStatusConstants,
MessageStakeholders,
RequestOriginConstants,
Expand Down
20 changes: 20 additions & 0 deletions aidants_connect_habilitation/templates/_issuer_form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% load static form_extras %}

{{ form.non_field_errors }}
<fieldset>
<legend>Identité</legend>

{% field_as_p form.first_name %}
{% field_as_p form.last_name %}
</fieldset>
<fieldset>
<legend>Contact</legend>

{% field_as_p form.email %}
{% field_as_p form.phone %}
</fieldset>
<fieldset>
<legend>Autres informations</legend>

{% field_as_p form.profession %}
</fieldset>
6 changes: 6 additions & 0 deletions aidants_connect_habilitation/templates/aidants_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@

{{ form.management_form }}

<section>
<h2>Demandeur</h2>
{% include "_issuer_form.html" with form=issuer %}
</section>

{% for aidant_form in form %}
<section>
<h2>Aidant</h2>
{% include "aidant_form.html" with form=aidant_form %}
</section>
{% endfor %}
Expand Down
17 changes: 1 addition & 16 deletions aidants_connect_habilitation/templates/issuer_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,8 @@

<form method="post">
{% csrf_token %}
{{ form.non_field_errors }}
<fieldset>
<legend>Identité</legend>

{% field_as_p form.first_name %}
{% field_as_p form.last_name %}
</fieldset>
<fieldset>
<legend>Contact</legend>
{% include "_issuer_form.html" %}

{% field_as_p form.email %}
{% field_as_p form.phone %}
</fieldset>
<fieldset>
<legend>Autres informations</legend>

{% field_as_p form.profession %}
</fieldset>
<input type="submit" value="Valider cette étape">
</form>
2 changes: 1 addition & 1 deletion aidants_connect_habilitation/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from phonenumber_field.phonenumber import to_python

from aidants_connect.constants import RequestOriginConstants
from aidants_connect.common.constants import RequestOriginConstants
from aidants_connect_habilitation.models import (
AidantRequest,
OrganisationRequest,
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from uuid import uuid4

from django.test import tag
from django.urls import reverse

from aidants_connect_habilitation.forms import IssuerForm
from aidants_connect_habilitation.models import OrganisationRequest
from aidants_connect_habilitation.tests.factories import OrganisationRequestFactory
from aidants_connect.common.tests.testcases import FunctionalTestCase


@tag("functional")
class AidantsRequestFormViewTests(FunctionalTestCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.pattern_name = "habilitation_new_aidants"
cls.organisation: OrganisationRequest = OrganisationRequestFactory(
draft_id=uuid4()
)

def open_url_from_pattern(self, org: OrganisationRequest):
self.open_live_url(
reverse(
self.pattern_name,
kwargs={
"issuer_id": org.issuer.issuer_id,
"draft_id": org.draft_id,
},
)
)

def test_issuer_form_is_rendered_harmless(self):
self.open_url_from_pattern(self.organisation)

for name in IssuerForm().fields.keys():
el_id = f"id_{name}"
el = self.selenium.find_element_by_id(el_id)
el_name_attr = el.get_attribute("name")
self.assertEqual(
el_name_attr,
"",
f"""Element <{el.tag_name} id="{el_id}"> from issuer form should not """
f"have `name` attribute set (current value is '{el_name_attr}')",
)
2 changes: 1 addition & 1 deletion aidants_connect_habilitation/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.db import IntegrityError
from django.test import tag, TestCase

from aidants_connect.constants import RequestOriginConstants
from aidants_connect.common.constants import RequestOriginConstants
from aidants_connect_habilitation.tests.factories import OrganisationRequestFactory


Expand Down
5 changes: 4 additions & 1 deletion aidants_connect_habilitation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ def form_valid(self, form):
return super().form_valid(form)

def get_context_data(self, **kwargs):
return {**super().get_context_data(**kwargs), "issuer": self.issuer}
return {
**super().get_context_data(**kwargs),
"issuer": IssuerForm(instance=self.issuer, render_non_editable=True),
}

def get_success_url(self):
return reverse("habilitation_new_issuer")
2 changes: 1 addition & 1 deletion aidants_connect_web/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class AidantConnectWebConfig(AppConfig):

def ready(self):
import aidants_connect_web.signals # noqa
import aidants_connect.lookups # noqa
import aidants_connect.common.lookups # noqa
2 changes: 1 addition & 1 deletion aidants_connect_web/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from phonenumber_field.formfields import PhoneNumberField
from phonenumber_field.widgets import PhoneNumberInternationalFallbackWidget

from aidants_connect.constants import AuthorizationDurations as ADKW
from aidants_connect.common.constants import AuthorizationDurations as ADKW
from aidants_connect_web.models import (
Aidant,
CarteTOTP,
Expand Down
2 changes: 1 addition & 1 deletion aidants_connect_web/migrations/0050_auto_20210321_2154.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# flake8: noqa
from django.db import migrations

from aidants_connect.constants import RequestOriginConstants
from aidants_connect.common.constants import RequestOriginConstants


def add_organisation_types(apps, schema_editor):
Expand Down
2 changes: 1 addition & 1 deletion aidants_connect_web/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from re import sub as regex_sub
from phonenumber_field.modelfields import PhoneNumberField

from aidants_connect.constants import (
from aidants_connect.common.constants import (
JOURNAL_ACTIONS,
JournalActionKeywords,
AuthorizationDurationChoices,
Expand Down
2 changes: 1 addition & 1 deletion aidants_connect_web/tests/test_functional/test_404.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.test import tag

from aidants_connect_web.tests.test_functional.testcases import FunctionalTestCase
from aidants_connect.common.tests.testcases import FunctionalTestCase


@tag("functional")
Expand Down
2 changes: 1 addition & 1 deletion aidants_connect_web/tests/test_functional/test_a11y.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.test import tag

from aidants_connect_web.tests.test_functional.testcases import FunctionalTestCase
from aidants_connect.common.tests.testcases import FunctionalTestCase
from selenium.common.exceptions import NoSuchElementException


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from aidants_connect_web.admin import MandatAdmin
from aidants_connect_web.models import Mandat
from aidants_connect_web.tests.factories import AidantFactory, MandatFactory
from aidants_connect_web.tests.test_functional.testcases import FunctionalTestCase
from aidants_connect.common.tests.testcases import FunctionalTestCase


@tag("functional")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
AutorisationFactory,
UsagerFactory,
)
from aidants_connect_web.tests.test_functional.testcases import FunctionalTestCase
from aidants_connect.common.tests.testcases import FunctionalTestCase
from aidants_connect_web.tests.test_functional.utilities import login_aidant


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
MandatFactory,
AutorisationFactory,
)
from aidants_connect_web.tests.test_functional.testcases import FunctionalTestCase
from aidants_connect.common.tests.testcases import FunctionalTestCase
from aidants_connect_web.tests.test_functional.utilities import login_aidant


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from selenium.webdriver.support.expected_conditions import url_matches

from aidants_connect_web.tests.factories import AidantFactory
from aidants_connect_web.tests.test_functional.testcases import FunctionalTestCase
from aidants_connect.common.tests.testcases import FunctionalTestCase
from aidants_connect_web.tests.test_functional.utilities import login_aidant


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
HabilitationRequestFactory,
OrganisationFactory,
)
from aidants_connect_web.tests.test_functional.testcases import FunctionalTestCase
from aidants_connect.common.tests.testcases import FunctionalTestCase


class RegionFilterTestCase(FunctionalTestCase):
Expand Down
2 changes: 1 addition & 1 deletion aidants_connect_web/tests/test_functional/test_homepage.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.test import tag

from aidants_connect_web.tests.test_functional.testcases import FunctionalTestCase
from aidants_connect.common.tests.testcases import FunctionalTestCase


@tag("functional")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
UsagerFactory,
MandatFactory,
)
from aidants_connect_web.tests.test_functional.testcases import FunctionalTestCase
from aidants_connect.common.tests.testcases import FunctionalTestCase
from aidants_connect_web.tests.test_functional.utilities import login_aidant


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
OrganisationFactory,
CarteTOTPFactory,
)
from aidants_connect_web.tests.test_functional.testcases import FunctionalTestCase
from aidants_connect.common.tests.testcases import FunctionalTestCase


@tag("functional", "import")
Expand Down
2 changes: 1 addition & 1 deletion aidants_connect_web/tests/test_functional/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from aidants_connect_web.tests.factories import (
AidantFactory,
)
from aidants_connect_web.tests.test_functional.testcases import FunctionalTestCase
from aidants_connect.common.tests.testcases import FunctionalTestCase
from django.core import mail

from selenium.webdriver.support.ui import WebDriverWait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
AidantFactory,
OrganisationFactory,
)
from aidants_connect_web.tests.test_functional.testcases import FunctionalTestCase
from aidants_connect.common.tests.testcases import FunctionalTestCase
from aidants_connect_web.tests.test_functional.utilities import login_aidant


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
MandatFactory,
UsagerFactory,
)
from aidants_connect_web.tests.test_functional.testcases import FunctionalTestCase
from aidants_connect.common.tests.testcases import FunctionalTestCase
from aidants_connect_web.tests.test_functional.utilities import login_aidant


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.test import tag

from aidants_connect_web.tests.test_functional.testcases import FunctionalTestCase
from aidants_connect.common.tests.testcases import FunctionalTestCase


@tag("functional")
Expand Down
2 changes: 1 addition & 1 deletion aidants_connect_web/tests/test_functional/test_usagers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
MandatFactory,
ExpiredMandatFactory,
)
from aidants_connect_web.tests.test_functional.testcases import FunctionalTestCase
from aidants_connect.common.tests.testcases import FunctionalTestCase
from aidants_connect_web.tests.test_functional.utilities import login_aidant


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
MandatFactory,
UsagerFactory,
)
from aidants_connect_web.tests.test_functional.testcases import FunctionalTestCase
from aidants_connect.common.tests.testcases import FunctionalTestCase
from aidants_connect_web.tests.test_functional.utilities import login_aidant


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
MandatFactory,
UsagerFactory,
)
from aidants_connect_web.tests.test_functional.testcases import FunctionalTestCase
from aidants_connect.common.tests.testcases import FunctionalTestCase
from aidants_connect_web.tests.test_functional.utilities import login_aidant


Expand Down
2 changes: 1 addition & 1 deletion aidants_connect_web/tests/test_views/test_FC_as_FS.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.test import override_settings, tag, TestCase
from django.test.client import Client

from aidants_connect.constants import AuthorizationDurationChoices
from aidants_connect.common.constants import AuthorizationDurationChoices
from aidants_connect_web.models import Connection, Journal, Usager
from aidants_connect_web.tests.factories import AidantFactory, UsagerFactory
from aidants_connect_web.utilities import generate_sha256_hash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from django_otp.plugins.otp_totp.models import TOTPDevice

from aidants_connect.constants import JournalActionKeywords
from aidants_connect.common.constants import JournalActionKeywords
from aidants_connect_web.models import Journal
from aidants_connect_web.tests.factories import (
AidantFactory,
Expand Down
Loading

0 comments on commit 69c8200

Please sign in to comment.