Skip to content

Commit

Permalink
fixup! 🚧(dashboard) refactor and modularize consent management templates
Browse files Browse the repository at this point in the history
  • Loading branch information
ssorin committed Jan 30, 2025
1 parent e2b275e commit 1c460fe
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dashboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
DASHBOARD_CONTROL_AUTHORITY_CITY: Paris
DASHBOARD_CONTROL_AUTHORITY_REPRESENTED_BY: John Doe
DASHBOARD_CONTROL_AUTHORITY_EMAIL: [email protected]
DASHBOARD_CONSENT_DONE_AT: Paris
DASHBOARD_CONSENT_SIGNATURE_LOCATION: Paris
steps:
- uses: actions/checkout@v4
- name: Install pipenv
Expand Down Expand Up @@ -108,4 +108,4 @@ jobs:
DASHBOARD_CONTROL_AUTHORITY_CITY: Paris
DASHBOARD_CONTROL_AUTHORITY_REPRESENTED_BY: John Doe
DASHBOARD_CONTROL_AUTHORITY_EMAIL: [email protected]
DASHBOARD_CONSENT_DONE_AT: Paris
DASHBOARD_CONSENT_SIGNATURE_LOCATION: Paris
2 changes: 1 addition & 1 deletion env.d/dashboard
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ DASHBOARD_CONTROL_AUTHORITY_CITY=Paris
DASHBOARD_CONTROL_AUTHORITY_REPRESENTED_BY=John Doe
[email protected]

DASHBOARD_CONSENT_DONE_AT=Paris
DASHBOARD_CONSENT_SIGNATURE_LOCATION=Paris

[email protected]
9 changes: 7 additions & 2 deletions src/dashboard/apps/consent/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ class ConsentCheckboxInput(CheckboxInput):


class ConsentForm(forms.Form):
"""Save user consent through a checkbox field."""
"""Save user consent through a checkbox field.
Note: all texts of this form (attributes: `label`, `description`, `help_text`)
are intended to appear in a contract and must therefore be in French and
non-translatable.
"""

# Specific authorisation checkbox
is_authorized_signatory = forms.BooleanField(
Expand Down Expand Up @@ -96,7 +101,7 @@ class ConsentForm(forms.Form):
),
)

# Global authorisation checkbox
# Global authorisation checkbox - this field must be in last position.
consent_agreed = forms.BooleanField(
required=True,
initial=False,
Expand Down
2 changes: 1 addition & 1 deletion src/dashboard/apps/consent/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
"email": "<[email protected]>",
},
)
CONSENT_DONE_AT = getattr(settings, "CONSENT_DONE_AT", "<city>")
CONSENT_SIGNATURE_LOCATION = getattr(settings, "CONSENT_SIGNATURE_LOCATION", "<city>")
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{% load i18n %}

{% comment %}
Note: all texts of this page are intended to appear in a contract and must
therefore be in French and non-translatable.
{% endcomment %}

<div class="fr-fieldset__element fr-my-4w">
<legend class="fr-fieldset__legend" id="text-legend">
D. Données à transmettre à la DGEC
Expand All @@ -17,9 +22,8 @@

{% if forloop.last %}
{% comment %}
Ce paragraphe se situe juste avant La case à cocher de consentement global
Attention: la case à cocher 'consent_agreed' doit toujours se trouver en dernière
position dans le form correspondant
These paragraphs are located just before the `global consent checkbox`.
Attention: the `consent_agreed` checkbox must always be positioned last in the corresponding forms.py.
{% endcomment %}
<p>
Usage des données : Suivi de la mise en œuvre de la politique énergétique.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{% load i18n %}

{% comment %}
Note: all texts of this page are intended to appear in a contract and must
therefore be in French and non-translatable.
{% endcomment %}

{% for entity in entities %}
<div class="fr-fieldset__element fr-my-4w">
<legend class="fr-fieldset__legend">
Expand All @@ -21,7 +26,7 @@
<div class="fr-table__container">
<div class="fr-table__content">
<table>
<caption>
<caption class="fr-text--md">
{% trans "Informations sur l'entreprise et le représentant" %}
</caption>
<thead>
Expand Down Expand Up @@ -49,6 +54,7 @@
{% include "consent/includes/_table_row.html" with label="Complément d'adresse" value=entity.address_2 row_number=row_number|add:"1" %}
{% include "consent/includes/_table_row.html" with label="Code Postale" value=entity.address_zip_code row_number=row_number|add:"1" %}
{% include "consent/includes/_table_row.html" with label="Commune" value=entity.address_city row_number=row_number|add:"1" %}
{# todo: add a field to retrieve this information (+ email and phone) if it doesn't exist #}
{% include "consent/includes/_table_row.html" with label="Nom du titulaire du contrat" value="-" row_number=row_number|add:"1" %}

<tr class="fr-table__section">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{% load i18n %}

{% comment %}
Note: all texts of this page are intended to appear in a contract and must
therefore be in French and non-translatable.
{% endcomment %}

<div class="fr-fieldset__element fr-my-4w">
<legend class="fr-fieldset__legend" id="text-legend">
A. Points de livraison à valider
Expand Down Expand Up @@ -39,9 +44,9 @@
data-fr-js-checkbox-actionee="true" />
<label class="fr-label" for="{{ consent.id }}"
{% if consent.status == 'VALIDATED' %}
title="{% trans "Delivery point is already validated" %}"
title="{% trans "Point de livraison déjà validé." %}"
{% elif consent.status == 'AWAITING' %}
title="{% trans "Delivery point awaiting consent" %}"
title="{% trans "Point de livraison en attende de validation." %}"
{% endif %}>
{{ consent.delivery_point.provider_assigned_id }}
</label>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{% load i18n %}

{% comment %}
Note: all texts of this page are intended to appear in a contract and must
therefore be in French and non-translatable.
{% endcomment %}

<div class="fr-fieldset__element fr-my-4w">
<legend class="fr-fieldset__legend">
C. Tiers
Expand All @@ -10,7 +15,7 @@
<div class="fr-table__container">
<div class="fr-table__content">
<table>
<caption>
<caption class="fr-text--md">
{% trans "Informations sur le tiers" %}
</caption>
<thead>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{% load i18n %}

{% comment %}
Note: all texts of this page are intended to appear in a contract and must
therefore be in French and non-translatable.
{% endcomment %}

<p>
<strong>Fait à : </strong>{{ consent_done_at }}
<strong>Fait à : </strong>{{ signature_location }}
<br />
<strong>Le :</strong> {% now "d/m/Y" %}
</p>
Expand Down
5 changes: 5 additions & 0 deletions src/dashboard/apps/consent/templates/consent/manage.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{% extends "consent/base.html" %}

{% comment %}
Note: all texts of this page are intended to appear in a contract and must
therefore be in French and non-translatable.
{% endcomment %}

{% load i18n static %}

{% block dashboard_content %}
Expand Down
4 changes: 2 additions & 2 deletions src/dashboard/apps/consent/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from .forms import ConsentForm
from .mixins import BreadcrumbContextMixin
from .models import Consent
from .settings import CONSENT_CONTROL_AUTHORITY, CONSENT_DONE_AT
from .settings import CONSENT_CONTROL_AUTHORITY, CONSENT_SIGNATURE_LOCATION


class IndexView(BreadcrumbContextMixin, TemplateView):
Expand Down Expand Up @@ -71,7 +71,7 @@ def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["control_authority"] = CONSENT_CONTROL_AUTHORITY
context["entities"] = self._get_entities()
context["consent_done_at"] = CONSENT_DONE_AT
context["signature_location"] = CONSENT_SIGNATURE_LOCATION
context["mailto"] = TEAM_EMAIL
return context

Expand Down
2 changes: 1 addition & 1 deletion src/dashboard/dashboard/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
"email": env.str("CONTROL_AUTHORITY_EMAIL"),
}

CONSENT_DONE_AT = env.str("CONSENT_DONE_AT")
CONSENT_SIGNATURE_LOCATION = env.str("CONSENT_SIGNATURE_LOCATION")


## Debug-toolbar
Expand Down

0 comments on commit 1c460fe

Please sign in to comment.