wip: add a 403.html template

This commit is contained in:
Yohan Boniface 2024-12-23 15:58:11 +01:00
parent d4fb92ec56
commit ddddf4ece3
6 changed files with 49 additions and 27 deletions

View file

@ -1,10 +1,11 @@
from functools import wraps
from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.http import HttpResponseForbidden
from django.shortcuts import get_object_or_404
from django.urls import reverse_lazy
from django.utils.translation import gettext as _
from .models import Map, Team
from .views import simple_json_response
@ -55,7 +56,7 @@ def can_view_map(view_func):
map_inst = get_object_or_404(Map, pk=kwargs["map_id"])
kwargs["map_inst"] = map_inst # Avoid rerequesting the map in the view
if not map_inst.can_view(request):
return HttpResponseForbidden()
raise PermissionDenied(_("This map is not publicly available"))
return view_func(request, *args, **kwargs)
return wrapper

View file

@ -208,31 +208,34 @@ input[type="submit"],
}
/* **************************** */
/* 404 */
/* 40x */
/* **************************** */
.content404 {
width: 400px;
.content-40x {
width: 600px;
margin-left: auto;
margin-right: auto;
margin-top: 100px;
text-align: center;
}
.content404 a {
.content-40x a {
color: #3A4259;
}
.content404 h1 {
font-size: 10em;
.content-40x h1 {
font-size: 2em;
margin-bottom: 0;
line-height: 0.5em;
margin-top: 40px;
}
.content404 h2 {
font-size: 4em;
margin-top: 0;
}
.content404 img {
.content-404 img {
width: 32%;
}
.page-40x {
background-image: url('./img/logo_lightcyan.svg');
background-repeat: no-repeat;
background-size: contain;
background-position: center;
width: 100vw;
height: 90vh;
}
/* **************************** */

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg viewBox="0 0 128 128" width="128" height="128" version="1.1" id="svg2" sodipodi:docname="logo_lightgreen.svg" inkscape:version="1.4 (e7c3feb100, 2024-10-09)" 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">
<defs id="defs2" />
<sodipodi:namedview id="namedview2" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:showpageshadow="2" inkscape:pageopacity="0.0" inkscape:pagecheckerboard="0" inkscape:deskcolor="#d1d1d1" inkscape:zoom="6.25" inkscape:cx="63.92" inkscape:cy="64" inkscape:window-width="1920" inkscape:window-height="1011" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="1" inkscape:current-layer="svg2" />
<path d="M36.5 6.2A64 64 0 0 0 64 128C14.5 81.8 3.1 24.8 36.5 6.2zM64 128A64 64 0 0 0 91.5 6.2c33.4 18.6 22 75.6-27.5 121.8z" fill="#263B58" id="path1" style="fill:#eafcf1;fill-opacity:1" />
<path d="M87.7 33.8a23.7 23.7 0 1 1-47.4 0 23.7 23.7 0 0 1 47.4 0z" fill="#263B58" id="path2" style="fill:#eafcf1;fill-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

11
umap/templates/403.html Normal file
View file

@ -0,0 +1,11 @@
{% extends "40x.html" %}
{% load i18n %}
{% block content %}
<div class="content-40x">
<h1>{{ exception }}</h1>
<p>{% blocktrans %}<a href="">Find out here</a> how to manage map permissions.{% endblocktrans %}</p>
<p><a href="{% url 'home' %}">{% trans "Go back home" %}</a></p>
</div>
{% endblock %}

View file

@ -1,19 +1,10 @@
{% extends "base.html" %}
{% extends "40x.html" %}
{% load i18n static %}
{% block content %}
<div class="content404">
<a href="{% url "home" %}"
title="{% trans "Take me to the home page" %}">
<h1>
4
<img alt="0" width="128px" height="128px" src="{% static "umap/img/logo.svg" %}">
4
</h1>
<h2>
Not Found
</h2>
</a>
<div class="content-40x content-404">
<h1>404 Not Found</h2>
<p><a href="{% url 'home' %}">{% trans "Go back home" %}</a></p>
</div>
{% endblock content %}

9
umap/templates/40x.html Normal file
View file

@ -0,0 +1,9 @@
{% extends "base.html" %}
{% load umap_tags %}
{% block body_class %}page-40x{% endblock body_class %}
{% block extra_head %}
{% umap_css %}
{{ block.super }}
{% umap_js %}
{% endblock extra_head %}