diff --git a/ServicesApp/funcs.py b/ServicesApp/funcs.py index 7a3ba9c..019b6e0 100644 --- a/ServicesApp/funcs.py +++ b/ServicesApp/funcs.py @@ -3,4 +3,21 @@ from .models import * def get_sections(): sections = Section.objects.filter(enable=True).order_by('order') - return sections \ No newline at end of file + return sections + +def get_section_views_Dict(section): + + services = section.rel_services_for_section.filter(enable=True).order_by('order') + services_view_scheme = '2_cols_wo_group' + for service in services: + if service.rel_children_for_service.filter(enable=True): + services_view_scheme = '3_cols_w_group' + break + + Dict = { + 'sections': get_sections(), + 'services': services, + 'services_view_scheme': services_view_scheme, + } + + return Dict \ No newline at end of file diff --git a/ServicesApp/js_views.py b/ServicesApp/js_views.py index d7caecd..1b8952b 100644 --- a/ServicesApp/js_views.py +++ b/ServicesApp/js_views.py @@ -38,9 +38,7 @@ def get_content_for_section_ajax(request): section = Section.objects.get(url=data['section_url']) - services = section.rel_services_for_section.filter(enable=True).order_by('order') - from .funcs import get_sections # one_list_childs = { # 'name' : 'вгд' @@ -54,11 +52,13 @@ def get_content_for_section_ajax(request): # Dict = { 'cur_section': section, - 'sections': get_sections(), - 'services': services, - + # 'sections': get_sections(), + # 'services': services, } + from .funcs import get_section_views_Dict + Dict.update(get_section_views_Dict(section)) + html = render_to_string('pages/content/c_blocks_constructor.html', Dict, request=request) res_Dict = { diff --git a/ServicesApp/views.py b/ServicesApp/views.py index 0aebb36..49cf574 100644 --- a/ServicesApp/views.py +++ b/ServicesApp/views.py @@ -15,20 +15,16 @@ def section_view(request, url): # from ArticlesApp.models import ArticleModel # arts = ArticleModel.objects.filter(enable=True).order_by('-createDT')[:4] - services = section.rel_services_for_section.filter(enable=True).order_by('order') - services_view_scheme = '2_cols_wo_group' - for service in services: - if service.rel_children_for_service.filter(enable=True): - services_view_scheme = '3_cols_w_group' - break + Dict = { 'page': section, - 'services': services, - 'services_view_scheme': services_view_scheme # 'articles': arts, } + from .funcs import get_section_views_Dict + Dict.update(get_section_views_Dict(section)) + # breadcrumbs_Dict = { # } # Dict.update({'breadcrumbs': breadcrumbs_Dict})