X-Git-Url: https://git.mdrn.pl/prawokultury.git/blobdiff_plain/846b69463a94546a97e392f8f7ade04669df1537..58494f1136f817ce26c0471d4918e45e1bac92e3:/fnpdjango/utils/views.py diff --git a/fnpdjango/utils/views.py b/fnpdjango/utils/views.py index caf8a43..f2270cc 100644 --- a/fnpdjango/utils/views.py +++ b/fnpdjango/utils/views.py @@ -15,3 +15,14 @@ def serve_file(url): return response else: return HttpResponseRedirect(url) + + +def set_current_object(request, obj, in_url=True): + request.CURRENT_OBJECT = obj + request.CURRENT_OBJECT_IN_URL = in_url + + +def get_current_object(request, for_url=False): + if for_url and not getattr(request, 'CURRENT_OBJECT_IN_URL', True): + return None + return getattr(request, 'CURRENT_OBJECT', None)