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

Redesign de la fiche détaillée #968

Merged
merged 120 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
10aa24c
reorganize template files
fabienheureux Oct 22, 2024
f320a4e
wip
fabienheureux Oct 22, 2024
e048df6
wip
fabienheureux Oct 22, 2024
86f0608
Merge remote-tracking branch 'origin/main' into actor-detail-redesign
fabienheureux Oct 23, 2024
71660b7
WIP
fabienheureux Oct 23, 2024
fe5c9d8
reorganize folders
fabienheureux Oct 23, 2024
ecffdf0
reorganize folders
fabienheureux Oct 23, 2024
52c2d86
reorganize folders
fabienheureux Oct 23, 2024
7e58652
reorganize folders
fabienheureux Oct 23, 2024
31b975c
WIP
fabienheureux Oct 23, 2024
4855f55
new html files
fabienheureux Oct 23, 2024
09f3883
improve parcel
fabienheureux Oct 24, 2024
ded809f
wip
fabienheureux Oct 24, 2024
1b2b530
wip
fabienheureux Oct 24, 2024
b61879e
wip - non fonctionnel, problèmes jinja
fabienheureux Oct 24, 2024
d054c9b
wip
fabienheureux Oct 24, 2024
b0648cf
Wip
fabienheureux Oct 24, 2024
f05e855
Wip
fabienheureux Oct 24, 2024
dcbbf59
add parcel transformers
fabienheureux Oct 25, 2024
e303fb7
wip
fabienheureux Oct 28, 2024
0b53035
wip
fabienheureux Oct 28, 2024
b086efc
wip
fabienheureux Oct 28, 2024
8ea0d2d
Add proposition services
fabienheureux Oct 28, 2024
62e04f5
wip
fabienheureux Oct 28, 2024
4e3275e
WIP
fabienheureux Oct 29, 2024
de9fca1
remove comments
fabienheureux Oct 29, 2024
23603d6
cleanup
fabienheureux Oct 29, 2024
3f4416d
cleanup
fabienheureux Oct 29, 2024
e49a911
Improve - responsive
fabienheureux Oct 30, 2024
a4e38c1
WIP
fabienheureux Oct 30, 2024
048fd0b
Better split structure between viewsa
fabienheureux Oct 31, 2024
5758ebc
Remove jinja dependencies
fabienheureux Oct 31, 2024
b6ad3d8
fiou
fabienheureux Oct 31, 2024
8674bd1
WIP
fabienheureux Oct 31, 2024
ab54750
WIP
fabienheureux Oct 31, 2024
23631ba
WIP
fabienheureux Oct 31, 2024
6261d92
WIP
fabienheureux Oct 31, 2024
01d312e
Merge remote-tracking branch 'origin/main' into actor-detail-redesign
fabienheureux Oct 31, 2024
d0de27a
wip
fabienheureux Oct 31, 2024
de234cc
Add sitemap
fabienheureux Oct 31, 2024
a4377b0
wip
fabienheureux Nov 1, 2024
620412d
wip
fabienheureux Nov 1, 2024
5baea3a
wip
fabienheureux Nov 1, 2024
48c6b3c
improve modal
fabienheureux Nov 1, 2024
adc6253
fix frontend deps
fabienheureux Nov 1, 2024
6c60f0d
backend deps
fabienheureux Nov 1, 2024
349f2e0
wip
fabienheureux Nov 1, 2024
0275fa7
Wip
fabienheureux Nov 1, 2024
88d857e
WIP
fabienheureux Nov 1, 2024
e226461
fix tests
fabienheureux Nov 1, 2024
f16dd5c
wip
fabienheureux Nov 1, 2024
b747446
temporarily pass e2e tests
fabienheureux Nov 4, 2024
d3fe709
fix e2e tests
fabienheureux Nov 4, 2024
abc5db1
Fix e2e tests
fabienheureux Nov 4, 2024
1fe16c1
Rewrite e2e tests
fabienheureux Nov 4, 2024
b1519ca
Fix e2e tests / a11y
fabienheureux Nov 4, 2024
3d51cc2
Fix e2e
fabienheureux Nov 4, 2024
ef45934
WIP
fabienheureux Nov 4, 2024
4e7e781
WIP
fabienheureux Nov 4, 2024
fd1bba4
Move some data actions to carte template
fabienheureux Nov 4, 2024
8586f41
Update e2e - revert before merge
fabienheureux Nov 4, 2024
1c73dbe
erge remote-tracking branch 'origin/main' into actor-detail-redesign
fabienheureux Nov 4, 2024
208df3b
lockfile
fabienheureux Nov 4, 2024
4f00a03
fix header
fabienheureux Nov 4, 2024
59b70b8
Merge remote-tracking branch 'origin/main' into actor-detail-redesign
fabienheureux Nov 5, 2024
db46bc9
wip
fabienheureux Nov 5, 2024
ba891b7
wip
fabienheureux Nov 5, 2024
a33021c
Fix order for actions
fabienheureux Nov 5, 2024
dfeb73f
wip
fabienheureux Nov 5, 2024
ad82fa6
fix tests
fabienheureux Nov 5, 2024
1440c1d
wip
fabienheureux Nov 5, 2024
fc6303b
fix unit tests
fabienheureux Nov 5, 2024
ff10b75
Merge remote-tracking branch 'origin/main' into actor-detail-redesign
fabienheureux Nov 5, 2024
1034490
Merge remote-tracking branch 'origin/main' into actor-detail-redesign
fabienheureux Nov 5, 2024
cf8d597
Update qfdmo/views/adresses.py
fabienheureux Nov 7, 2024
797136e
Update qfdmo/views/adresses.py
fabienheureux Nov 7, 2024
af37181
extract dsfr colors
fabienheureux Nov 7, 2024
f927673
dsfr hacks
fabienheureux Nov 7, 2024
ff1d314
dsfr hacks
fabienheureux Nov 7, 2024
36743dd
Wip
fabienheureux Nov 7, 2024
ebdd36a
wip
fabienheureux Nov 7, 2024
c653403
Regressions
fabienheureux Nov 7, 2024
62f1d15
Revert useless change
fabienheureux Nov 7, 2024
38f1b46
Revert useless change
fabienheureux Nov 7, 2024
7d59971
Merge remote-tracking branch 'origin/main' into actor-detail-redesign
fabienheureux Nov 7, 2024
7330c93
Move get_share_url method
fabienheureux Nov 7, 2024
4547c64
Feedbacks
fabienheureux Nov 7, 2024
da6ed5b
Remove useless context processor
fabienheureux Nov 7, 2024
a737ce8
add comment
fabienheureux Nov 7, 2024
ba49850
WIP
fabienheureux Nov 7, 2024
ff7a692
add merge migration
fabienheureux Nov 7, 2024
c94e57d
Missing file...
fabienheureux Nov 7, 2024
9c22c4e
WIP
fabienheureux Nov 7, 2024
aecd4c6
Merge remote-tracking branch 'origin/main' into actor-detail-redesign
fabienheureux Nov 7, 2024
dadc922
merge migrations
fabienheureux Nov 7, 2024
3ae9d59
Missing file...
fabienheureux Nov 7, 2024
522a7ad
Merge remote-tracking branch 'origin/main' into actor-detail-redesign
fabienheureux Nov 12, 2024
b02f776
Add optionnal border on sources component
fabienheureux Nov 12, 2024
42dc3b2
Set iframe to be scrollable
fabienheureux Nov 12, 2024
179e2da
Update docs
fabienheureux Nov 12, 2024
825e3cd
Bold text
fabienheureux Nov 12, 2024
6eb5c13
Fixes feedbacks
fabienheureux Nov 12, 2024
3c985a4
Add test
fabienheureux Nov 12, 2024
68065fb
Revert e2e test deletion
fabienheureux Nov 12, 2024
13d3cd8
Do not add value to cleaned_data
fabienheureux Nov 12, 2024
67e88dd
Wip
fabienheureux Nov 12, 2024
ee17c6d
WIIIIP
fabienheureux Nov 12, 2024
d9c9c21
WIIIIP
fabienheureux Nov 12, 2024
7176450
Update tailwind.config.js
fabienheureux Nov 13, 2024
a736d48
Declutter blocks in carte / formulaire templates
fabienheureux Nov 13, 2024
3b656fa
Declutter blocks in carte / formulaire templates
fabienheureux Nov 13, 2024
29aeabc
Version fonctionnelle en fixed sur la carte
fabienheureux Nov 13, 2024
80369c0
Version fonctionnelle formulaire
fabienheureux Nov 13, 2024
32c0bff
Fix scroll on formulaire version
fabienheureux Nov 13, 2024
25956d3
Force z index in formulaire version
fabienheureux Nov 13, 2024
ec3f992
Fix e2e and add comment
fabienheureux Nov 13, 2024
2ea926e
Merge remote-tracking branch 'origin/main' into actor-detail-redesign
fabienheureux Nov 13, 2024
18a6948
On drop le mode standalone
fabienheureux Nov 13, 2024
9b57e56
Merge remote-tracking branch 'origin/main' into actor-detail-redesign
fabienheureux Nov 13, 2024
3e4a88d
fix frontend tests
fabienheureux Nov 13, 2024
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
6 changes: 6 additions & 0 deletions .parcelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "@parcel/config-default",
"transformers": {
"node_modules/@gouvfr/dsfr/**/*.{js,css}": ["./parcel-transformers/remove-ie-hack", "...", "./parcel-transformers/dsfr"],
}
}
3 changes: 2 additions & 1 deletion .postcssrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"plugins": {
"tailwindcss": true
"tailwindcss": true,
"postcss-nesting": true
}
}
10 changes: 5 additions & 5 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
"filename": "core/settings.py",
"hashed_secret": "1ee34e26aeaf89c64ecc2c85efe6a961b75a50e9",
"is_verified": false,
"line_number": 203
"line_number": 209
}
],
"docker-compose.yml": [
Expand All @@ -178,7 +178,7 @@
"filename": "jinja2/layout/base.html",
"hashed_secret": "057dece35d736a3ae1e710a9cba3f080bd101cde",
"is_verified": false,
"line_number": 71
"line_number": 78
}
],
"static/to_compile/src/analytics.ts": [
Expand All @@ -187,14 +187,14 @@
"filename": "static/to_compile/src/analytics.ts",
"hashed_secret": "d18c4e3c4c78b9cb093367ad31172846fe044e15",
"is_verified": false,
"line_number": 9
"line_number": 10
},
{
"type": "Base64 High Entropy String",
"filename": "static/to_compile/src/analytics.ts",
"hashed_secret": "53206fbbe4b5f629cab678b33aca7ca33f144e2f",
"is_verified": false,
"line_number": 14
"line_number": 15
}
],
"unit_tests/qfdmo/test_views.py": [
Expand All @@ -207,5 +207,5 @@
}
]
},
"generated_at": "2024-10-23T11:40:03Z"
"generated_at": "2024-11-13T09:55:29Z"
}
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ migrate:
makemigrations:
$(DJANGO_ADMIN) makemigrations

.PHONY: merge-migrations
merge-migrations:
$(DJANGO_ADMIN) makemigrations --merge


.PHONY: createcachetable
createcachetable:
Expand All @@ -84,6 +88,10 @@ createsuperuser:
seed-database:
$(DJANGO_ADMIN) loaddata categories actions acteur_services acteur_types

.PHONY: restore-prod
restore-prod:
./scripts/restore_prod_locally.sh

.PHONY: clear-cache
clear-cache:
$(DJANGO_ADMIN) clear_cache --all
Expand Down Expand Up @@ -116,3 +124,10 @@ js-test:
test:
@make unit-test
@make e2e-test

# DSFR
.PHONY: extract-dsfr
extract-dsfr:
$(PYTHON) ./dsfr_hacks/extract_dsfr_colors.py
$(PYTHON) ./dsfr_hacks/extract_used_colors.py
$(PYTHON) ./dsfr_hacks/extract_used_icons.py
2 changes: 1 addition & 1 deletion Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
services: docker compose --profile lvao up
web: .venv/bin/python manage.py runserver
web: .venv/bin/python manage.py runserver 0.0.0.0:8000
fabienheureux marked this conversation as resolved.
Show resolved Hide resolved
npm: npm run watch
1 change: 1 addition & 0 deletions core/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ def environment(request):
return {
"ENVIRONMENT": settings.ENVIRONMENT,
"DEBUG": settings.DEBUG,
"is_embedded": True,
}
53 changes: 16 additions & 37 deletions core/jinja2_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,8 @@
from qfdmo.models.action import get_actions_by_direction


def is_embedded(request: HttpRequest) -> bool:
return "iframe" in request.GET or "carte" in request.GET


def is_carte(request: HttpRequest) -> bool:
return "carte" in request.GET


def is_iframe(request: HttpRequest) -> bool:
return "iframe" in request.GET


def action_by_direction(request: HttpRequest, direction: str):
# TODO: refactor to not use a dict anymore
requested_direction = get_direction(request)
action_displayed = request.GET.get("action_displayed", "")
actions_to_display = get_actions_by_direction()[direction]
Expand All @@ -45,14 +34,6 @@ def action_by_direction(request: HttpRequest, direction: str):
return [{**a, "active": True} for a in actions_to_display]


# TODO : should be deprecated and replaced by a value in context view
def display_infos_panel(adresse: DisplayedActeur) -> bool:
return (
bool(adresse.horaires_description or adresse.display_postal_address())
and not adresse.is_digital
)


# TODO : should be deprecated and replaced by a value in context view
def display_exclusivite_reparation(acteur: DisplayedActeur) -> bool:
return acteur.exclusivite_de_reprisereparation
Expand All @@ -62,37 +43,35 @@ def hide_object_filter(request) -> bool:
return bool(request.GET.get("sc_id"))


def distance_to_acteur(request, adresse):
long = request.GET.get("longitude")
lat = request.GET.get("latitude")
point = adresse.location
def distance_to_acteur(request, acteur):
longitude = request.GET.get("longitude")
latitude = request.GET.get("latitude")
location = acteur.location

if not (longitude and latitude and location and not acteur.is_digital):
return ""
fabienheureux marked this conversation as resolved.
Show resolved Hide resolved

if long and lat and point and not adresse.is_digital:
dist = sqrt((point.y - float(lat)) ** 2 + (point.x - float(long)) ** 2) * 111320
return (
f"({str(round(dist/1000,1)).replace('.',',')} km)"
if dist >= 1000
else f"({round(dist/10)*10} m)"
)
return ""
distance_meters = (
sqrt((location.y - float(latitude)) ** 2 + (location.x - float(longitude)) ** 2)
* 111320
)
if distance_meters >= 1000:
return f"({round(distance_meters / 1000, 1)} km)".replace(".", ",")
fabienheureux marked this conversation as resolved.
Show resolved Hide resolved
else:
return f"({round(distance_meters/10) * 10 } m)"


def environment(**options):
env = Environment(**options)
env.globals.update(
{
"action_by_direction": action_by_direction,
"display_infos_panel": display_infos_panel,
"hide_object_filter": hide_object_filter,
"distance_to_acteur": distance_to_acteur,
"display_exclusivite_reparation": display_exclusivite_reparation,
"is_embedded": is_embedded,
"is_iframe": is_iframe,
"is_carte": is_carte,
"url": reverse,
"static": static,
"quote_plus": lambda u: quote_plus(u),
"ENVIRONMENT": settings.ENVIRONMENT,
"AIRFLOW_WEBSERVER_REFRESHACTEUR_URL": (
settings.AIRFLOW_WEBSERVER_REFRESHACTEUR_URL
),
Expand Down
26 changes: 16 additions & 10 deletions core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.sitemaps",
"whitenoise.runserver_nostatic",
"django.contrib.staticfiles",
"django.contrib.gis",
Expand All @@ -50,6 +51,7 @@
"widget_tweaks",
"dsfr",
"django.forms",
"colorfield",
"core",
"qfdmd",
"qfdmo",
Expand Down Expand Up @@ -155,28 +157,32 @@

ROOT_URLCONF = "core.urls"


def context_processors():
return [
"django.template.context_processors.debug",
fabienheureux marked this conversation as resolved.
Show resolved Hide resolved
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"core.context_processors.environment",
"dsfr.context_processors.site_config",
]


TEMPLATES = [
{
"BACKEND": "django.template.backends.jinja2.Jinja2",
"DIRS": [BASE_DIR / "jinja2"],
"OPTIONS": {
"environment": "core.jinja2_handler.environment",
"context_processors": context_processors(),
},
},
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [BASE_DIR / "templates"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"core.context_processors.environment",
"dsfr.context_processors.site_config",
],
},
"OPTIONS": {"context_processors": context_processors()},
},
]

Expand Down
30 changes: 30 additions & 0 deletions core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,45 @@

from django.conf import settings
from django.contrib import admin
from django.contrib.sitemaps import GenericSitemap
from django.contrib.sitemaps import views as sitemaps_views
from django.urls import include, path

from qfdmo.models.acteur import DisplayedActeur

from .api import api

info_dict = {
"queryset": DisplayedActeur.objects.all(),
"date_field": "modifie_le",
}


class PaginatedSitemap(GenericSitemap):
limit = 500


sitemaps = {"items": PaginatedSitemap(info_dict, priority=1.0)}


urlpatterns = [
path("admin/", admin.site.urls),
path("api/", api.urls),
path("explorer/", include("explorer.urls")),
path(
"sitemap.xml",
sitemaps_views.index,
{"sitemaps": sitemaps},
name="django.contrib.sitemaps.views.index",
),
path(
"sitemap-<section>.xml",
sitemaps_views.sitemap,
{"sitemaps": sitemaps},
name="django.contrib.sitemaps.views.sitemap",
),
path("", include(("qfdmo.urls", "qfdmo"), namespace="qfdmo")),
path("dsfr/", include(("dsfr_hacks.urls", "dsfr_hacks"), namespace="dsfr_hacks")),
]

if settings.DEBUG:
Expand Down
3 changes: 3 additions & 0 deletions docs/Coding-guidelines
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Coding guidelines

- Nommage (et [Swift API Guidelines](https://www.swift.org/documentation/api-design-guidelines/))
78 changes: 78 additions & 0 deletions docs/Frontend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Frontend et templating

Le projet utilise le templating Django pour développer le frontend.

- Jinja vs templating Django
- Parcel
- Tailwind
- Organisation et découpage des templates
- Utilisation des formulaires
- Django DSFR

## Jinja et templating Django

Le projet utilise Jinja et le templating Django.
:warning: **Ces deux approches cohabitent mais il est envisagé d'abandonner Jinja à terme.**
Quand bien même les templates continuent d'être placé dans le dossier `jinja2` afin de garantir une rétrocompatibilité, tous les futurs développement doivent s'efforcer de s'affranchir de Jinja.

## Parcel

[Parcel](https://parceljs.org) est utilisé pour compiler les fichiers statiques : CSS, JS notamment.
Les sources sont configurées dans le fichier package.json`

### Transformers

Le projet utilise des _transformers_, ceux-ci sont principalement utilisés pour assainir le DSFR aujourd'hui.

### PostCSS

Parcel embarque PostCSS, celui-ci est étendu dans le projet pour supporter Tailwind et le [_CSS nesting_](https://www.w3.org/TR/css-nesting-1/)


## Organisation et découpage des templates

On considère que le découpage de templates peut avoir lieu dans plusieurs situations :
- Rendre un élément de design réutilisable (composant du DSFR, composant custom)
- Rendre un template moins lourd et le découper en petites unités fonctionnelles

Un template de composant étant considéré comme réutilisable, il sera nommé `nom_du_composant.html`
Un fragment de template étant considéré local au template qu'il compose, il sera nommé `_nom_du_fragment.html` et placé dans un dossier portant le même nom que le template où il est utilisé.

L'organisation précise des templates est laissée au jugement du développement, mais l'idée est de faire remonter à proprement parler au niveau le plus haut possible les fichiers de templates.
Par exemple, si on travaille sur le template de la fiche détaillée d'un acteur, qui utilise un composant tag, on peut retrouver l'arborescence suivante
```
shared
- tag.html
acteur
- fiche.html
- fiche
- - presentation.html
- - _tags.html
```

Avec par exemple
```jinja
{# _tags.html #}
{% for tag in tags %}
{% include "shared/tag.html" %}
{% endfor %}
```

Note : cette convention a été adoptée en cours de projet et il est possible qu'une partie des templates legacy ne la respecte pas encore.

## Tailwind

Le projet utilise Tailwind.
Les classes Tailwind sont préfixées de `qfdmo` afin de les *namespacer* par rapport aux autres dépendances utilisées (DSFR notamment).

Afin de les rendre lisible, on tentera tant que possible de les grouper par usage sur une ligne.
Par exemple les classes relatives au style (bordure, couleur, taille de texte) pourront être distinguées de celles relative au positionnement.

```html
<div class="
qfdmo-flex qfdmo-justify-around
qfdmo-border-solid qfdmo-border-black qfdmo-border-2
qfdmo-bg-white
">
```
Empty file added dsfr_hacks/__init__.py
Empty file.
Loading
Loading