Skip to content

Commit

Permalink
✨(dashboard) add dashboard consent base app
Browse files Browse the repository at this point in the history
- introduces the new 'consent' Django app.
- added app structure
- added templates views
- added templates
- added django-extension
- updated translations
- updated settings and urls according this changes
  • Loading branch information
ssorin committed Nov 19, 2024
1 parent 0277dea commit 67bc298
Show file tree
Hide file tree
Showing 18 changed files with 151 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/dashboard/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to
- add internationalization and language switcher
- add authentication system
- introduce new custom user model
- add consent base app

[unreleased]: https://github.com/MTES-MCT/qualicharge/compare/main...bootstrap-dashboard-project

3 changes: 2 additions & 1 deletion src/dashboard/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ name = "pypi"
Django = "==5.1.3"
django-dsfr = "==1.4.3"
django-environ = "==0.11.2"
django-extensions = "==3.2.3"
gunicorn = "==23.0.0"
psycopg = {extras = ["pool", "binary"], version = "==3.2.3"}
whitenoise = "==6.8.2"

[dev-packages]
black = "==24.10.0"
django-stubs = {extras = ["compatible-mypy"], version = "==5.1.1"}
djlint = "==1.36.1"
honcho = "==2.0.0"
mypy = "==1.13.0"
pytest = "==8.3.3"
pytest-cov = "==6.0.0"
pytest-django = "==4.9.0"
pytest-httpx = "==0.34.0"
ruff = "==0.7.4"
djlint = "==1.36.1"

[requires]
python_version = "3.12"
11 changes: 10 additions & 1 deletion src/dashboard/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/dashboard/apps/consent/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Dashboard consent app."""
13 changes: 13 additions & 0 deletions src/dashboard/apps/consent/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Dashboard consent app base config."""

from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _


class ConsentConfig(AppConfig):
"""Consent app config."""

default_auto_field = "django.db.models.BigAutoField"
name = "apps.consent"
label = "qcd_consent"
verbose_name = _("Consent")
1 change: 1 addition & 0 deletions src/dashboard/apps/consent/migrations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Dashboard consent app migrations."""
4 changes: 4 additions & 0 deletions src/dashboard/apps/consent/templates/consent/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% extends "base.html" %}

{% block content %}
{% endblock content %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% extends "home/base.html" %}

{% load i18n %}

{% block content %}
<h2>
{% trans "Consents management" %}
</h2>
{% endblock content %}
15 changes: 15 additions & 0 deletions src/dashboard/apps/consent/templates/consent/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends "home/base.html" %}

{% load i18n %}

{% block content %}
<h2>
{% trans "Consents summary" %}
</h2>

<p>
<a class="fr-link fr-icon-arrow-right-line fr-link--icon-right" href="{% url "consent:manage" %}">
{% trans "Manage consent" %}
</a>
</p>
{% endblock content %}
12 changes: 12 additions & 0 deletions src/dashboard/apps/consent/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Dashboard consent app urls."""

from django.urls import path

from .views import IndexView, ManageView

app_name = "consent"

urlpatterns = [
path("", IndexView.as_view(), name="index"),
path("manage/", ManageView.as_view(), name="manage"),
]
36 changes: 36 additions & 0 deletions src/dashboard/apps/consent/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Dashboard consent app views."""

from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView


class IndexView(TemplateView):
"""Index view of the consent app."""

template_name = "consent/index.html"

def get_context_data(self, **kwargs):
"""Add custom context to the view."""
context = super().get_context_data(**kwargs)
context["breadcrumb_data"] = {
"current": _("Consent"),
}
return context


class ManageView(TemplateView):
"""Consents management view."""

template_name = "consent/consent-management.html"

def get_context_data(self, **kwargs):
"""Add custom context to the view."""
context = super().get_context_data(**kwargs)
context["breadcrumb_data"] = {
"links": [
{"url": reverse("consent:index"), "title": _("Consent")},
],
"current": _("Manage Consents"),
}
return context
14 changes: 10 additions & 4 deletions src/dashboard/apps/home/templates/home/cards/consentement.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

<div class="fr-grid-row fr-grid-row--gutters">
<div class="fr-col-12 fr-col-md-6">
<div class="fr-card fr-enlarge-link">
<div class="fr-card">
<div class="fr-card__body">

<div class="fr-card__content">
<p class="fr-card__title">
<a href="#" rel="noopener noreferrer" title="">{% trans "Consent Management" %}</a>
<a href="{% url 'consent:index' %}" rel="noopener noreferrer" title="">
{% trans "Consent Management" %}
</a>
</p>
<p class="fr-card__desc">
Texte de la carte.
Expand All @@ -21,10 +23,14 @@
<div class="fr-card__footer">
<ul>
<li>
<a class="fr-link" href="#">Lien interne</a>
<a class="fr-link fr-icon-arrow-right-line fr-link--icon-right" href="#">
Lien interne
</a>
</li>
<li>
<a class="fr-link" href="#">Lien interne</a>
<a class="fr-link fr-icon-arrow-right-line fr-link--icon-right" href="#">
Lien interne
</a>
</li>
</ul>

Expand Down
3 changes: 1 addition & 2 deletions src/dashboard/apps/home/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""Dashboard home app views."""

from django.contrib.auth.mixins import LoginRequiredMixin
from django.views.generic import TemplateView


class IndexView(LoginRequiredMixin, TemplateView):
class IndexView(TemplateView):
"""Index view of the homepage."""

template_name = "home/index.html"
3 changes: 3 additions & 0 deletions src/dashboard/dashboard/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django_extensions",
"widget_tweaks",
"dsfr",
"dashboard",
"apps",
"apps.auth",
"apps.home",
"apps.consent",
]

MIDDLEWARE = [
Expand All @@ -60,6 +62,7 @@
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.auth.middleware.LoginRequiredMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
Expand Down
1 change: 1 addition & 0 deletions src/dashboard/dashboard/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
path("admin/", admin.site.urls),
path("accounts/", include("django.contrib.auth.urls")),
# apps
path("consent/", include("apps.consent.urls")),
path("", include("apps.home.urls")),
# internationalization
path("i18n/", include("django.conf.urls.i18n")),
Expand Down
Binary file modified src/dashboard/locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
36 changes: 28 additions & 8 deletions src/dashboard/locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-18 16:10+0100\n"
"PO-Revision-Date: 2024-11-18 16:11+0100\n"
"POT-Creation-Date: 2024-11-19 11:20+0100\n"
"PO-Revision-Date: 2024-11-19 11:22+0100\n"
"Last-Translator: ssorin <[email protected]>\n"
"Language-Team: \n"
"Language: fr\n"
Expand All @@ -19,23 +19,43 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 3.5\n"

#: apps/auth/apps.py:12
#: apps/auth/apps.py:13
msgid "Authentication"
msgstr "Authentification"

#: apps/home/templates/home/cards/consentement.html:12
#: apps/consent/templates/consent/consent-management.html:7
msgid "Consents management"
msgstr "Gestion du consentement"

#: apps/consent/templates/consent/index.html:7
msgid "Consents summary"
msgstr "Résumé des consentements"

#: apps/consent/templates/consent/index.html:12
msgid "Manage consent"
msgstr "Gérer le consentement"

#: apps/consent/views.py:17 apps/consent/views.py:32
msgid "Consent"
msgstr "Consentement"

#: apps/consent/views.py:34
msgid "Manage Consents"
msgstr "Gérer les consentements"

#: apps/home/templates/home/cards/consentement.html:13
msgid "Consent Management"
msgstr "Gestion du consentement"

#: apps/home/templates/home/index.html:7
msgid "QualiCharge dashboard"
msgstr "Tableau de bord QualiCharge"

#: dashboard/settings.py:126
#: dashboard/settings.py:129
msgid "French"
msgstr "Français"

#: dashboard/settings.py:127
#: dashboard/settings.py:130
msgid "English"
msgstr "Anglais"

Expand Down Expand Up @@ -133,8 +153,8 @@ msgid "Identifier"
msgstr "Identifiant"

#: templates/registration/login.html:51
msgid "Expected format: [email protected]"
msgstr "Format attendu : [email protected]"
msgid "Expected format: myusername"
msgstr "Format attendu : nomdutilisateur"

#: templates/registration/login.html:69
msgid "Password"
Expand Down
8 changes: 4 additions & 4 deletions src/dashboard/templates/registration/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h2>
aria-labelledby="credentials-messages">
<div class="fr-fieldset__element">
<span class="fr-hint-text">
{% trans "Unless otherwise stated, all fields are required." %}
{% trans "Unless otherwise stated, all fields are required." %}
</span>
</div>
<div class="fr-fieldset__element">
Expand All @@ -66,7 +66,7 @@ <h2>
<div class="fr-fieldset__element">
<div class="fr-password" id="id_password">
<label class="fr-label" for="id_password-input">
{% trans "Password" %}
{% trans "Password" %}
</label>
<div class="fr-input-wrap">
<input class="fr-password__input fr-input"
Expand All @@ -87,7 +87,7 @@ <h2>
type="checkbox"
aria-describedby="id_password-show-messages">
<label class="fr-password__checkbox fr-label" for="id_password-show">
{% trans "Show" %}
{% trans "Show" %}
</label>
<div class="fr-messages-group"
id="id_password-show-messages"
Expand All @@ -106,7 +106,7 @@ <h2>
<ul class="fr-btns-group">
<li>
<button class="fr-mt-2v fr-btn">
{% trans "Login" %}
{% trans "Login" %}
</button>
</li>
</ul>
Expand Down

0 comments on commit 67bc298

Please sign in to comment.