def get_common_context(request): c = {} c['request_url'] = request.path c['works_r'] = Work.get_recent(4) c['works_b'] = Work.get_best(4) c['articles_r'] = Article.get_recent(4) c['is_debug'] = settings.DEBUG c.update(csrf(request)) return c
def portfolio_page(request, curr_cat=None, curr_work=None): c = get_common_context(request) c['categories'] = Category.get_not_empty() c['curr_cat'] = Category.get_by_slug(curr_cat) if c['curr_cat'] is None: c['curr_cat'] = c['categories'][0] c['curr_work'] = Work.get_by_slug(curr_work) if c['curr_work'] is None: c['curr_work'] = Work.get_first_in_category(c['curr_cat']) return render_to_response('portfolio.html', c, context_instance=RequestContext(request))
def portfolio_page(request, curr_work=None): c = get_common_context(request) if curr_work: c['curr_work'] = Work.get_by_slug(curr_work) return render_to_response('portfolio_work.html', c, context_instance=RequestContext(request)) else: c['tags'] = WorkTag.get_work_tags() c['works'] = Work.objects.all() return render_to_response('portfolio.html', c, context_instance=RequestContext(request))
def work(request, work_slug): categs = Category.objects.all() work = Work.objects.get(slug=work_slug) work_categs = work.categ.all() work_cover = (Work.objects.filter(categ__in=work_categs, bck=True).order_by('?').first() or Work.objects.filter(bck=True).order_by('?').first()) try: prev_work = Work.get_previous_by_added(work) except Work.DoesNotExist: prev_work = None try: next_work = Work.get_next_by_added(work) except Work.DoesNotExist: next_work = None return render(request, "portfolio/work.html", locals())