def object_detail(request, category, content_type, slug, year=None, month=None, day=None, url_remainder=None): """ Renders a page for placement. All the data fetching and context creation is done in `_object_detail`. If `url_remainder` is specified, tries to locate custom view via `dispatcher`. Renders a template returned by `get_template` with context returned by `_object_detail`. :Parameters: - `request`: `HttpRequest` from Django - `category, content_type, slug, year, month, day`: parameters passed on to `_object_detail` - `url_remainder`: url after the object's url, used to locate custom views in `dispatcher` :Exceptions: - `Http404`: if the URL is not valid and/or doesn't correspond to any valid `Placement` """ context = _object_detail(request.user, category, content_type, slug, year, month, day) obj = context['object'] # check for custom actions if url_remainder: bits = url_remainder.split('/') return dispatcher.call_view(request, bits, context) elif dispatcher.has_custom_detail(obj): return dispatcher.call_custom_detail(request, context) return render_to_response( get_templates('object.html', slug, context['category'], context['content_type'].app_label, context['content_type'].model), context, context_instance=RequestContext(request) )
def render(self, request, context, template): return render_to_response( template, context, context_instance=RequestContext(request), content_type='application/xml' )
def category_detail(request, category): context = _category_detail(category) return render_to_response( ( 'page/category/%s/category.html' % (context["category"].path), 'page/category.html', ), context, context_instance=RequestContext(request) )
def home(request): """ Homepage of the actual site. :Parameters: - `request`: `HttpRequest` from Django :Exceptions: - `Http404`: if there is no base category """ context = _category_detail() return render_to_response( ( 'page/category/%s/category.html' % (context['category'].path), 'page/category.html', ), context, context_instance=RequestContext(request) )
def export(request, count, name='', content_type=None): """ Export banners. :Parameters: - `count`: number of objects to pass into the template - `name`: name of the template ( page/export/banner.html is default ) - `models`: list of Model classes to include """ t_list = [] if name: t_list.append('page/export/%s.html' % name) t_list.append('page/export/banner.html') cat = get_cached_object_or_404(Category, tree_parent__isnull=True, site__id=settings.SITE_ID) listing = Listing.objects.get_listing(count=count, category=cat) return render_to_response( t_list, { 'category' : cat, 'listing' : listing }, context_instance=RequestContext(request), content_type=content_type )
def list_content_type(request, category=None, year=None, month=None, day=None, content_type=None, paginate_by=20): # pagination if 'p' in request.GET and request.GET['p'].isdigit(): page_no = int(request.GET['p']) else: page_no = 1 context = _list_content_type(category, year, month, day, content_type, page_no, paginate_by) if content_type: ct = get_content_type(content_type) else: ct = False template_list = [] if ct: template_list.append('page/category/%s/content_type/%s.%s/listing.html' % (context["cat"].path, ct.app_label, ct.model)) template_list.append('page/category/%s/listing.html' % (context["cat"].path)) if ct: template_list.append('page/content_type/%s.%s/listing.html' % (ct.app_label, ct.model)) template_list.append('page/listing.html') return render_to_response( template_list, context, context_instance=RequestContext(request) )
def render(self, request, context, template): return render_to_response(template, context, context_instance=RequestContext(request))
def handle_error(request): response = render_to_response('page/500.html', {}, context_instance=RequestContext(request)) response.status_code = 500 return response
def page_not_found(request): response = render_to_response('page/404.html', {}, context_instance=RequestContext(request)) response.status_code = 404 return response