def front_page(request): """ Renders different templates if the user is logged in or not """ if not request.user.is_authenticated(): return render_to_response( "ui/front.html", {"document_count": manager(Document).count(), "page_count": manager(Page).count()}, context_instance=RequestContext(request), ) else: return render_to_response( "ui/home.html", {"search_query": request.GET.get("q", "")}, context_instance=RequestContext(request) )
def front_page(request): """ Renders different templates if the user is logged in or not """ if not request.user.is_authenticated(): return render_to_response('ui/front.html', { 'document_count': manager(Document).count(), 'page_count': manager(Page).count(), }, context_instance=RequestContext(request)) else: return render_to_response('ui/home.html', {'search_query': request.GET.get('q', '')}, context_instance=RequestContext(request))
def process_uploaded_files(files, user): gateway = _init_processor()[0] logging.debug(str(gateway)) # pick all files that are send in this API # support sending multiple files in a single request for key, the_file in files.iteritems(): content_type = the_file.content_type if content_type == 'application/octet-stream': content_type = guess_mime_type(the_file.name) asset_class = models.manager(models.AssetClass).get( name = models.AssetClass.UPLOAD) if not asset_class.has_consumers(content_type): raise HttpRequestValidationError( 'Unsupported content type: %s' % content_type) upload = operations.create_asset_from_stream( data_stream = StringIO(the_file.read()), owner = user, producer = gateway, asset_class = models.AssetClass.UPLOAD, file_name = the_file.name, child_number = 0, mime_type = content_type) operations.publish_work_item(upload)