X-Git-Url: https://git.mdrn.pl/prawokultury.git/blobdiff_plain/846b69463a94546a97e392f8f7ade04669df1537..a84463e418ebe210f8c0ae2f466ad268d31e4c36:/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)