Ajout des pages d'erreur

Fix #8
This commit is contained in:
Jean-Marie Favreau 2024-04-15 16:43:47 +02:00
parent 6f3000c51b
commit 88c76a2a78
4 changed files with 208 additions and 2 deletions

View File

@ -0,0 +1,157 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="126.82973mm"
height="56.166805mm"
viewBox="0 0 126.82974 56.166805"
version="1.1"
id="svg5"
xml:space="preserve"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
sodipodi:docname="pommes.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
showgrid="false"
inkscape:zoom="1.3189567"
inkscape:cx="214.94262"
inkscape:cy="58.000389"
inkscape:window-width="1920"
inkscape:window-height="1020"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="g384" /><defs
id="defs2"><filter
inkscape:collect="always"
style="color-interpolation-filters:sRGB"
id="filter38466"
x="-0.078650487"
y="-0.29315126"
width="1.1573411"
height="1.5863822"><feGaussianBlur
inkscape:collect="always"
stdDeviation="0.81073628"
id="feGaussianBlur38468" /></filter><filter
inkscape:collect="always"
style="color-interpolation-filters:sRGB"
id="filter38466-3"
x="-0.060800894"
y="-0.25262014"
width="1.1216247"
height="1.5052374"><feGaussianBlur
inkscape:collect="always"
stdDeviation="0.81073628"
id="feGaussianBlur38468-6" /></filter><filter
inkscape:collect="always"
style="color-interpolation-filters:sRGB"
id="filter38466-3-5"
x="-0.060800895"
y="-0.25262014"
width="1.1216247"
height="1.5052374"><feGaussianBlur
inkscape:collect="always"
stdDeviation="0.81073628"
id="feGaussianBlur38468-6-3" /></filter><filter
inkscape:collect="always"
style="color-interpolation-filters:sRGB"
id="filter38466-3-2"
x="-0.060800898"
y="-0.25262014"
width="1.1216247"
height="1.5052374"><feGaussianBlur
inkscape:collect="always"
stdDeviation="0.81073628"
id="feGaussianBlur38468-6-9" /></filter></defs><g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-48.578404,-57.600845)"><g
id="g384"
transform="translate(22.72439,-118.49779)"><path
style="fill:#010000;fill-opacity:0.561232;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;filter:url(#filter38466)"
d="m 30.119151,225.67614 c 0.965519,4.45831 17.076497,4.10429 21.546399,3.22785 13.87936,-2.9076 -5.958657,-6.13886 -12.808688,-6.54436 -4.613953,0.0322 -9.286858,0.34529 -8.737711,3.31651 z"
id="path38464"
sodipodi:nodetypes="cccc" /><path
style="fill:#010000;fill-opacity:0.561232;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;filter:url(#filter38466-3)"
d="m 87.172517,226.86644 c 0.965519,4.45831 25.019863,3.96877 30.482693,1.22894 13.87937,-2.9076 -16.08645,-5.72863 -22.936483,-6.13413 -4.613953,0.0322 -8.095357,1.93397 -7.54621,4.90519 z"
id="path38464-7"
sodipodi:nodetypes="cccc" /><path
style="fill:#010000;fill-opacity:0.561232;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;filter:url(#filter38466-3-2)"
d="m 112.98123,223.50499 c 0.96552,4.45831 25.01986,3.96877 30.48269,1.22894 13.87937,-2.9076 -16.08645,-5.72863 -22.93648,-6.13413 -4.61395,0.0322 -8.09536,1.93397 -7.54621,4.90519 z"
id="path38464-7-1"
sodipodi:nodetypes="cccc" /><path
style="fill:#010000;fill-opacity:0.561232;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;filter:url(#filter38466-3-5)"
d="m 65.184109,221.28668 c 0.965519,4.45831 25.019863,3.96877 30.482693,1.22894 13.879368,-2.9076 -16.08645,-5.72863 -22.936483,-6.13413 -4.613953,0.0322 -8.095357,1.93397 -7.54621,4.90519 z"
id="path38464-7-5"
sodipodi:nodetypes="cccc" /><path
style="fill:#840103;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 86.725323,219.88316 c 0.708759,2.00893 -16.515833,0.34774 -21.687027,-7.93835 -5.171194,-8.2861 -3.763967,-13.58169 -2.234075,-17.59746 1.529892,-4.01577 2.907438,-5.92547 5.806876,-8.7927 2.899438,-2.86723 5.998448,-8.59829 11.9153,-8.91316 5.916851,-0.31487 13.246677,1.03438 18.14476,6.51896 4.898083,5.48457 4.135783,4.56309 4.327753,11.82129 0.19197,7.2582 -16.982346,22.89249 -16.273587,24.90142 z"
id="path38521"
sodipodi:nodetypes="zzzzzzzz" /><path
style="fill:#834e0c;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 133.1414,181.84555 -0.42521,-1.38416 0.9446,-0.48098 0.84134,0.21637 0.0662,5.23515 v 3.40759 c -0.36705,0.23459 -0.84847,0.0157 -1.32294,-0.17562 -3e-5,-0.13276 -0.10399,-6.81835 -0.10399,-6.81835 z"
id="path6259-6"
sodipodi:nodetypes="cccccccc" /><path
style="fill:#d60012;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 115.54426,187.09106 c 2.54917,-3.01758 3.74777,-3.75279 7.65023,-4.48524 3.90246,-0.73245 11.97354,0.59898 16.01795,0.27084 4.04441,-0.32814 10.23107,2.95585 12.4974,11.37405 2.26633,8.4182 -4.361,22.40664 -5.68702,24.68388 -1.32602,2.27724 -4.58568,3.8508 -7.30185,4.70408 -2.71617,0.85328 -3.87231,-0.18087 -5.75724,-0.21063 -1.88493,-0.0298 -3.1947,0.3369 -5.5466,0.0702 -2.3519,-0.26668 -4.45157,0.41221 -8.14438,-3.00369 -3.69281,-3.4159 -8.77859,-13.48153 -8.9869,-19.53378 -0.20831,-6.05225 2.70924,-10.85215 5.25841,-13.86973 z"
id="path44098"
sodipodi:nodetypes="zzzzzzzzzzz" /><path
style="fill:#a30b0e;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 91.049338,227.05348 c 0,0 2.096979,0.98865 3.366175,1.05833 1.269196,0.0697 2.515497,-0.62306 4.020413,-0.79375 1.504916,-0.17069 3.315514,-0.33009 4.986984,-0.15445 1.67146,0.17564 2.67655,1.44596 4.94818,1.21279 2.27163,-0.23317 4.7873,-0.53519 7.76883,-3.24162 2.98153,-2.70643 6.67077,-9.99926 8.01766,-13.7903 1.34689,-3.79104 0.964,-6.95292 0.88227,-8.76492 -0.0817,-1.812 -0.28545,-2.05058 -0.28545,-2.05058"
id="path6267"
sodipodi:nodetypes="czzzzzzzc" /><path
style="fill:#c07f16;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 97.188667,188.34369 c 1.858659,0.51169 3.166323,1.18081 5.616683,1.52344 1.36291,-0.20833 2.52486,-0.13533 4.31769,-0.94554 l -1.36453,9.43662 c 0,0 -6.727792,0.0977 -6.541247,-0.54771 0.186544,-0.6454 -2.028596,-9.46681 -2.028596,-9.46681 z"
id="path24930"
sodipodi:nodetypes="ccccsc" /><path
style="fill:#f1e890;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 103.45898,196.09727 c -1.28283,-3.55228 -5.226566,-9.29945 -10.596971,-8.55496 -5.370405,0.74449 -10.078575,7.90246 -10.928331,15.43409 -0.849756,7.53163 7.401814,24.34497 10.192223,24.52944 3.229996,0.55392 5.958819,-1.60562 6.699335,-2.56442 0.740516,-0.9588 1.0542,1.41933 1.880334,1.58911 0.82614,0.16978 1.47736,-1.00863 2.48529,-0.75867 1.00793,0.24996 4.01972,2.24324 6.05234,1.00663 8.40879,-5.32292 15.92933,-15.39837 15.55298,-25.19132 -0.22977,-5.9788 -4.35586,-13.60403 -10.22824,-14.75036 -6.96794,-1.3602 -9.33036,3.99209 -11.10896,9.26046 z"
id="path6257"
sodipodi:nodetypes="czzczzzcssc" /><path
style="fill:#e7582b;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 57.722653,216.94448 c 4.085521,3.35662 0.130547,7.52783 -5.004235,9.25697 -14.581897,4.8464 -20.31834,-3.51094 -24.926001,-7.87922"
id="path3493"
sodipodi:nodetypes="ccc" /><path
style="fill:#f1eb92;fill-opacity:0.98131;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 39.629539,202.72444 c -1.245318,-2.21148 -13.219171,2.79441 -13.275444,12.07728 -0.02329,3.84143 4.98535,6.17686 8.449628,7.83695 11.918897,5.71155 25.399655,-3.60223 22.672449,-6.00628 l -7.221348,-5.62762 c -2.701303,-0.68184 -4.827634,-2.47374 -6.528276,-5.08751 z"
id="path3491"
sodipodi:nodetypes="csscccc" /><path
style="fill:#60140f;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 44.056485,208.53269 c -0.940445,-0.96729 0.406981,2.80556 1.492086,2.91021 0.320996,0.031 0.614745,-0.43864 0.597778,-0.76068 -0.05258,-0.99795 -2.089864,-2.14953 -2.089864,-2.14953 z"
id="path5910"
sodipodi:nodetypes="ssss" /><path
style="fill:#744e0b;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 102.69003,186.3689 -0.42521,-1.38416 0.9446,-0.48098 0.84134,0.21637 0.0662,5.23515 v 3.40759 c -0.36705,0.23459 -0.84847,0.0157 -1.32294,-0.17562 -3e-5,-0.13276 -0.10399,-6.81835 -0.10399,-6.81835 z"
id="path6259"
sodipodi:nodetypes="cccccccc" /><path
style="fill:#60140f;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 105.09347,204.21755 c -0.10793,0.44487 -0.0918,0.80693 -0.0505,1.30309 0.0413,0.49616 -0.27564,1.44483 0.34253,1.64797 0.61817,0.20314 1.44979,-0.60075 1.65368,-1.48252 0.20389,-0.88177 -1.27069,-2.87462 -1.27069,-2.87462 0,0 -0.56709,0.96121 -0.67502,1.40608 z"
id="path6261"
sodipodi:nodetypes="zzzzcz" /><path
style="fill:#60140f;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 99.089819,203.26937 c -0.53143,0.0298 -0.217288,0.3086 -0.396875,0.76536 -0.179587,0.45676 -0.855987,1.48491 -0.557202,2.00672 0.298785,0.52181 1.011637,0.57281 1.473936,0.39196 0.462302,-0.18085 0.786262,-0.59664 0.778252,-1.22739 -0.008,-0.63075 -0.766681,-1.96648 -1.298111,-1.93665 z"
id="path6263"
sodipodi:nodetypes="zzzzzz" /><path
style="fill:#f5dc0c;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 103.05859,198.44574 -0.81262,4.57009 -0.31681,6.97364 0.99998,3.92596 0.75482,-4.71212 -0.0384,-3.55499 z"
id="path6265" /><path
style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
d="m 67.367899,196.68283 c 0,0 4.204417,-1.16049 5.95753,-1.68797 0.53786,-0.16183 0.794335,-3.57452 0.695045,-3.97169 -0.09929,-0.39717 -1.092213,-2.4823 -1.092213,-2.4823"
id="path39627"
sodipodi:nodetypes="cszc" /><path
style="fill:#510701;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 73.179776,194.26572 c -0.105315,-0.14042 -1.841212,-1.73181 -2.632882,-2.7733 -0.79167,-1.04149 -1.693987,-2.52693 -2.071198,-3.45155 -0.377211,-0.92462 -0.738993,-1.48616 -0.456366,-1.91264 0.282627,-0.42648 0.734231,-0.30422 1.088257,-0.18241 0.354026,0.12181 0.684882,0.55237 0.772311,0.84252 0.08743,0.29015 -0.119676,0.3973 -0.105315,0.667 0.01436,0.2697 -0.04559,0.27495 0.245735,0.91273 0.291328,0.63778 1.160067,1.94648 1.825466,2.70309 0.665399,0.75661 1.859099,1.04674 2.088991,1.83989 0.229892,0.79315 -0.09265,2.0968 -0.609346,2.08381 -0.516692,-0.013 -0.215863,-0.90466 -0.215863,-0.90466"
id="path39629"
sodipodi:nodetypes="czzzzzzzzzzc" /></g></g></svg>

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,32 @@
{% extends "agenda_culturel/page.html" %}
{% load i18n %}
{% load static %}
{% load static_content_extra %}
{% block title %}
Y'a un pépin
{% endblock %}
{% block content %}
<article>
<header>
<h1>Y'a un pépin (erreur {{ error }})</h1>
</header>
<p>On a rencontré un pépin en cherchant la page que tu as demandé&nbsp;! N'hésites pas à <a href="{% url 'contact' %}">nous signaler
tout ça</a> si tu penses qu'il y a un bug dans la compote.</p>
<div style="text-align: center"><img src="{% static 'images/pommes.svg' %}" style="width: 800px; margin: auto" /></div>
</article>
{% endblock %}

View File

@ -64,6 +64,8 @@ urlpatterns = [
path("mquestions/<int:qpk>/answers/add", ModerationAnswerCreateView.as_view(), name="add_manswer"),
path("mquestions/<int:qpk>/answers/<int:pk>/edit", ModerationAnswerUpdateView.as_view(), name="edit_manswer"),
path("mquestions/<int:qpk>/answers/<int:pk>/delete", ModerationAnswerDeleteView.as_view(), name="delete_manswer"),
path("404/", page_not_found, name="page_not_found"),
path("500/", internal_server_error, name="internal_server_error"),
]
if settings.DEBUG:
@ -78,3 +80,6 @@ js_info_dict = {
# 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'

View File

@ -7,7 +7,7 @@ from django import forms
from django.contrib.postgres.search import SearchQuery, SearchHeadline
from django.core.exceptions import PermissionDenied
from django.http import HttpResponseRedirect
from django.http import HttpResponseRedirect, HttpResponse, HttpResponseNotFound
from django.urls import reverse
import urllib
@ -50,6 +50,12 @@ def get_event_qs(request):
return Event.objects.filter(status=Event.STATUS.PUBLISHED)
def page_not_found(request, exception=None):
return render(request, 'page-erreur.html', status=404, context={"error": 404})
def internal_server_error(request):
return render(request, 'page-erreur.html', status=500, context={"error": 500})
class CategoryCheckboxSelectMultiple(forms.CheckboxSelectMultiple):
@ -393,6 +399,12 @@ class ContactMessageCreateView(SuccessMessageMixin, CreateView):
success_url = reverse_lazy('home')
success_message = _('Your message has been sent successfully.')
def get_form(self, form_class=None):
if form_class is None:
form_class = self.get_form_class()
return form_class(**self.get_form_kwargs())
class ContactMessageUpdateView(SuccessMessageMixin, PermissionRequiredMixin, LoginRequiredMixin, UpdateView):
model = ContactMessage