def get_content(request, template_name='sfmayor2011/sfmayor_content_items.html'): context = {} content = (Content.published_objects.filter(primary_topic__slug='sf-mayoral-race', publication_status='P').order_by('-pub_date').exclude( Q(classname='videos.video') | Q(classname='images.image') | Q(classname='images.gallery')))[5:] pages, current_page = paginate_list(request, content) context['pages'] = pages context['current_page'] = current_page context['content'] = current_page.object_list context['cssname'] = 'stories-Story' return render_to_response(template_name, context, context_instance=RequestContext(request))
def get_content_candidates(request, slug, template_name='sfmayor2011/sfmayor_content_items.html'): try: context = {} candidate = get_object_or_404(Candidate, entity__full_name__slug=slug) related_content = Content.objects.filter((Q(content_type__name='story')|\ Q(content_type__name='post')), body__contains=candidate.entity.full_name.name,\ publication_status='P').order_by('-pub_date') pages, current_page = paginate_list(request, related_content) context['pages'] = pages context['current_page'] = current_page context['content'] = current_page.object_list context['cssname'] = 'stories-Story' except Exception as e: print e logger.error('sfmayor2011.get_content_candidates e=%s' % e) return render_to_response(template_name, context, context_instance=RequestContext(request))
def index(request, template_name='sfmayor2011/sfmayor_index.html'): context = {} context['candidates'] = Candidate.objects.all().exclude(Q(bio='')|Q(bio=None)|Q(bio='test bio zzzz')).order_by('entity__full_name__name') context['stories'] = (Content.published_objects.filter( primary_topic__slug='sf-mayoral-race', publication_status='P').order_by('-pub_date').exclude( Q(classname='videos.video') | Q(classname='images.image') | Q(classname='images.gallery')))[0:5] content = (Content.published_objects.filter( primary_topic__slug='sf-mayoral-race', publication_status='P').order_by('-pub_date').exclude( Q(classname='videos.video') | Q(classname='images.image') | Q(classname='images.gallery')))[5:] pages, current_page = paginate_list(request, content) context['pages'] = pages context['current_page'] = current_page context['content'] = current_page.object_list context['cssname'] = 'stories-Story' return render_to_response(template_name, context, context_instance=RequestContext(request))
def candidate(request, slug, template_name='sfmayor2011/sfmayor_candidate.html'): context = {} candidate = get_object_or_404(Candidate, entity__full_name__slug=slug) candidates = get_candidates_w_bios() if candidate not in candidates: raise Http404 context['candidate'] = candidate context['candidates'] = candidates #want to be a little looser with the stories displayed on candidate pages #so there is some content related_content = Content.objects.filter((Q(content_type__name='story')|\ Q(content_type__name='post')), body__contains=candidate.entity.full_name.name,\ publication_status='P').order_by('-pub_date') pages, current_page = paginate_list(request, related_content) context['pages'] = pages context['current_page'] = current_page context['content'] = current_page.object_list context['cssname'] = 'stories-Story' return render_to_response(template_name, context, context_instance=RequestContext(request))