84 lines
2.0 KiB
Python
84 lines
2.0 KiB
Python
import json
|
|
|
|
from django.http import HttpResponse, Http404, FileResponse
|
|
from django.template import loader, RequestContext
|
|
from django.contrib.auth.decorators import login_required
|
|
from .models import *
|
|
from django.conf import settings
|
|
from .funcs import get_inter_http_respose
|
|
|
|
def test_code(request):
|
|
|
|
|
|
return HttpResponse('finished')
|
|
|
|
|
|
def MainPage(request):
|
|
|
|
# print(f'LOCALE_PATHS = {str(settings.LOCALE_PATHS)}')
|
|
|
|
page = StaticPage.objects.get(url='main')
|
|
|
|
# from ArticlesApp.models import ArticleModel
|
|
# arts = ArticleModel.objects.filter(enable=True).order_by('-createDT')[:4]
|
|
|
|
Dict = {
|
|
'page': page,
|
|
# 'articles': arts,
|
|
}
|
|
|
|
# breadcrumbs_Dict = {
|
|
# }
|
|
# Dict.update({'breadcrumbs': breadcrumbs_Dict})
|
|
|
|
t = loader.get_template('pages/p_main.html')
|
|
return get_inter_http_respose(t, Dict, request)
|
|
# return HttpResponse(t.render(Dict, request))
|
|
|
|
|
|
|
|
def StaticPageView(request, url):
|
|
# from RoutesApp.forms import RouteForm
|
|
# from SubscribesApp.funcs import get_subsribes_w_options
|
|
|
|
Dict = {}
|
|
|
|
if url == '':
|
|
return MainPage(request)
|
|
elif url == 'for_movers':
|
|
Dict.update({
|
|
# 'route_form': RouteForm(),
|
|
'owner_type': 'customer',
|
|
})
|
|
elif url == 'for_customers':
|
|
Dict.update({
|
|
# 'route_form': RouteForm(),
|
|
'owner_type': 'mover'
|
|
})
|
|
# elif url == 'works':
|
|
# return WorksPage(request)
|
|
elif url in ['main']:
|
|
raise Http404
|
|
|
|
# if url in ['for_movers', 'for_customers']:
|
|
# subscribes, all_options = get_subsribes_w_options()
|
|
# Dict.update({
|
|
# 'subscribes': subscribes,
|
|
# })
|
|
|
|
try:
|
|
page = StaticPage.objects.get(url=url)
|
|
except StaticPage.DoesNotExist:
|
|
raise Http404
|
|
|
|
|
|
Dict.update({
|
|
'page': page,
|
|
})
|
|
|
|
t = loader.get_template('pages/p_static_page.html')
|
|
return get_inter_http_respose(t, Dict, request)
|
|
# return HttpResponse(t.render(Dict, request))
|
|
|
|
|