0.9.0 404 prepare
This commit is contained in:
@@ -112,6 +112,20 @@ class BaseModelViewPage(BaseModel):
|
|||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
|
def get_title(self):
|
||||||
|
if self.seo_title:
|
||||||
|
return self.seo_title
|
||||||
|
elif self.title:
|
||||||
|
return self.title
|
||||||
|
else:
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
def get_description(self):
|
||||||
|
if self.seo_description:
|
||||||
|
return self.seo_description
|
||||||
|
else:
|
||||||
|
return self.description
|
||||||
|
|
||||||
def get_FAQ_items(self):
|
def get_FAQ_items(self):
|
||||||
return self.FAQ_items.filter(enable=True).order_by('order')
|
return self.FAQ_items.filter(enable=True).order_by('order')
|
||||||
|
|
||||||
|
|||||||
@@ -6,33 +6,64 @@ from django.contrib.auth.decorators import login_required
|
|||||||
from .models import *
|
from .models import *
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from .funcs import get_inter_http_respose
|
from .funcs import get_inter_http_respose
|
||||||
|
from django.http.response import JsonResponse, HttpResponse
|
||||||
|
from django.views.decorators.http import require_GET, require_POST
|
||||||
|
from django.shortcuts import get_object_or_404
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
from webpush import send_user_notification
|
||||||
|
import json
|
||||||
|
|
||||||
def test_code(request):
|
def test_code(request):
|
||||||
from RoutesApp.funcs import get_city_by_type_transport_and_address_point
|
from RoutesApp.funcs import get_city_by_type_transport_and_address_point
|
||||||
from RoutesApp.models import Route
|
from RoutesApp.models import Route
|
||||||
from ReferenceDataApp.models import Airport, City
|
from ReferenceDataApp.models import Airport, City
|
||||||
|
|
||||||
routes = Route.objects.all()
|
try:
|
||||||
|
# body = request.body
|
||||||
|
# data = json.loads(body)
|
||||||
|
# if 'head' not in data or 'body' not in data or 'id' not in data:
|
||||||
|
# return JsonResponse(status=400, data={"message": "Invalid data format"})
|
||||||
|
# user_id = data['id']
|
||||||
|
user = request.user
|
||||||
|
payload = {'head': '123', 'body': 'qwerty'}
|
||||||
|
send_user_notification(user=user, payload=payload, ttl=1000)
|
||||||
|
return JsonResponse(status=200, data={"message": "Web push successful"})
|
||||||
|
except TypeError:
|
||||||
|
return JsonResponse(status=500, data={"message": "An error occurred"})
|
||||||
|
|
||||||
for route in routes:
|
# routes = Route.objects.all()
|
||||||
print(route.id)
|
#
|
||||||
required_save = False
|
# for route in routes:
|
||||||
if not route.from_city:
|
# print(route.id)
|
||||||
route.from_city = get_city_by_type_transport_and_address_point(route.type_transport, route.from_address_point)
|
# required_save = False
|
||||||
required_save = True
|
# if not route.from_city:
|
||||||
|
# route.from_city = get_city_by_type_transport_and_address_point(route.type_transport, route.from_address_point)
|
||||||
|
# required_save = True
|
||||||
|
#
|
||||||
|
# if not route.to_city:
|
||||||
|
# route.to_city = get_city_by_type_transport_and_address_point(route.type_transport,
|
||||||
|
# route.to_address_point)
|
||||||
|
# required_save = True
|
||||||
|
#
|
||||||
|
# if required_save:
|
||||||
|
# route.save()
|
||||||
|
|
||||||
if not route.to_city:
|
# return HttpResponse('finished')
|
||||||
route.to_city = get_city_by_type_transport_and_address_point(route.type_transport,
|
|
||||||
route.to_address_point)
|
|
||||||
required_save = True
|
|
||||||
|
|
||||||
if required_save:
|
|
||||||
route.save()
|
|
||||||
|
|
||||||
return HttpResponse('finished')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def Page404(request, exeption=None):
|
||||||
|
|
||||||
|
Dict = {}
|
||||||
|
|
||||||
|
t = loader.get_template('404.html')
|
||||||
|
try:
|
||||||
|
res = get_inter_http_respose(t, Dict, request)
|
||||||
|
return HttpResponse(res, status=404)
|
||||||
|
except Exception as e:
|
||||||
|
return HttpResponse(str(e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,17 @@ from django.contrib import admin
|
|||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
from django.conf.urls.static import static
|
from django.conf.urls.static import static
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from GeneralApp.views import Page404
|
||||||
|
|
||||||
|
handler404 = Page404
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# path('admin/', admin.site.urls),
|
# path('admin/', admin.site.urls),
|
||||||
path('ckeditor/', include('ckeditor_uploader.urls')),
|
path('ckeditor/', include('ckeditor_uploader.urls')),
|
||||||
path('i18n/', include('django.conf.urls.i18n')),
|
path('i18n/', include('django.conf.urls.i18n')),
|
||||||
|
|
||||||
|
# path('webpush/', include('webpush.urls')),
|
||||||
|
|
||||||
path('messages/', include('ChatServiceApp.urls')),
|
path('messages/', include('ChatServiceApp.urls')),
|
||||||
|
|
||||||
path('user_account/', include('AuthApp.js_urls')),
|
path('user_account/', include('AuthApp.js_urls')),
|
||||||
@@ -22,6 +27,8 @@ urlpatterns = [
|
|||||||
path('reference_data/', include('ReferenceDataApp.js_urls')),
|
path('reference_data/', include('ReferenceDataApp.js_urls')),
|
||||||
|
|
||||||
path('', include('ArticlesApp.js_urls')),
|
path('', include('ArticlesApp.js_urls')),
|
||||||
|
|
||||||
|
path('test_404', Page404, name='page_404'),
|
||||||
]
|
]
|
||||||
|
|
||||||
from django.conf.urls.i18n import i18n_patterns
|
from django.conf.urls.i18n import i18n_patterns
|
||||||
|
|||||||
8
templates/404.html
Normal file
8
templates/404.html
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{% extends "tb_base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
404
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -13,7 +13,17 @@
|
|||||||
{# <h1>Техническая поддержка</h1>#}
|
{# <h1>Техническая поддержка</h1>#}
|
||||||
{# </div>#}
|
{# </div>#}
|
||||||
{% if user.is_staff or staff %}
|
{% if user.is_staff or staff %}
|
||||||
<div class="menu_buttons curtain left {% if mobile %}{% if not ticket %}open{% else %}close{% endif %}{% else %}open{% endif %}{% if name.ticket %}margin{% endif %}" data-name="<img style='width: 25px;display: block;position: relative;bottom: 0;' src='{% static "/img/svg/users-solid.svg" %}'>">
|
<div class="menu_buttons curtain left
|
||||||
|
{% if mobile %}
|
||||||
|
{% if not ticket %}open
|
||||||
|
{% else %}close
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
open
|
||||||
|
{% endif %}
|
||||||
|
{% if name.ticket %}margin{% endif %}"
|
||||||
|
data-name="<img style='width: 25px;display: block;position: relative;bottom: 0;' src='{% static "/img/svg/users-solid.svg" %}'>"
|
||||||
|
>
|
||||||
<div class="container_block_list_of_users">
|
<div class="container_block_list_of_users">
|
||||||
{% include 'blocks/profile/b_list_of_tickets_support_chat.html' %}
|
{% include 'blocks/profile/b_list_of_tickets_support_chat.html' %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,19 +1,11 @@
|
|||||||
{% if page.seo_title %}
|
<title>{{ page.get_title }}</title>
|
||||||
<title>{{ page.seo_title }}</title>
|
|
||||||
{% elif page.title %}
|
|
||||||
<title>{{ page.title }}</title>
|
|
||||||
{% elif page.name %}
|
|
||||||
<title>{{ page.name }}</title>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if page.seo_description %}
|
{% if page.get_description %}
|
||||||
<meta name="description" content="{{ page.seo_description }}"/>
|
<meta name="description" content="{{ page.get_description }}"/>
|
||||||
{% elif page.description %}
|
|
||||||
<meta name="description" content="{{ page.description }}"/>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if page.seo_keywords %}
|
{% if page.seo_keywords %}
|
||||||
<meta name="keywords" content="{{ page.seo_keywords }}"/>
|
<meta name="keywords" content="{{ page.seo_keywords }}"/>
|
||||||
{% elif page.description %}
|
{% elif page.get_description %}
|
||||||
<meta name="keywords" content="{{ page.description }}"/>
|
<meta name="keywords" content="{{ page.get_description }}"/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
Reference in New Issue
Block a user