def home(request): c = get_common_context(request) c['request_url'] = 'home' c['recent_news'] = Article.get_list(c['lang'])[:6] c['recent_photos'] = Photo.objects.all()[:3] c['home_top'] = Page.get('home_top', c['lang'])['content'] c['home_history'] = Page.get('home_history', c['lang'])['content'] return render_to_response('home.html', c, context_instance=RequestContext(request))
def get_common_context(request): c = {} c['lang'] = request.LANGUAGE_CODE c['request_url'] = request.path c['is_debug'] = settings.DEBUG c['recent_news'] = Article.get_list(c['lang'])[:2] c['recent_projects'] = Project.objects.all()[:3] c['recent_comments'] = ProjectComment.objects.all()[:3] c['ime_expert'] = Expert.exist(request.user) c['ime_participant'] = Participant.exist(request.user) c['auth'] = request.user.is_authenticated() c.update(csrf(request)) return c
def news(request): c = get_common_context(request) items = Article.get_list(c['lang']) paginator = Paginator(items, PAGINATION_COUNT) page = int(request.GET.get('page', '1')) try: items = paginator.page(page) except PageNotAnInteger: page = 1 items = paginator.page(page) except EmptyPage: page = paginator.num_pages items = paginator.page(page) c['page'] = page c['page_range'] = paginator.page_range if len(c['page_range']) > 1: c['need_pagination'] = True c['items'] = items return render_to_response('news.html', c, context_instance=RequestContext(request))
def news(request): c = get_common_context(request) c['list'] = Article.get_list(c['lang']) return render_to_response('news.html', c, context_instance=RequestContext(request))