def home_page(request): c = get_common_context(request) c['request_url'] = 'home' c['slideshow'] = Slider.objects.all() c['content'] = Page.get_by_slug('home')['content'] c['n'] = Article.recent_some(1)[0] return render_to_response('home.html', c, context_instance=RequestContext(request))
def news_page(request, page_name=None): c = get_common_context(request) if (request.method == 'GET') or not request.POST.get('search_value', None): try: if page_name: c['recent'] = Article.get_by_slug(page_name) else: c['recent'] = Article.recent_some(1)[0] c['news'] = Article.recent_some(1000) return render_to_response('news.html', c, context_instance=RequestContext(request)) except: raise Http404('page %s not found' % page_name) else: # POST c['search_value'] = request.POST['search_value'] c['news'] = Article.find(c['search_value']) if len(c['news']) > 0: c['recent'] = c['news'][0] else: c['not_found'] = True return render_to_response('news.html', c, context_instance=RequestContext(request))