521 lines
16 KiB
Python
521 lines
16 KiB
Python
from django.conf import settings
|
|
from django.conf.urls.static import static
|
|
from django.contrib import admin
|
|
from django.contrib.sitemaps import GenericSitemap
|
|
from django.contrib.sitemaps.views import sitemap
|
|
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
|
from django.urls import include, path, re_path
|
|
from django.views.decorators.cache import cache_page
|
|
from django.views.i18n import JavaScriptCatalog
|
|
|
|
from .sitemaps import (
|
|
HomeCategorySitemap,
|
|
MonthCategorySitemap,
|
|
StaticViewSitemap,
|
|
UpcomingCategorySitemap,
|
|
WeekCategorySitemap,
|
|
)
|
|
from .models import Event, Place, Organisation, Category
|
|
from .views import (
|
|
# Categorisation rules
|
|
CategorisationRuleCreateView,
|
|
CategorisationRuleDeleteView,
|
|
CategorisationRuleUpdateView,
|
|
apply_categorisation_rules,
|
|
categorisation_rules,
|
|
# Errors
|
|
internal_server_error,
|
|
page_not_found,
|
|
# General pages
|
|
about,
|
|
import_requirements,
|
|
mentions_legales,
|
|
moderation_rules,
|
|
thank_you,
|
|
# Moderation
|
|
EventModerateView,
|
|
moderate_event_next,
|
|
moderate_from_date,
|
|
# Organisations
|
|
OrganisationCreateView,
|
|
OrganisationDeleteView,
|
|
OrganisationDetailView,
|
|
OrganisationDetailViewPast,
|
|
OrganisationListView,
|
|
OrganisationUpdateView,
|
|
# Tags
|
|
view_tag,
|
|
view_tag_past,
|
|
TagUpdateView,
|
|
tag_list,
|
|
TagDeleteView,
|
|
rename_tag,
|
|
delete_tag,
|
|
TagCreateView,
|
|
# Places
|
|
PlaceCreateView,
|
|
PlaceDeleteView,
|
|
PlaceDetailView,
|
|
PlaceDetailViewPast,
|
|
PlaceFromEventCreateView,
|
|
PlaceListAdminView,
|
|
PlaceListView,
|
|
PlaceUpdateView,
|
|
UnknownPlaceAddView,
|
|
UnknownPlacesListView,
|
|
fix_unknown_places,
|
|
# TODO pas encore trié
|
|
home,
|
|
week_view,
|
|
month_view,
|
|
day_view,
|
|
upcoming_events,
|
|
export_ical,
|
|
recent,
|
|
administration,
|
|
activite,
|
|
fix_duplicate,
|
|
clear_cache,
|
|
export_event_ical,
|
|
MessageDeleteView,
|
|
imports,
|
|
add_import,
|
|
update_orphan_events,
|
|
cancel_import,
|
|
run_all_fb_rimports,
|
|
run_all_rimports,
|
|
EventDetailView,
|
|
EventUpdateView,
|
|
RecurrentImportCreateView,
|
|
RecurrentImportDeleteView,
|
|
RecurrentImportUpdateView,
|
|
run_rimport,
|
|
duplicates,
|
|
DuplicatedEventsDetailView,
|
|
StaticContentCreateView,
|
|
StaticContentUpdateView,
|
|
MessageCreateView,
|
|
merge_duplicate,
|
|
EventCreateView,
|
|
event_search,
|
|
event_search_full,
|
|
recurrent_imports,
|
|
delete_cm_spam,
|
|
update_from_source,
|
|
change_status_event,
|
|
EventDeleteView,
|
|
set_duplicate,
|
|
import_event_proxy,
|
|
import_from_url,
|
|
import_from_urls,
|
|
view_messages,
|
|
MessageUpdateView,
|
|
statistics,
|
|
view_rimport,
|
|
update_duplicate_event,
|
|
UserProfileUpdateView,
|
|
)
|
|
|
|
event_dict = {
|
|
"queryset": Event.objects.all(),
|
|
"date_field": "modified_date",
|
|
}
|
|
place_dict = {
|
|
"queryset": Place.objects.all(),
|
|
}
|
|
organisation_dict = {
|
|
"queryset": Organisation.objects.all(),
|
|
}
|
|
category_dict = {
|
|
"queryset": Category.objects.all(),
|
|
}
|
|
|
|
|
|
sitemaps = {
|
|
"static": StaticViewSitemap,
|
|
"events": GenericSitemap(event_dict, priority=1.0, protocol="https"),
|
|
"places": GenericSitemap(place_dict, priority=0.6, protocol="https"),
|
|
"categories": GenericSitemap(category_dict, priority=0.8, protocol="https"),
|
|
"home_categories": HomeCategorySitemap,
|
|
"upcoming_categories": UpcomingCategorySitemap,
|
|
"week_categories": WeekCategorySitemap,
|
|
"month_categories": MonthCategorySitemap,
|
|
"organisations": GenericSitemap(organisation_dict, priority=0.2, protocol="https"),
|
|
}
|
|
|
|
urlpatterns = [
|
|
# Categorisation rules
|
|
path(
|
|
"catrules/add",
|
|
CategorisationRuleCreateView.as_view(),
|
|
name="add_catrule",
|
|
),
|
|
path(
|
|
"catrules/<int:pk>/delete",
|
|
CategorisationRuleDeleteView.as_view(),
|
|
name="delete_catrule",
|
|
),
|
|
path(
|
|
"catrules/<int:pk>/edit",
|
|
CategorisationRuleUpdateView.as_view(),
|
|
name="edit_catrule",
|
|
),
|
|
path("catrules/apply", apply_categorisation_rules, name="apply_catrules"),
|
|
path("catrules/", categorisation_rules, name="categorisation_rules"),
|
|
# Errors
|
|
path("500/", internal_server_error, name="internal_server_error"),
|
|
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"),
|
|
# Moderation
|
|
path("moderate", EventModerateView.as_view(), name="moderate"),
|
|
path(
|
|
"event/<int:pk>/moderate",
|
|
EventModerateView.as_view(),
|
|
name="moderate_event",
|
|
),
|
|
path(
|
|
"event/<int:pk>/moderate-force",
|
|
EventModerateView.as_view(),
|
|
name="moderate_event_force",
|
|
),
|
|
path(
|
|
"event/<int:pk>/moderate/after/<int:pred>",
|
|
EventModerateView.as_view(),
|
|
name="moderate_event_step",
|
|
),
|
|
path(
|
|
"event/<int:pk>/moderate/back/<int:pred>",
|
|
EventModerateView.as_view(),
|
|
name="moderate_event_backstep",
|
|
),
|
|
path(
|
|
"event/<int:pk>/moderate-next",
|
|
moderate_event_next,
|
|
name="moderate_event_next",
|
|
),
|
|
path(
|
|
"moderate/<int:y>/<int:m>/<int:d>",
|
|
moderate_from_date,
|
|
name="moderate_from_date",
|
|
),
|
|
# Organisations
|
|
path(
|
|
"organisme/add",
|
|
OrganisationCreateView.as_view(),
|
|
name="add_organisation",
|
|
),
|
|
path(
|
|
"organisme/<int:pk>/delete",
|
|
OrganisationDeleteView.as_view(),
|
|
name="delete_organisation",
|
|
),
|
|
path(
|
|
"organisme/<int:pk>-<extra>",
|
|
OrganisationDetailView.as_view(),
|
|
name="view_organisation",
|
|
),
|
|
path(
|
|
"organisme/<int:pk>-<extra>",
|
|
OrganisationDetailView.as_view(),
|
|
name="view_organisation_fullname",
|
|
),
|
|
path(
|
|
"organisme/<int:pk>",
|
|
OrganisationDetailView.as_view(),
|
|
name="view_organisation_shortname",
|
|
),
|
|
path(
|
|
"organisme/<int:pk>/past",
|
|
OrganisationDetailViewPast.as_view(),
|
|
name="view_organisation_past",
|
|
),
|
|
path(
|
|
"organisme/<int:pk>-<extra>/past",
|
|
OrganisationDetailViewPast.as_view(),
|
|
name="view_organisation_past_fullname",
|
|
),
|
|
path(
|
|
"organismes/",
|
|
OrganisationListView.as_view(),
|
|
name="view_organisations",
|
|
),
|
|
path(
|
|
"organisme/<int:pk>/edit",
|
|
OrganisationUpdateView.as_view(),
|
|
name="edit_organisation",
|
|
),
|
|
# Places
|
|
path("places/add", PlaceCreateView.as_view(), name="add_place"),
|
|
path("place/<int:pk>/delete", PlaceDeleteView.as_view(), name="delete_place"),
|
|
path("place/<int:pk>", PlaceDetailView.as_view(), name="view_place"),
|
|
path(
|
|
"place/<int:pk>-<extra>",
|
|
PlaceDetailView.as_view(),
|
|
name="view_place_fullname",
|
|
),
|
|
path(
|
|
"place/<int:pk>/past",
|
|
PlaceDetailViewPast.as_view(),
|
|
name="view_place_past",
|
|
),
|
|
path(
|
|
"place/<int:pk>-<extra>/past",
|
|
PlaceDetailViewPast.as_view(),
|
|
name="view_place_past_fullname",
|
|
),
|
|
path(
|
|
"places/add/<int:pk>",
|
|
PlaceFromEventCreateView.as_view(),
|
|
name="add_place_from_event",
|
|
),
|
|
path("places/list", PlaceListAdminView.as_view(), name="view_places_admin"),
|
|
path("places/", PlaceListView.as_view(), name="view_places"),
|
|
path("place/<int:pk>/edit", PlaceUpdateView.as_view(), name="edit_place"),
|
|
path(
|
|
"event/<int:pk>/addplace",
|
|
UnknownPlaceAddView.as_view(),
|
|
name="add_place_to_event",
|
|
),
|
|
path(
|
|
"events/unknown-places",
|
|
UnknownPlacesListView.as_view(),
|
|
name="view_unknown_places",
|
|
),
|
|
path(
|
|
"events/unknown-places/fix",
|
|
fix_unknown_places,
|
|
name="fix_unknown_places",
|
|
),
|
|
# TODO pas encore trié
|
|
path("", home, name="home"),
|
|
path("cat:<cat>/", home, name="home_category"),
|
|
path(
|
|
"cat:<cat>/semaine/<int:year>/<int:week>/",
|
|
week_view,
|
|
name="week_view_category",
|
|
),
|
|
path("cat:<cat>/cette-semaine/", week_view, name="cette_semaine_category"),
|
|
path(
|
|
"cat:<cat>/mois/<int:year>/<int:month>/",
|
|
month_view,
|
|
name="month_view_category",
|
|
),
|
|
path(
|
|
"cat:<cat>/jour/<int:year>/<int:month>/<int:day>/",
|
|
day_view,
|
|
name="day_view_category",
|
|
),
|
|
path("cat:<cat>/jour/", day_view, name="day_view_category_when"),
|
|
path("cat:<cat>/a-venir/", upcoming_events, name="a_venir_category"),
|
|
path("cat:<cat>/aujourdhui/", day_view, name="aujourdhui_category"),
|
|
path(
|
|
"cat:<cat>/a-venir/<int:year>/<int:month>/<int:day>/",
|
|
upcoming_events,
|
|
name="a_venir_jour_category",
|
|
),
|
|
path("cat:<cat>/cette-semaine/", week_view, name="cette_semaine_category"),
|
|
path("cat:<cat>/ical", export_ical, name="export_ical_category"),
|
|
path("cat:<cat>/ce-mois-ci", month_view, name="ce_mois_ci_category"),
|
|
path("semaine/<int:year>/<int:week>/", week_view, name="week_view"),
|
|
path("mois/<int:year>/<int:month>/", month_view, name="month_view"),
|
|
path("jour/<int:year>/<int:month>/<int:day>/", day_view, name="day_view"),
|
|
path("jour/", day_view, name="day_view_when"),
|
|
path("aujourdhui/", day_view, name="aujourdhui"),
|
|
path("a-venir/", upcoming_events, name="a_venir"),
|
|
path(
|
|
"a-venir/<int:year>/<int:month>/<int:day>/",
|
|
upcoming_events,
|
|
name="a_venir_jour",
|
|
),
|
|
path("cette-semaine/", week_view, name="cette_semaine"),
|
|
path("ce-mois-ci", month_view, name="ce_mois_ci"),
|
|
path("tag/<t>/", view_tag, name="view_tag"),
|
|
path("tag/<tag>/ical", export_ical, name="export_ical_tag"),
|
|
path("tag/<t>/past", view_tag_past, name="view_tag_past"),
|
|
path("tags/", tag_list, name="view_all_tags"),
|
|
path("tag/<int:pk>/edit", TagUpdateView.as_view(), name="edit_tag"),
|
|
path(
|
|
"tag/<int:pk>/delete",
|
|
TagDeleteView.as_view(),
|
|
name="delete_object_tag",
|
|
),
|
|
path("tag/<t>/rename", rename_tag, name="rename_tag"),
|
|
path("tag/<t>/delete", delete_tag, name="delete_tag"),
|
|
path("tags/add", TagCreateView.as_view(), name="add_tag"),
|
|
path("recent/", recent, name="recent"),
|
|
path("administration/", administration, name="administration"),
|
|
path("activite/", activite, name="activite"),
|
|
path(
|
|
"event/<int:year>/<int:month>/<int:day>/<int:pk>-<extra>",
|
|
EventDetailView.as_view(),
|
|
name="view_event",
|
|
),
|
|
path("event/<int:pk>/", EventDetailView.as_view(), name="edit_event_pk"),
|
|
path("event/<int:pk>/edit", EventUpdateView.as_view(), name="edit_event"),
|
|
path(
|
|
"event/<int:pk>/edit-force", EventUpdateView.as_view(), name="edit_event_force"
|
|
),
|
|
path(
|
|
"event/<int:pk>/simple-clone/edit",
|
|
EventUpdateView.as_view(),
|
|
name="simple_clone_edit",
|
|
),
|
|
path(
|
|
"event/<int:pk>/clone/edit",
|
|
EventUpdateView.as_view(),
|
|
name="clone_edit",
|
|
),
|
|
path(
|
|
"event/<int:pk>/message",
|
|
MessageCreateView.as_view(),
|
|
name="message_for_event",
|
|
),
|
|
path(
|
|
"event/<int:pk>/update-from-source",
|
|
update_from_source,
|
|
name="update_from_source",
|
|
),
|
|
path(
|
|
"event/<int:pk>/change-status/<status>",
|
|
change_status_event,
|
|
name="change_status_event",
|
|
),
|
|
path("event/<int:pk>/delete", EventDeleteView.as_view(), name="delete_event"),
|
|
path(
|
|
"event/<int:year>/<int:month>/<int:day>/<int:pk>/set_duplicate",
|
|
set_duplicate,
|
|
name="set_duplicate",
|
|
),
|
|
path("ajouter", import_event_proxy, name="add_event"),
|
|
path("ajouter/url", import_from_url, name="add_event_url"),
|
|
path("ajouter/urls", import_from_urls, name="add_event_urls"),
|
|
path("ajouter/details", EventCreateView.as_view(), name="add_event_details"),
|
|
path("admin/", admin.site.urls),
|
|
path("accounts/", include("django.contrib.auth.urls")),
|
|
path("test_app/", include("test_app.urls")),
|
|
path(
|
|
"static-content/create",
|
|
StaticContentCreateView.as_view(),
|
|
name="create_static_content",
|
|
),
|
|
path(
|
|
"static-content/<int:pk>/edit",
|
|
StaticContentUpdateView.as_view(),
|
|
name="edit_static_content",
|
|
),
|
|
path("rechercher", event_search, name="event_search"),
|
|
path("rechercher/complet/", event_search_full, name="event_search_full"),
|
|
path("contact", MessageCreateView.as_view(), name="contact"),
|
|
path("messages", view_messages, name="messages"),
|
|
path("statistiques", statistics, name="statistics"),
|
|
path("messages/spams/delete", delete_cm_spam, name="delete_cm_spam"),
|
|
path(
|
|
"message/<int:pk>",
|
|
MessageUpdateView.as_view(),
|
|
name="message",
|
|
),
|
|
path(
|
|
"message/<int:pk>/delete",
|
|
MessageDeleteView.as_view(),
|
|
name="delete_message",
|
|
),
|
|
path("imports/", imports, name="imports"),
|
|
path("imports/add", add_import, name="add_import"),
|
|
path(
|
|
"imports/orphans/run",
|
|
update_orphan_events,
|
|
name="update_orphan_events",
|
|
),
|
|
path("imports/<int:pk>/cancel", cancel_import, name="cancel_import"),
|
|
path("rimports/", recurrent_imports, name="recurrent_imports"),
|
|
path("rimports/run", run_all_rimports, name="run_all_rimports"),
|
|
path("rimports/fb/run", run_all_fb_rimports, name="run_all_fb_rimports"),
|
|
path(
|
|
"rimports/status/<status>",
|
|
recurrent_imports,
|
|
name="recurrent_imports_status",
|
|
),
|
|
path(
|
|
"rimports/status/<status>/run",
|
|
run_all_rimports,
|
|
name="run_all_rimports_status",
|
|
),
|
|
path("rimports/add", RecurrentImportCreateView.as_view(), name="add_rimport"),
|
|
path("rimports/<int:pk>/view", view_rimport, name="view_rimport"),
|
|
path("rimports/<int:pk>/stats", statistics, name="stats_rimport"),
|
|
path(
|
|
"rimports/<int:pk>/edit",
|
|
RecurrentImportUpdateView.as_view(),
|
|
name="edit_rimport",
|
|
),
|
|
path(
|
|
"rimports/<int:pk>/delete",
|
|
RecurrentImportDeleteView.as_view(),
|
|
name="delete_rimport",
|
|
),
|
|
path("rimports/<int:pk>/run", run_rimport, name="run_rimport"),
|
|
path("duplicates/", duplicates, name="duplicates"),
|
|
path(
|
|
"duplicates/<int:pk>",
|
|
DuplicatedEventsDetailView.as_view(),
|
|
name="view_duplicate",
|
|
),
|
|
path("duplicates/<int:pk>/fix", fix_duplicate, name="fix_duplicate"),
|
|
path("duplicates/<int:pk>/merge", merge_duplicate, name="merge_duplicate"),
|
|
path(
|
|
"duplicates/<int:pk>/update/<int:epk>",
|
|
update_duplicate_event,
|
|
name="update_event",
|
|
),
|
|
path(
|
|
"organisme/<int:organisation_pk>/ical",
|
|
export_ical,
|
|
name="export_ical_organisation",
|
|
),
|
|
path("place/<int:place_pk>/ical", export_ical, name="export_ical_place"),
|
|
path(
|
|
"event/<int:year>/<int:month>/<int:day>/<int:pk>/ical",
|
|
export_event_ical,
|
|
name="export_event_ical",
|
|
),
|
|
path("ical", export_ical, name="export_ical"),
|
|
re_path(r"^robots\.txt", include("robots.urls")),
|
|
path("__debug__/", include("debug_toolbar.urls")),
|
|
path("ckeditor5/", include("django_ckeditor_5.urls")),
|
|
path(
|
|
"sitemap.xml",
|
|
cache_page(86400)(sitemap),
|
|
{"sitemaps": sitemaps},
|
|
name="cached-sitemap",
|
|
),
|
|
path("cache/clear", clear_cache, name="clear_cache"),
|
|
path("profile/edit", UserProfileUpdateView.as_view(), name="edit_profile"),
|
|
]
|
|
|
|
if settings.DEBUG:
|
|
urlpatterns += staticfiles_urlpatterns()
|
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
|
|
|
# If you already have a js_info_dict dictionary, just add
|
|
# 'recurrence' to the existing 'packages' tuple.
|
|
js_info_dict = {
|
|
"packages": ("recurrence",),
|
|
}
|
|
|
|
# jsi18n can be anything you like here
|
|
urlpatterns += [
|
|
path(
|
|
"jsi18n.js",
|
|
JavaScriptCatalog.as_view(packages=["recurrence"]),
|
|
name="jsi18n",
|
|
),
|
|
]
|
|
|
|
handler404 = "agenda_culturel.views.page_not_found"
|
|
handler500 = "agenda_culturel.views.internal_server_error"
|