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