Séparation des vues générales

This commit is contained in:
SebF 2025-03-24 10:33:45 +01:00
parent 47feea263a
commit e127a25a0e
4 changed files with 65 additions and 54 deletions

View File

@ -20,6 +20,12 @@ from .views import (
# Errors # Errors
internal_server_error, internal_server_error,
page_not_found, page_not_found,
# General pages
about,
import_requirements,
mentions_legales,
moderation_rules,
thank_you,
# TODO pas encore trié # TODO pas encore trié
home, home,
week_view, week_view,
@ -76,8 +82,6 @@ from .views import (
DuplicatedEventsDetailView, DuplicatedEventsDetailView,
StaticContentCreateView, StaticContentCreateView,
StaticContentUpdateView, StaticContentUpdateView,
about,
thank_you,
MessageCreateView, MessageCreateView,
merge_duplicate, merge_duplicate,
EventCreateView, EventCreateView,
@ -95,7 +99,6 @@ from .views import (
import_event_proxy, import_event_proxy,
import_from_url, import_from_url,
import_from_urls, import_from_urls,
mentions_legales,
view_messages, view_messages,
MessageUpdateView, MessageUpdateView,
statistics, statistics,
@ -105,8 +108,6 @@ from .views import (
CategorisationRuleDeleteView, CategorisationRuleDeleteView,
CategorisationRuleUpdateView, CategorisationRuleUpdateView,
apply_categorisation_rules, apply_categorisation_rules,
moderation_rules,
import_requirements,
UserProfileUpdateView, UserProfileUpdateView,
) )
@ -141,6 +142,12 @@ urlpatterns = [
# Errors # Errors
path("500/", internal_server_error, name="internal_server_error"), path("500/", internal_server_error, name="internal_server_error"),
path("404/", page_not_found, name="page_not_found"), path("404/", page_not_found, name="page_not_found"),
# General pages
path("a-propos", about, name="about"),
path("besoin-pour-import", import_requirements, name="import_requirements"),
path("mentions-legales", mentions_legales, name="mentions_legales"),
path("regles-de-moderation", moderation_rules, name="moderation_rules"),
path("merci", thank_you, name="thank_you"),
# TODO pas encore trié # TODO pas encore trié
path("", home, name="home"), path("", home, name="home"),
path("cat:<cat>/", home, name="home_category"), path("cat:<cat>/", home, name="home_category"),
@ -291,11 +298,6 @@ urlpatterns = [
), ),
path("rechercher", event_search, name="event_search"), path("rechercher", event_search, name="event_search"),
path("rechercher/complet/", event_search_full, name="event_search_full"), path("rechercher/complet/", event_search_full, name="event_search_full"),
path("mentions-legales", mentions_legales, name="mentions_legales"),
path("a-propos", about, name="about"),
path("regles-de-moderation", moderation_rules, name="moderation_rules"),
path("besoin-pour-import", import_requirements, name="import_requirements"),
path("merci", thank_you, name="thank_you"),
path("contact", MessageCreateView.as_view(), name="contact"), path("contact", MessageCreateView.as_view(), name="contact"),
path("messages", view_messages, name="messages"), path("messages", view_messages, name="messages"),
path("statistiques", statistics, name="statistics"), path("statistiques", statistics, name="statistics"),

View File

@ -1,2 +1,3 @@
from .oldviews import * from .oldviews import *
from .errors import * from .errors import *
from .general_pages_views import *

View File

@ -0,0 +1,52 @@
from django.db.models import Q
from django.shortcuts import render
from django.urls import reverse_lazy
from ..models import RecurrentImport
from django.utils.translation import gettext_lazy as _
def thank_you(request):
return render(request, "agenda_culturel/thank_you.html")
def mentions_legales(request):
context = {
"title": "Mentions légales",
"static_content": "mentions_legales",
"url_path": reverse_lazy("mentions_legales"),
}
return render(request, "agenda_culturel/page-single.html", context)
def about(request):
rimports = (
RecurrentImport.objects.filter(~Q(recurrence=RecurrentImport.RECURRENCE.NEVER))
.order_by("name__unaccent")
.all()
)
context = {
"title": "À propos",
"static_content": "about",
"url_path": reverse_lazy("about"),
"rimports": rimports,
}
return render(request, "agenda_culturel/page-rimports-list.html", context)
def moderation_rules(request):
context = {
"title": _("Moderation rules"),
"static_content": "moderation_rules",
"url_path": reverse_lazy("moderation_rules"),
}
return render(request, "agenda_culturel/page-single.html", context)
def import_requirements(request):
context = {
"title": _("Import requirements"),
"static_content": "import_requirements",
"url_path": reverse_lazy("import_requirements"),
}
return render(request, "agenda_culturel/page-single.html", context)

View File

@ -179,50 +179,6 @@ def get_event_qs(request):
return Event.objects.filter(status=Event.STATUS.PUBLISHED) return Event.objects.filter(status=Event.STATUS.PUBLISHED)
def thank_you(request):
return render(request, "agenda_culturel/thank_you.html")
def mentions_legales(request):
context = {
"title": "Mentions légales",
"static_content": "mentions_legales",
"url_path": reverse_lazy("mentions_legales"),
}
return render(request, "agenda_culturel/page-single.html", context)
def about(request):
rimports = (
RecurrentImport.objects.filter(~Q(recurrence=RecurrentImport.RECURRENCE.NEVER))
.order_by("name__unaccent")
.all()
)
context = {
"title": "À propos",
"static_content": "about",
"url_path": reverse_lazy("about"),
"rimports": rimports,
}
return render(request, "agenda_culturel/page-rimports-list.html", context)
def moderation_rules(request):
context = {
"title": _("Moderation rules"),
"static_content": "moderation_rules",
"url_path": reverse_lazy("moderation_rules"),
}
return render(request, "agenda_culturel/page-single.html", context)
def import_requirements(request):
context = {
"title": _("Import requirements"),
"static_content": "import_requirements",
"url_path": reverse_lazy("import_requirements"),
}
return render(request, "agenda_culturel/page-single.html", context)
def home(request, cat=None): def home(request, cat=None):