0.0.8 Services
This commit is contained in:
@@ -44,6 +44,8 @@ class Admin_Section(SuperModelAdmin, Admin_Trans_BaseModelViewPage):
|
||||
'order', 'modifiedDT', 'createDT'
|
||||
]
|
||||
|
||||
prepopulated_fields = {"url": ("name_en",)}
|
||||
|
||||
list_display_links = ['id']
|
||||
list_editable = ['order']
|
||||
|
||||
@@ -64,3 +66,51 @@ admin.site.register(Section,Admin_Section)
|
||||
|
||||
|
||||
|
||||
class Admin_Service(SuperModelAdmin, Admin_Trans_BaseModelViewPage):
|
||||
|
||||
|
||||
fieldsets = [
|
||||
(None, {
|
||||
'classes': ['wide'],
|
||||
'fields': ('name',
|
||||
'url',
|
||||
'title', 'description', 'text',
|
||||
'picture',
|
||||
'order',
|
||||
)
|
||||
}),
|
||||
('SEO', {
|
||||
'classes': ['wide', 'collapse'],
|
||||
'fields': (
|
||||
'seo_title', 'seo_description', 'seo_keywords', 'seo_text',
|
||||
)
|
||||
}),
|
||||
]
|
||||
|
||||
|
||||
list_display = [
|
||||
'id',
|
||||
'name', 'url', 'title',
|
||||
'order', 'modifiedDT', 'createDT'
|
||||
]
|
||||
|
||||
prepopulated_fields = {"url": ("name",)}
|
||||
|
||||
list_display_links = ['id']
|
||||
list_editable = ['order']
|
||||
|
||||
list_filter = ['modifiedDT', 'createDT']
|
||||
search_fields = ['name', 'title']
|
||||
# filter_horizontal = ['options']
|
||||
|
||||
inlines = [Admin_StackedInline_Block]
|
||||
|
||||
def has_delete_permission(self, request, obj=None):
|
||||
if request.user.is_superuser:
|
||||
return True
|
||||
|
||||
if obj.url in ('main', 'spec_technics', 'works'):
|
||||
return False
|
||||
|
||||
admin.site.register(Service, Admin_Service)
|
||||
|
||||
|
||||
@@ -2,5 +2,5 @@ from .models import *
|
||||
|
||||
def get_sections():
|
||||
|
||||
sections = Section.objects.filter(enable=True)
|
||||
sections = Section.objects.filter(enable=True).order_by('order')
|
||||
return sections
|
||||
@@ -5,7 +5,7 @@ from django.conf import settings
|
||||
from .js_views import *
|
||||
|
||||
urlpatterns = [
|
||||
path('get_content_for_section', get_content_for_section_ajax, name='main'),
|
||||
path('get_content_for_section', get_content_for_section_ajax, name='get_content_for_section_ajax'),
|
||||
# path('page/<str:url>/', StaticPageView, name='static_page'),
|
||||
# path('test_code', test_code, name='test_code'),
|
||||
]
|
||||
@@ -16,6 +16,7 @@ from django.urls import reverse
|
||||
from .funcs import *
|
||||
|
||||
def get_content_for_section_ajax(request):
|
||||
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
@@ -26,6 +27,9 @@ def get_content_for_section_ajax(request):
|
||||
if not data and request.body:
|
||||
data = json.loads(request.body)
|
||||
|
||||
if 'screen_width' in data and data['screen_width']:
|
||||
request.session['screen_width'] = data['screen_width']
|
||||
|
||||
if not 'section_url' in data or not data['section_url']:
|
||||
msg = _("Не найден section_url в data")
|
||||
err_Dict = {
|
||||
@@ -35,22 +39,21 @@ def get_content_for_section_ajax(request):
|
||||
|
||||
section = Section.objects.get(url=data['section_url'])
|
||||
|
||||
Dict = {
|
||||
'section': section
|
||||
}
|
||||
|
||||
html = render_to_string('blocks/b_search_routes.html', routes_Dict, request=request)
|
||||
html = render_to_string('pages/content/c_projectiing_section.html', Dict, request=request)
|
||||
|
||||
res_Dict = {
|
||||
'html': html,
|
||||
'last_block': routes_Dict['last_block']
|
||||
# 'form': RouteForm(initial=data)
|
||||
}
|
||||
|
||||
return JsonResponse(res_Dict)
|
||||
|
||||
except Exception as e:
|
||||
|
||||
msg = f' get_content_for_section_ajax ошибка в запросе = {str(e)}'
|
||||
errors_Dict = {
|
||||
'errors': {
|
||||
'all__': f'ошибка в запросе = {str(e)}'
|
||||
}
|
||||
'errors': msg
|
||||
}
|
||||
return JsonResponse(errors_Dict, status=400)
|
||||
|
||||
10
templates/pages/content/c_projectiing_section.html
Normal file
10
templates/pages/content/c_projectiing_section.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user