From 851289de47f1fa8512254b6985d443d7e5122b30 Mon Sep 17 00:00:00 2001 From: OndraRehounek <ondra.rehounek@seznam.cz> Date: Thu, 24 Feb 2022 16:51:45 +0100 Subject: [PATCH] district and region: 404 pages --- district/models.py | 5 +++++ district/templates/district/404.html | 25 +++++++++++++++++++++++++ region/models.py | 5 +++++ region/templates/region/404.html | 22 ++++++++++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 district/templates/district/404.html create mode 100644 region/templates/region/404.html diff --git a/district/models.py b/district/models.py index 59255f80..e683c413 100644 --- a/district/models.py +++ b/district/models.py @@ -2,6 +2,7 @@ import random from django.core.paginator import Paginator from django.db import models +from django.shortcuts import render from django.utils.translation import gettext_lazy from modelcluster.contrib.taggit import ClusterTaggableManager from modelcluster.fields import ParentalKey @@ -219,6 +220,10 @@ class DistrictHomePage(MetadataPageMixin, CalendarMixin, Page): def election_page(self): return self._first_subpage_of_type(DistrictElectionPage) + @staticmethod + def get_404_response(request): + return render(request, "district/404.html", status=404) + @property def people_page(self): return self._first_subpage_of_type(DistrictPeoplePage) diff --git a/district/templates/district/404.html b/district/templates/district/404.html new file mode 100644 index 00000000..e7455978 --- /dev/null +++ b/district/templates/district/404.html @@ -0,0 +1,25 @@ +{#{% extends 'district/base.html' %} radši ne-extendujeme base, aby nezklouzlo na 500 v případě nějakého problému #} +{% load static %} + +<html lang="cs"> + <head> + <link rel="stylesheet" href="{% static 'styleguide18/assets/css/styles.css' %}"> + <title>404</title> + </head> + <body> + {# {% block content %}#} + <div class="flex flex-col my-40 items-center"> + <h1 class="head-alt-lg mb-8"> + 404 + </h1> + <img src="{% static 'shared/img/logo_black.svg' %}" alt class="mb-8"/> + <h1 class="head-alt-md mb-8"> + Narazili jsme na mělčinu... + </h1> + <a href="/"> + Zpět do přístavu + </a> + </div> + {# {% endblock content %}#} + </body> +</html> diff --git a/region/models.py b/region/models.py index 7a894bfa..2c43c4e0 100644 --- a/region/models.py +++ b/region/models.py @@ -2,6 +2,7 @@ import random from django.core.paginator import Paginator from django.db import models +from django.shortcuts import render from django.utils.translation import gettext_lazy from modelcluster.contrib.taggit import ClusterTaggableManager from modelcluster.fields import ParentalKey @@ -219,6 +220,10 @@ class RegionHomePage(MetadataPageMixin, CalendarMixin, Page): def election_page(self): return self._first_subpage_of_type(RegionElectionPage) + @staticmethod + def get_404_response(request): + return render(request, "region/404.html", status=404) + @property def people_page(self): return self._first_subpage_of_type(RegionPeoplePage) diff --git a/region/templates/region/404.html b/region/templates/region/404.html new file mode 100644 index 00000000..c87ff38e --- /dev/null +++ b/region/templates/region/404.html @@ -0,0 +1,22 @@ +{% load static %} + +<html lang="cs"> + <head> + <link rel="stylesheet" href="{% static 'styleguide18/assets/css/styles.css' %}"> + <title>404</title> + </head> + <body> + <div class="flex flex-col my-40 items-center"> + <h1 class="head-alt-lg mb-8"> + 404 + </h1> + <img src="{% static 'shared/img/logo_black.svg' %}" alt class="mb-8"/> + <h1 class="head-alt-md mb-8"> + Narazili jsme na mělčinu... + </h1> + <a href="/"> + Zpět do přístavu + </a> + </div> + </body> +</html> -- GitLab