Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/faq
Browse files Browse the repository at this point in the history
  • Loading branch information
pyDez committed Jan 29, 2025
2 parents 64407bd + d1ae8cb commit 34c2003
Show file tree
Hide file tree
Showing 114 changed files with 4,368 additions and 1,986 deletions.
98 changes: 48 additions & 50 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,30 @@ name: CI

# Enable Buildkit and let compose use it to speed up image building
env:
DATABASE_URL: 'postgis://envergo:envergo@localhost:5432/envergo'
DATABASE_URL: "postgis://envergo:envergo@localhost:5432/envergo"
USE_DOCKER: False
LANG: 'fr_FR.UTF-8'
LC_ALL: 'fr_FR.UTF-8'
DJANGO_SETTINGS_MODULE: 'config.settings.ci'
LANG: "fr_FR.UTF-8"
LC_ALL: "fr_FR.UTF-8"
DJANGO_SETTINGS_MODULE: "config.settings.ci"

on:
pull_request:
branches: [ "main" ]
branches: ["main"]

push:
branches: [ "main" ]
branches: ["main"]

jobs:
linter:
runs-on: ubuntu-latest
steps:

- name: Checkout Code Repository
uses: actions/checkout@v3

- name: Set up Python 3.12
uses: actions/[email protected]
with:
python-version: 3.12.3
python-version: 3.12.8

# Run all pre-commit hooks on all the files.
# Getting only staged files can be tricky in case a new PR is opened
Expand Down Expand Up @@ -86,20 +85,19 @@ jobs:
- name: Set up Python 3.12
uses: actions/[email protected]
with:
python-version: 3.12.3
python-version: 3.12.8

- name: Install python dependencies
run: pip install -r requirements/local.txt
run: pip install -r requirements/local.txt

- name: Install js dependencies
run: npm ci
run: npm ci

- name: Build assets
run: bash bin/build_assets.sh
run: bash bin/build_assets.sh

- name: Run Django Tests
run: pytest

run: pytest

e2e:
timeout-minutes: 60
Expand All @@ -123,39 +121,39 @@ jobs:
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Install French locale
run: |
sudo apt update
sudo apt install -y language-pack-fr
sudo locale-gen fr_FR.UTF-8
sudo update-locale LANG=fr_FR.UTF-8 LC_ALL=fr_FR.UTF-8
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Create empty .env file if it does not exist
run: touch .env
- name: Launch services
run: docker compose -f docker-compose.yml -f docker-compose.e2e.yml up -d
- name: Migrate database
run: docker compose -f docker-compose.yml -f docker-compose.e2e.yml run --rm django python manage.py migrate
- name: Seed database
run: docker compose -f docker-compose.yml -f docker-compose.e2e.yml run --rm django python manage.py loaddata e2e/fixtures/db_seed.json
- name: Build assets
run: docker compose -f docker-compose.yml -f docker-compose.e2e.yml run --rm django bash bin/build_assets.sh
- name: Wait for services to be ready
run: wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --tries 10 http://localhost:3000/
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Install French locale
run: |
sudo apt update
sudo apt install -y language-pack-fr
sudo locale-gen fr_FR.UTF-8
sudo update-locale LANG=fr_FR.UTF-8 LC_ALL=fr_FR.UTF-8
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Create empty .env file if it does not exist
run: touch .env
- name: Launch services
run: docker compose -f docker-compose.yml -f docker-compose.e2e.yml up -d
- name: Migrate database
run: docker compose -f docker-compose.yml -f docker-compose.e2e.yml run --rm django python manage.py migrate
- name: Seed database
run: docker compose -f docker-compose.yml -f docker-compose.e2e.yml run --rm django python manage.py loaddata e2e/fixtures/db_seed.json
- name: Build assets
run: docker compose -f docker-compose.yml -f docker-compose.e2e.yml run --rm django bash bin/build_assets.sh
- name: Wait for services to be ready
run: wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --tries 10 http://localhost:3000/
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
2 changes: 1 addition & 1 deletion compose/django/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM docker.io/python:3.12.3-slim-bookworm as python
FROM docker.io/python:3.12.8-slim-bookworm as python

# Python build stage
FROM python as python-build-stage
Expand Down
7 changes: 6 additions & 1 deletion config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#authentication-backends
AUTHENTICATION_BACKENDS = [
"django.contrib.auth.backends.ModelBackend",
"envergo.users.backends.AuthBackend",
]
# https://docs.djangoproject.com/en/dev/ref/settings/#auth-user-model
AUTH_USER_MODEL = "users.User"
Expand Down Expand Up @@ -431,4 +431,9 @@
),
}

SITE_FROM_EMAIL = {
"amenagement": "[email protected]",
"haie": "[email protected]",
}

HAIE_FAQ_URL = "https://www.notion.so/Guichet-unique-de-la-haie-propos-17afe5fe476680a9abe6c4bdf5301abb"
2 changes: 1 addition & 1 deletion config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"debug_toolbar.panels.redirects.RedirectsPanel",
# Disable profiling panel due to an issue with Python 3.12:
# https://github.com/jazzband/django-debug-toolbar/issues/1875
"debug_toolbar.panels.profiling.ProfilingPanels",
"debug_toolbar.panels.profiling.ProfilingPanel",
],
"SHOW_TEMPLATE_CONTEXT": True,
}
Expand Down
10 changes: 10 additions & 0 deletions config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@
DEFAULT_FROM_EMAIL = env(
"DJANGO_DEFAULT_FROM_EMAIL", default="EnvErgo <[email protected]>"
)
SITE_FROM_EMAIL = {
"amenagement": env(
"DJANGO_AMENAGEMENT_FROM_EMAIL",
default="EnvErgo <[email protected]>",
),
"haie": env(
"DJANGO_HAIE_FROM_EMAIL",
default="Guichet unique de la haie <[email protected]>",
),
}
# https://docs.djangoproject.com/en/dev/ref/settings/#server-email
SERVER_EMAIL = env("DJANGO_SERVER_EMAIL", default=DEFAULT_FROM_EMAIL)
# https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
Expand Down
45 changes: 0 additions & 45 deletions config/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.auth import views as auth_views
from django.contrib.auth.forms import SetPasswordForm
from django.urls import include, path
from django.utils.translation import gettext_lazy as _
from django.views import defaults as default_views
Expand All @@ -14,51 +12,8 @@
# customize error pages to handle multi-site
handler500 = server_error

# We redefine django auth patterns for better customization
auth_patterns = [
path(_("login/"), auth_views.LoginView.as_view(), name="login"),
path(_("logout/"), auth_views.LogoutView.as_view(), name="logout"),
path(
_("password_change/"),
auth_views.PasswordChangeView.as_view(form_class=SetPasswordForm),
name="password_change",
),
path(
_("password_change/done/"),
auth_views.PasswordChangeDoneView.as_view(),
name="password_change_done",
),
path(
_("password_reset/"),
auth_views.PasswordResetView.as_view(
subject_template_name="emails/password_reset_subject.txt",
email_template_name="emails/password_reset.txt",
html_email_template_name="emails/password_reset.html",
),
name="password_reset",
),
path(
_("password_reset/done/"),
auth_views.PasswordResetDoneView.as_view(),
name="password_reset_done",
),
path(
_("reset/<uidb64>/<token>/"),
auth_views.PasswordResetConfirmView.as_view(),
name="password_reset_confirm",
),
path(
_("reset/done/"),
auth_views.PasswordResetCompleteView.as_view(),
name="password_reset_complete",
),
]


urlpatterns = [
path("anymail/", include("anymail.urls")),
path(_("accounts/"), include(auth_patterns)),
path(_("users/"), include("envergo.users.urls")),
path(_("analytics/"), include("envergo.analytics.urls")),
path(_("feedback/"), include("envergo.analytics.urls")),
path("urlmappings/", include("envergo.urlmappings.urls")),
Expand Down
71 changes: 71 additions & 0 deletions config/urls_amenagement.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from django.conf import settings
from django.contrib.auth import views as auth_views
from django.contrib.auth.forms import SetPasswordForm
from django.urls import include, path
from django.utils.translation import gettext_lazy as _

Expand All @@ -8,8 +11,76 @@

from .urls import urlpatterns as common_urlpatterns

# We redefine django auth patterns for better customization
auth_patterns = [
path(
_("login/"),
auth_views.LoginView.as_view(
template_name="amenagement/registration/login.html"
),
name="login",
),
path(
_("logout/"),
auth_views.LogoutView.as_view(
template_name="amenagement/registration/logged_out.html"
),
name="logout",
),
path(
_("password_change/"),
auth_views.PasswordChangeView.as_view(
form_class=SetPasswordForm,
template_name="amenagement/registration/password_change_form.html",
),
name="password_change",
),
path(
_("password_change/done/"),
auth_views.PasswordChangeDoneView.as_view(
template_name="registration/password_change_done.html"
),
name="password_change_done",
),
path(
_("password_reset/"),
auth_views.PasswordResetView.as_view(
template_name="amenagement/registration/password_reset_form.html",
subject_template_name="amenagement/emails/password_reset_subject.txt",
email_template_name="amenagement/emails/password_reset.txt",
html_email_template_name="amenagement/emails/password_reset.html",
from_email=settings.SITE_FROM_EMAIL["amenagement"],
),
name="password_reset",
),
path(
_("password_reset/done/"),
auth_views.PasswordResetDoneView.as_view(
template_name="amenagement/registration/password_reset_done.html",
),
name="password_reset_done",
),
path(
_("reset/<uidb64>/<token>/"),
auth_views.PasswordResetConfirmView.as_view(
template_name="amenagement/registration/password_reset_confirm.html"
),
name="password_reset_confirm",
),
path(
_("reset/done/"),
auth_views.PasswordResetCompleteView.as_view(
template_name="amenagement/registration/password_reset_complete.html"
),
name="password_reset_complete",
),
]


urlpatterns = [
path("", include("envergo.pages.urls_amenagement")),
path(_("accounts/"), include(auth_patterns)),
path(_("users/"), include("envergo.users.urls")),
path(
"a/<slug:reference>/",
ShortUrlAdminRedirectView.as_view(),
Expand Down
Loading

0 comments on commit 34c2003

Please sign in to comment.