mod: обновить error pages и тестовые комментарии
This commit is contained in:
@@ -57,6 +57,8 @@ urlpatterns = [
|
||||
]
|
||||
|
||||
handler404 = 'web.views.handler404'
|
||||
handler400 = 'web.views.handler400'
|
||||
handler403 = 'web.views.handler403'
|
||||
handler500 = 'web.views.handler500'
|
||||
|
||||
if settings.DEBUG:
|
||||
|
||||
34
cadpoint/templates/400.html
Normal file
34
cadpoint/templates/400.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="content-language" content="ru" />
|
||||
<meta name="generator" content="Microsoft FrontPage 1.0" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.4" />
|
||||
<meta name="description" content="cadpoint.ru — запрос получился некорректным, проверьте адрес, параметры или форму" />
|
||||
<meta name="keywords" content="cadpoint.ru — плохой запрос" />
|
||||
<meta name="copyright" lang="ru" content="Sergei Erjemin" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<meta name="document-state" content="Static" />
|
||||
<meta name="generator" content="handcraft" />
|
||||
<title>CADpoint.ru - http 400 error</title>
|
||||
<meta name="theme-color" content="#F5F5F5" />
|
||||
<link rel="icon" type="image/svg+xml" href="/media/_error/svgs/favicon.svg" />
|
||||
<link rel="icon" type="image/png" href="/media/_error/img/favicon.png" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/media/_error/img/favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<div style="width:100%;height:80%;display:table;position:absolute;top:0;left:0;">
|
||||
<div style="display:table-cell;text-align:center;vertical-align:middle;">
|
||||
<div style="display:inline-block;">
|
||||
<img src="/media/_error/svgs/xxx-error.svg" alt="cadpoint.ru - http 400 error" style="width: 80vw;" />
|
||||
<pre>запрос получился некорректным.
|
||||
Проверьте адрес, параметры или форму и попробуйте ещё раз.
|
||||
<a href="/">Вернуться на главную</a></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
33
cadpoint/templates/401.html
Normal file
33
cadpoint/templates/401.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="content-language" content="ru" />
|
||||
<meta name="generator" content="Microsoft FrontPage 1.0" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.4" />
|
||||
<meta name="description" content="cadpoint.ru — чтобы открыть эту страницу, нужно войти в систему" />
|
||||
<meta name="keywords" content="cadpoint.ru — вход в систему" />
|
||||
<meta name="copyright" lang="ru" content="Sergei Erjemin" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<meta name="document-state" content="Static" />
|
||||
<meta name="generator" content="handcraft" />
|
||||
<title>CADpoint.ru - http 401 error</title>
|
||||
<meta name="theme-color" content="#F5F5F5" />
|
||||
<link rel="icon" type="image/svg+xml" href="/media/_error/svgs/favicon.svg" />
|
||||
<link rel="icon" type="image/png" href="/media/_error/img/favicon.png" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/media/_error/img/favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<div style="width:100%;height:80%;display:table;position:absolute;top:0;left:0;">
|
||||
<div style="display:table-cell;text-align:center;vertical-align:middle;">
|
||||
<div style="display:inline-block;">
|
||||
<img src="/media/_error/svgs/xxx-error.svg" alt="cadpoint.ru - http 401 error" style="width: 80vw;" />
|
||||
<pre>для этой страницы нужен вход в систему.
|
||||
Если у вас есть доступ (и вы знаете где он находится) — войдите и попробуйте ещё раз.</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
33
cadpoint/templates/403.html
Normal file
33
cadpoint/templates/403.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="content-language" content="ru" />
|
||||
<meta name="generator" content="Microsoft FrontPage 1.0" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.4" />
|
||||
<meta name="description" content="cadpoint.ru — доступ к этой странице запрещён, проверьте права доступа" />
|
||||
<meta name="keywords" content="cadpoint.ru — доступ запрещён" />
|
||||
<meta name="copyright" lang="ru" content="Sergei Erjemin" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<meta name="document-state" content="Static" />
|
||||
<meta name="generator" content="handcraft" />
|
||||
<title>CADpoint.ru - http 403 error</title>
|
||||
<meta name="theme-color" content="#F5F5F5" />
|
||||
<link rel="icon" type="image/svg+xml" href="/media/_error/svgs/favicon.svg" />
|
||||
<link rel="icon" type="image/png" href="/media/_error/img/favicon.png" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/media/_error/img/favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<div style="width:100%;height:80%;display:table;position:absolute;top:0;left:0;">
|
||||
<div style="display:table-cell;text-align:center;vertical-align:middle;">
|
||||
<div style="display:inline-block;">
|
||||
<img src="/media/_error/svgs/xxx-error.svg" alt="cadpoint.ru - http 403 error" style="width: 80vw;" />
|
||||
<pre>доступ к этой странице ограничен.
|
||||
Проверьте права доступа или обратитесь к админис­тратору, если считаете, что это ошибка.</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -6,25 +6,26 @@
|
||||
<meta http-equiv="content-language" content="ru" />
|
||||
<meta name="generator" content="Microsoft FrontPage 1.0" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.4" />
|
||||
<meta name="description" content="cadpoint.ru - http 404 error" />
|
||||
<meta name="keywords" content="cadpoint.ru - http 404 error" />
|
||||
<meta name="description" content="cadpoint.ru — страница не найдена… возможно, адрес устарел или введён с ошибкой" />
|
||||
<meta name="keywords" content="cadpoint.ru — страница не найдена" />
|
||||
<meta name="copyright" lang="ru" content="Sergei Erjemin" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<meta name="document-state" content="Static" />
|
||||
<meta name="generator" content="handcraft" />
|
||||
<title>CADpoint.ru - http 404 error</title>
|
||||
<meta name="theme-color" content="#F5F5F5" />
|
||||
<link rel="icon" type="image/svg+xml" href="/static/svgs/favicon.svg" />
|
||||
<link rel="icon" type="image/png" href="/static/img/favicon.png" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/static/img/favicon.ico" />
|
||||
<link rel="icon" type="image/svg+xml" href="/media/_error/svgs/favicon.svg" />
|
||||
<link rel="icon" type="image/png" href="/media/_error/img/favicon.png" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/media/_error/img/favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<div style="width:100%;height:80%;display:table;position:absolute;top:0;left:0;">
|
||||
<div style="display:table-cell;text-align:center;vertical-align:middle;">
|
||||
<div style="display:inline-block;">
|
||||
<img src="/static/svgs/404-error.svg"
|
||||
<img src="/media/_error/svgs/404-error.svg"
|
||||
width="80%" alt="cadpoint.ru - http 404 error" />
|
||||
<pre>попробуйте начать просмотр сайта <a href="/">с главной страницы...</a></pre>
|
||||
<pre>похоже, такой страницы или картинки больше нет.
|
||||
Если ссылка старая или адрес был введён вручную, вернитесь на главную и попробуйте ещё раз…</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
33
cadpoint/templates/413.html
Normal file
33
cadpoint/templates/413.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="content-language" content="ru" />
|
||||
<meta name="generator" content="Microsoft FrontPage 1.0" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.4" />
|
||||
<meta name="description" content="cadpoint.ru — слишком большой запрос или файл, попробуйте уменьшить объём данных" />
|
||||
<meta name="keywords" content="cadpoint.ru — слишком большой запрос" />
|
||||
<meta name="copyright" lang="ru" content="Sergei Erjemin" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<meta name="document-state" content="Static" />
|
||||
<meta name="generator" content="handcraft" />
|
||||
<title>CADpoint.ru - http 413 error</title>
|
||||
<meta name="theme-color" content="#F5F5F5" />
|
||||
<link rel="icon" type="image/svg+xml" href="/media/_error/svgs/favicon.svg" />
|
||||
<link rel="icon" type="image/png" href="/media/_error/img/favicon.png" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/media/_error/img/favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<div style="width:100%;height:80%;display:table;position:absolute;top:0;left:0;">
|
||||
<div style="display:table-cell;text-align:center;vertical-align:middle;">
|
||||
<div style="display:inline-block;">
|
||||
<img src="/media/_error/svgs/xxx-error.svg" alt="cadpoint.ru - http 413 error" style="width: 80vw;" />
|
||||
<pre>запрос оказался слишком большим.
|
||||
Попробуйте уменьшить объём данных или загрузить файл поменьше.</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
33
cadpoint/templates/429.html
Normal file
33
cadpoint/templates/429.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="content-language" content="ru" />
|
||||
<meta name="generator" content="Microsoft FrontPage 1.0" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.4" />
|
||||
<meta name="description" content="cadpoint.ru — слишком много запросов, подождите немного и попробуйте снова" />
|
||||
<meta name="keywords" content="cadpoint.ru — слишком много запросов" />
|
||||
<meta name="copyright" lang="ru" content="Sergei Erjemin" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<meta name="document-state" content="Static" />
|
||||
<meta name="generator" content="handcraft" />
|
||||
<title>CADpoint.ru - http 429 error</title>
|
||||
<meta name="theme-color" content="#F5F5F5" />
|
||||
<link rel="icon" type="image/svg+xml" href="/media/_error/svgs/favicon.svg" />
|
||||
<link rel="icon" type="image/png" href="/media/_error/img/favicon.png" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/media/_error/img/favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<div style="width:100%;height:80%;display:table;position:absolute;top:0;left:0;">
|
||||
<div style="display:table-cell;text-align:center;vertical-align:middle;">
|
||||
<div style="display:inline-block;">
|
||||
<img src="/media/_error/svgs/xxx-error.svg" alt="cadpoint.ru - http 429 error" style="width: 80vw;" />
|
||||
<pre>слишком много запросов за короткое время.
|
||||
Подождите немного и попробуйте снова.</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -6,24 +6,25 @@
|
||||
<meta http-equiv="content-language" content="ru" />
|
||||
<meta name="generator" content="Microsoft FrontPage 1.0" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.4" />
|
||||
<meta name="description" content="cadpoint.ru - http 500 error" />
|
||||
<meta name="keywords" content="cadpoint.ru - http 500 error" />
|
||||
<meta name="description" content="cadpoint.ru — внутренняя ошибка сервера, попробуйте открыть страницу чуть позже" />
|
||||
<meta name="keywords" content="cadpoint.ru — внутренняя ошибка сервера" />
|
||||
<meta name="copyright" lang="ru" content="Sergei Erjemin" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<meta name="document-state" content="Static" />
|
||||
<meta name="generator" content="handcraft" />
|
||||
<title>CADpoint.ru - http 500 error</title>
|
||||
<meta name="theme-color" content="#F5F5F5" />
|
||||
<link rel="icon" type="image/svg+xml" href="/static/svgs/favicon.svg" />
|
||||
<link rel="icon" type="image/png" href="/static/img/favicon.png" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/static/img/favicon.ico" />
|
||||
<link rel="icon" type="image/svg+xml" href="/media/_error/svgs/favicon.svg" />
|
||||
<link rel="icon" type="image/png" href="/media/_error/img/favicon.png" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/media/_error/img/favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<div style="width:100%;height:80%;display:table;position:absolute;top:0;left:0;">
|
||||
<div style="display:table-cell;text-align:center;vertical-align:middle;">
|
||||
<div style="display:inline-block;">
|
||||
<img src="/static/svgs/500-error.svg" alt="cadpoint.ru - http 500 error" style="width: 80vw;" />
|
||||
<pre>подождите, скоро все починят...</pre>
|
||||
<img src="/media/_error/svgs/500-error.svg" alt="cadpoint.ru - http 500 error" style="width: 80vw;" />
|
||||
<pre>подождите, скоро всё починят…
|
||||
Если ошибка повторяется, серверу нужен небольшой ремонт.</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
33
cadpoint/templates/502.html
Normal file
33
cadpoint/templates/502.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="content-language" content="ru" />
|
||||
<meta name="generator" content="Microsoft FrontPage 1.0" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.4" />
|
||||
<meta name="description" content="cadpoint.ru — сервис временно недоступен, попробуйте снова чуть позже" />
|
||||
<meta name="keywords" content="cadpoint.ru — сервис временно недоступен" />
|
||||
<meta name="copyright" lang="ru" content="Sergei Erjemin" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<meta name="document-state" content="Static" />
|
||||
<meta name="generator" content="handcraft" />
|
||||
<title>CADpoint.ru - http 502 error</title>
|
||||
<meta name="theme-color" content="#F5F5F5" />
|
||||
<link rel="icon" type="image/svg+xml" href="/media/_error/svgs/favicon.svg" />
|
||||
<link rel="icon" type="image/png" href="/media/_error/img/favicon.png" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/media/_error/img/favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<div style="width:100%;height:80%;display:table;position:absolute;top:0;left:0;">
|
||||
<div style="display:table-cell;text-align:center;vertical-align:middle;">
|
||||
<div style="display:inline-block;">
|
||||
<img src="/media/_error/svgs/xxx-error.svg" alt="cadpoint.ru - http 502 error" style="width: 80vw;" />
|
||||
<pre>сервис временно недоступен.
|
||||
Попробуйте открыть страницу чуть позже.</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
33
cadpoint/templates/503.html
Normal file
33
cadpoint/templates/503.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="content-language" content="ru" />
|
||||
<meta name="generator" content="Microsoft FrontPage 1.0" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.4" />
|
||||
<meta name="description" content="cadpoint.ru — сервис временно недоступен, идёт обслуживание или высокая нагрузка" />
|
||||
<meta name="keywords" content="cadpoint.ru — сервис временно недоступен" />
|
||||
<meta name="copyright" lang="ru" content="Sergei Erjemin" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<meta name="document-state" content="Static" />
|
||||
<meta name="generator" content="handcraft" />
|
||||
<title>CADpoint.ru - http 503 error</title>
|
||||
<meta name="theme-color" content="#F5F5F5" />
|
||||
<link rel="icon" type="image/svg+xml" href="/media/_error/svgs/favicon.svg" />
|
||||
<link rel="icon" type="image/png" href="/media/_error/img/favicon.png" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/media/_error/img/favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<div style="width:100%;height:80%;display:table;position:absolute;top:0;left:0;">
|
||||
<div style="display:table-cell;text-align:center;vertical-align:middle;">
|
||||
<div style="display:inline-block;">
|
||||
<img src="/media/_error/svgs/xxx-error.svg" alt="cadpoint.ru - http 503 error" style="width: 80vw;" />
|
||||
<pre>сервис временно недоступен.
|
||||
Скоро всё должно заработать снова — просто подождите немного.</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
33
cadpoint/templates/504.html
Normal file
33
cadpoint/templates/504.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="content-language" content="ru" />
|
||||
<meta name="generator" content="Microsoft FrontPage 1.0" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.4" />
|
||||
<meta name="description" content="cadpoint.ru — сервер отвечает слишком долго, попробуйте снова чуть позже" />
|
||||
<meta name="keywords" content="cadpoint.ru — сервер отвечает слишком долго" />
|
||||
<meta name="copyright" lang="ru" content="Sergei Erjemin" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<meta name="document-state" content="Static" />
|
||||
<meta name="generator" content="handcraft" />
|
||||
<title>CADpoint.ru - http 504 error</title>
|
||||
<meta name="theme-color" content="#F5F5F5" />
|
||||
<link rel="icon" type="image/svg+xml" href="/media/_error/svgs/favicon.svg" />
|
||||
<link rel="icon" type="image/png" href="/media/_error/img/favicon.png" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/media/_error/img/favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<div style="width:100%;height:80%;display:table;position:absolute;top:0;left:0;">
|
||||
<div style="display:table-cell;text-align:center;vertical-align:middle;">
|
||||
<div style="display:inline-block;">
|
||||
<img src="/media/_error/svgs/xxx-error.svg" alt="cadpoint.ru - http 504 error" style="width: 80vw;" />
|
||||
<pre>сервер отвечает слишком долго.
|
||||
Подождите немного и попробуйте снова.</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="description" content="{% block Description %}CADpoint — новости о 3D-печати и САПР{% endblock %}" />
|
||||
<meta name="keywords" content="{% block Keywords %}cadpoint, 3D-печать, САПР, новости{% endblock %}" />
|
||||
<meta name="copyright" lang="ru" content="Sergei Erjemin{% block CopyrightAuthor4Meta %}{% endblock %}." />
|
||||
<meta name="robots" content="index,follow" />
|
||||
<meta name="robots" content="{% block robots %}index,follow{% endblock %}" />
|
||||
<meta name="format-detection" content="telephone=no" />
|
||||
<title>{% block page_title %}CADPOINT.RU{% endblock %}</title>
|
||||
<meta name="meta-title" content="{% block meta_title %}CADPOINT.RU{% endblock %}" />
|
||||
|
||||
@@ -13,7 +13,12 @@ from web.legacy_links import build_canonical_url, replace_legacy_links
|
||||
from web.models import TbContent
|
||||
|
||||
|
||||
# Этот файл смешивает два типа проверок:
|
||||
# - простые тесты чистой логики без базы данных (`SimpleTestCase`),
|
||||
# - интеграционные Django-тесты с базой и HTTP-клиентом (`TestCase`).
|
||||
class LegacyLinksTests(SimpleTestCase):
|
||||
# `SimpleTestCase` подходит для функций, которые не ходят в базу и не
|
||||
# требуют полноценного HTTP-запроса: здесь мы просто проверяем строки.
|
||||
def test_build_canonical_url_without_slug(self):
|
||||
self.assertEqual(build_canonical_url(123, ''), '/item/123-')
|
||||
|
||||
@@ -42,6 +47,7 @@ class LegacyLinksTests(SimpleTestCase):
|
||||
self.assertEqual(len(matches), 1)
|
||||
|
||||
|
||||
# Эти тесты тоже без базы: проверяем очистку HTML и подготовку slug'ов.
|
||||
class SafeHtmlSpecialSymbolsTests(SimpleTestCase):
|
||||
def test_strips_html_tags_and_decodes_entities(self):
|
||||
text = '<p>«Привет <b>мир</b>» ­<script>alert(1)</script><style>p{}</style></p>'
|
||||
@@ -54,6 +60,7 @@ class SafeHtmlSpecialSymbolsTests(SimpleTestCase):
|
||||
self.assertEqual(clean_text_to_slug('₽ € $ ₴ ₿'), 'content')
|
||||
|
||||
|
||||
# Здесь проверяем форму админки: её поля, виджеты и виртуальные настройки.
|
||||
class AdminTypographFormTests(SimpleTestCase):
|
||||
def test_admin_form_exposes_virtual_typograph_fields(self):
|
||||
form = AdminContentForm()
|
||||
@@ -100,7 +107,11 @@ class AdminTypographFormTests(SimpleTestCase):
|
||||
self.assertEqual(str(item), '007: «Привет мир»')
|
||||
|
||||
|
||||
# В этих тестах уже нужна база и `client`, потому что мы проверяем Django-views
|
||||
# и JSON-ответы как реальные запросы из браузера.
|
||||
class TagAutocompleteTests(TestCase):
|
||||
# `TestCase` поднимает тестовую БД, а `client` умеет делать полноценные запросы
|
||||
# к Django, как будто их отправил браузер.
|
||||
def setUp(self):
|
||||
user_model = get_user_model()
|
||||
self.user = user_model.objects.create_superuser(
|
||||
@@ -150,6 +161,7 @@ class TagAutocompleteTests(TestCase):
|
||||
self.assertEqual(payload['pagination']['more'], False)
|
||||
|
||||
|
||||
# Страница со всеми тегами — тоже обычный Django-response, поэтому тут `TestCase`.
|
||||
class AllTagsPageTests(TestCase):
|
||||
def setUp(self):
|
||||
user_model = get_user_model()
|
||||
@@ -207,6 +219,7 @@ class AllTagsPageTests(TestCase):
|
||||
self.assertNotContains(response, 'onclick="CookieAcceptDate')
|
||||
|
||||
|
||||
# Здесь проверяем поведение страницы тега, включая пустое состояние.
|
||||
class TagEmptyStateTests(TestCase):
|
||||
def setUp(self):
|
||||
self.item = TbContent.objects.create(
|
||||
@@ -242,6 +255,7 @@ class TagEmptyStateTests(TestCase):
|
||||
self.assertContains(response, 'не найден или был переименован')
|
||||
|
||||
|
||||
# Тут мы проверяем модель и `save()`: slug, типограф, счётчик просмотров и SEO-поля.
|
||||
class TypographTests(TestCase):
|
||||
def test_save_generates_slug_from_clean_text(self):
|
||||
item = TbContent(szContentHead='<b>Привет мир</b>')
|
||||
@@ -410,6 +424,7 @@ class TypographTests(TestCase):
|
||||
self.assertNotContains(response, 'None')
|
||||
|
||||
|
||||
# Это тесты карты сайта: проверяем, что в XML попадают только публичные страницы.
|
||||
class SitemapTests(TestCase):
|
||||
def setUp(self):
|
||||
self.published = TbContent.objects.create(
|
||||
@@ -444,6 +459,8 @@ class SitemapTests(TestCase):
|
||||
self.assertNotContains(response, 'skrytaya-statya')
|
||||
|
||||
|
||||
# Для error-handlers удобно использовать `RequestFactory`: мы сами создаём
|
||||
# request и вызываем функцию-обработчик напрямую, без прохода через URL-роутинг.
|
||||
class ErrorHandlersTests(SimpleTestCase):
|
||||
def setUp(self):
|
||||
self.factory = RequestFactory()
|
||||
@@ -469,7 +486,7 @@ class ErrorHandlersTests(SimpleTestCase):
|
||||
self.assertEqual(response.status_code, 403)
|
||||
self.assertContains(response, 'CADpoint.ru - http 403 error', status_code=403)
|
||||
self.assertContains(response, '<meta name="robots" content="noindex,nofollow" />', status_code=403)
|
||||
self.assertContains(response, 'доступ к этой странице ограничен.', status_code=403)
|
||||
self.assertContains(response, 'доступ к этой странице ограничен.', status_code=403)
|
||||
|
||||
def test_handler404_renders_modern_template(self):
|
||||
response = self.client.get('/no-such-page/')
|
||||
@@ -477,7 +494,7 @@ class ErrorHandlersTests(SimpleTestCase):
|
||||
self.assertEqual(response.status_code, 404)
|
||||
self.assertContains(response, 'CADpoint.ru - http 404 error', status_code=404)
|
||||
self.assertContains(response, '<meta name="robots" content="noindex,nofollow" />', status_code=404)
|
||||
self.assertContains(response, 'похоже, такой страницы больше нет.', status_code=404)
|
||||
self.assertContains(response, 'похоже, такой страницы или картинки больше нет.', status_code=404)
|
||||
|
||||
def test_handler500_renders_modern_template(self):
|
||||
from web.views import handler500
|
||||
|
||||
@@ -26,6 +26,30 @@ def handler404(request, exception: str):
|
||||
return response
|
||||
|
||||
|
||||
def handler400(request, exception: Exception):
|
||||
""" Обработчик ошибки 400
|
||||
|
||||
:param request:
|
||||
:param exception:
|
||||
:return: response:
|
||||
"""
|
||||
response = render(request, "400.html", {"MSG": exception})
|
||||
response.status_code = 400
|
||||
return response
|
||||
|
||||
|
||||
def handler403(request, exception: Exception):
|
||||
""" Обработчик ошибки 403
|
||||
|
||||
:param request:
|
||||
:param exception:
|
||||
:return: response:
|
||||
"""
|
||||
response = render(request, "403.html", {"MSG": exception})
|
||||
response.status_code = 403
|
||||
return response
|
||||
|
||||
|
||||
def handler500(request):
|
||||
""" Обработчик ошибки 500
|
||||
|
||||
|
||||
18
public/static/README.md
Normal file
18
public/static/README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# СТАТИКА
|
||||
|
||||
Эта папка предназначена для хранения статических файлов, таких как изображения, стили CSS и JavaScript файлы.
|
||||
Папка будет внутри контейнера, а файлы внутри папки будут доступны с помощью gunicorn и whitenoise на хосте.
|
||||
|
||||
Но в случае сбоя контейнера, ошибок Djанго и ошибок 404 при доступе в media (которые будут в папке `media` на
|
||||
внешнем хосте с доступом через nginx), то эти файлы могут стать недоступны. Таким образом, файлы необхдимые
|
||||
для отображения кастовых страниц ошибок 400, 403, 404, 500 и других должны быть скопированы на внешний хост,
|
||||
в папку `media/_error` в момент запуска контейнера (с помощью `entrypoint.sh` или инструкций `command`
|
||||
в `docker-compose.yml`)
|
||||
|
||||
. Вот список этих файлов (путь указан относительно папки `static`):
|
||||
* svgs/favicon.svg
|
||||
* img/favicon.png
|
||||
* img/favicon.ico
|
||||
* svgs/xxx-error.svg
|
||||
* svgs/404-error.svg
|
||||
* svgs/500-error.svg
|
||||
1
public/static/svgs/xxx-error.svg
Normal file
1
public/static/svgs/xxx-error.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 15 KiB |
Reference in New Issue
Block a user