コード例 #1
0
    def get(self, request, *args, **kwargs):
        page = Page.objects.get(slug=kwargs['slug'])
        page_images = PageImage.objects.filter(page=page)
        html = page.html.format(
            block_directions_p=Blocks.block_directions_p(),
            block_directions_table=Blocks.block_directions_table(),
            block_staff_table_deanery=Blocks.block_staff_table(
                [Staff.Category.DEANERY]),
            block_staff_table_council=Blocks.block_staff_table(
                [Staff.Category.COUNCIL]),
            **{
                'image_url_%s' % (page_image.slug): page_image.image.url
                for page_image in page_images
            })

        context = {}
        context['header'] = page.name
        context['breadcrumbs'] = page.menu.get_breadcrumbs_dict()
        context['sitename'] = Setting.get('sitename')
        context['theme'] = css_theme(request)
        context['menus'] = Menu.get_dict()
        context['page'] = page
        context['html'] = html

        if page.is_sidebar:
            context['sidebar'] = {
                'header': page.sidebar_name if page.sidebar_name else None,
                'objects': page.menu.childs
            }
        return render(request, self.template_name, context)
コード例 #2
0
    def get(self, request, *args, **kwargs):
        context = {}
        menu = Menu.objects.filter(kind=Menu.Kind.NEWS_LIST).first()
        page = kwargs['page'] if 'page' in kwargs else 1
        on_page = Setting.get('on_page')
        context['header'] = 'Новости'
        context['sitename'] = Setting.get('sitename')
        context['theme'] = css_theme(request)
        context['breadcrumbs'] = menu.get_breadcrumbs_dict()
        context['menus'] = Menu.get_dict()
        context['news'] = News.objects.filter().order_by(
            '-datetime')[(page - 1) * on_page:page * on_page]

        news_count = News.objects.all().count()
        pages_count = news_count // on_page + 1

        context['pager'] = {
            'prev': (page - 1) if page != 1 else None,
            'next': (page + 1) if page != pages_count else None,
            'page': page,
            'pages': list(range(1, pages_count + 1))
        }
        print(context['pager'])

        return render(request, self.template_name, context)
コード例 #3
0
    def get(self, request, *args, **kwargs):
        translation.activate('ru')

        context = {}
        groups = ScheduleGroup.objects.all()
        context['groups'] = groups
        menu = Menu.objects.filter(kind=Menu.Kind.SCHEDULE).first()
        if 'slug' not in kwargs:
            context['is_list'] = True
            context['header'] = 'Расписание'
            context['breadcrumbs'] = menu.get_breadcrumbs_dict()
        else:
            context['is_list'] = False
            group = ScheduleGroup.objects.get(slug=kwargs['slug'])

            context['header'] = 'Расписание ' + group.name
            context['breadcrumbs'] = group.get_breadcrumbs_dict(menu)
            context['group'] = group
            context['webpush'] = {'group': 'all'}
            context['schedule'] = group.get_schedule_dict()

        menu = Menu.objects.filter(kind=Menu.Kind.CATHEDRA_ITEM).first()

        context['sitename'] = Setting.get('sitename')
        context['theme'] = css_theme(request)
        context['menus'] = Menu.get_dict()
        return render(request, self.template_name, context)
コード例 #4
0
 def get(self, request):
     context = {}
     menu = Menu.objects.filter(kind=Menu.Kind.CATHEDRA_LIST).first()
     context['header'] = 'Кафедры'
     context['sitename'] = Setting.get('sitename')
     context['theme'] = css_theme(request)
     context['breadcrumbs'] = menu.get_breadcrumbs_dict()
     context['menus'] = Menu.get_dict()
     context['cathedras'] = Cathedra.objects.all()
     return render(request, self.template_name, context)
コード例 #5
0
    def _get_context(self, request, *args, **kwargs):
        context = {}
        context['header'] = 'Заказ справок'
        context['breadcrumbs'] = Menu.objects.filter(
            kind=Menu.Kind.CERTIFICATES).first().get_breadcrumbs_dict()
        context['sitename'] = Setting.get('sitename')
        context['theme'] = css_theme(request)
        context['menus'] = Menu.get_dict()

        return context
コード例 #6
0
 def get(self, request, *args, **kwargs):
     context = {}
     announcement = Announcement.objects.get(slug=kwargs['slug'])
     menu = Menu.objects.filter(kind=Menu.Kind.ANNOUNCEMENT_ITEM).first()
     context['header'] = announcement.name
     context['sitename'] = Setting.get('sitename')
     context['theme'] = css_theme(request)
     context['breadcrumbs'] = menu.get_breadcrumbs_dict()
     context['menus'] = Menu.get_dict()
     context['announcement'] = announcement
     return render(request, self.template_name, context)
コード例 #7
0
 def get(self, request, *args, **kwargs):
     context = {}
     news_item = News.objects.get(slug=kwargs['slug'])
     menu = Menu.objects.filter(kind=Menu.Kind.NEWS_ITEM).first()
     context['header'] = news_item.name
     context['sitename'] = Setting.get('sitename')
     context['theme'] = css_theme(request)
     context['breadcrumbs'] = menu.get_breadcrumbs_dict()
     context['menus'] = Menu.get_dict()
     context['news_item'] = news_item
     return render(request, self.template_name, context)
コード例 #8
0
 def get(self, request, *args, **kwargs):
     context = {}
     direction = Direction.objects.get(slug=kwargs['slug'])
     menu = Menu.objects.filter(kind=Menu.Kind.DIRECTION_ITEM).first()
     context['header'] = direction.name
     context['sitename'] = Setting.get('sitename')
     context['theme'] = css_theme(request)
     context['breadcrumbs'] = direction.get_breadcrumbs_dict(menu)
     context['menus'] = Menu.get_dict()
     context['direction'] = direction
     context['html'] = direction.html
     return render(request, self.template_name, context)
コード例 #9
0
 def get(self, request, *args, **kwargs):
     context = {}
     staff = Staff.objects.get(slug=kwargs['slug'])
     menu = Menu.objects.filter(kind=Menu.Kind.CATHEDRA_ITEM).first()
     context['header'] = staff.name
     context['sitename'] = Setting.get('sitename')
     context['theme'] = css_theme(request)
     context['breadcrumbs'] = staff.get_breadcrumbs_dict(menu)
     context['menus'] = Menu.get_dict()
     context['person'] = staff
     context['html'] = staff.html
     return render(request, self.template_name, context)
コード例 #10
0
ファイル: index.py プロジェクト: Dzyba/ineuiit
    def get(self, request):
        context = {}
        # page = Page.objects.get(slug='index')
        # context['header'] = page.name
        # context['breadcrumbs'] = page.menu.get_breadcrumbs_dict()
        # context['page'] = page

        context['sitename'] = Setting.get('sitename')
        context['theme'] = css_theme(request)
        context['menus'] = Menu.get_dict()
        context['slider'] = News.objects.filter(is_slider=True).order_by('-datetime')[:3]
        context['news'] = News.objects.filter().order_by('-datetime')[:3]
        announcements = Announcement.objects.all().order_by('-datetime')[:4]
        context['announcement'] = announcements[0]
        context['announcements'] = announcements[1:4]
        return render(request, self.template_name, context)