cleanup in utils
This commit is contained in:
parent
9943e84a96
commit
f5a438cf9f
@ -24,6 +24,10 @@ class Tab(object):
|
||||
self.url = url
|
||||
|
||||
|
||||
## All following function are only needed to render a block from a template
|
||||
## and could be removed, if the template worked with an include-statement instead.
|
||||
## Its only used for ajax-request from the projector.
|
||||
|
||||
def get_template(template):
|
||||
if isinstance(template, (tuple, list)):
|
||||
return loader.select_template(template)
|
||||
@ -77,23 +81,3 @@ def render_block_to_string(template_name, block, dictionary=None,
|
||||
context_instance = Context(dictionary)
|
||||
t.render(context_instance)
|
||||
return render_template_block(t, block, context_instance)
|
||||
|
||||
|
||||
def direct_block_to_template(request, template, block, extra_context=None,
|
||||
mimetype=None, **kwargs):
|
||||
"""
|
||||
Render a given block in a given template with any extra URL parameters in
|
||||
the context as ``{{ params }}``.
|
||||
"""
|
||||
if extra_context is None:
|
||||
extra_context = {}
|
||||
dictionary = {'params': kwargs}
|
||||
for key, value in extra_context.items():
|
||||
if callable(value):
|
||||
dictionary[key] = value()
|
||||
else:
|
||||
dictionary[key] = value
|
||||
c = RequestContext(request, dictionary)
|
||||
t = get_template(template)
|
||||
t.render(c)
|
||||
return HttpResponse(render_template_block(t, block, c), mimetype=mimetype)
|
||||
|
@ -67,12 +67,12 @@ def del_confirm_form(request, object, name=None, delete_link=None):
|
||||
% html_strong(name), delete_link)
|
||||
|
||||
|
||||
def render_response(req, *args, **kwargs):
|
||||
kwargs['context_instance'] = RequestContext(req)
|
||||
return render_to_response(*args, **kwargs)
|
||||
|
||||
|
||||
def template(template_name):
|
||||
"""
|
||||
Decorator to set a template for a view.
|
||||
|
||||
Deprecated. Use class based views instead.
|
||||
"""
|
||||
def renderer(func):
|
||||
def wrapper(request, *args, **kwargs):
|
||||
output = func(request, *args, **kwargs)
|
||||
@ -95,6 +95,8 @@ def permission_required(perm, login_url=None):
|
||||
"""
|
||||
Decorator for views that checks whether a user has a particular permission
|
||||
enabled, redirecting to the log-in page if necessary.
|
||||
|
||||
Deprecated.
|
||||
"""
|
||||
def renderer(func):
|
||||
def wrapper(request, *args, **kw):
|
||||
@ -109,6 +111,8 @@ def permission_required(perm, login_url=None):
|
||||
|
||||
def render_to_forbidden(request, error=
|
||||
ugettext_lazy("Sorry, you have no rights to see this page.")):
|
||||
# TODO: Integrate this function into the PermissionMixin once the
|
||||
# above function is deleted.
|
||||
return HttpResponseForbidden(render_to_string('403.html',
|
||||
{'error': error}, context_instance=RequestContext(request)))
|
||||
|
||||
@ -127,7 +131,9 @@ def delete_default_permissions(**kwargs):
|
||||
def ajax_request(data):
|
||||
"""
|
||||
generates a HTTPResponse-Object with json-Data for a
|
||||
ajax response
|
||||
ajax response.
|
||||
|
||||
Deprecated.
|
||||
"""
|
||||
return HttpResponse(json.dumps(data))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user