Minor fixes.
[prawokultury.git] / fnpdjango / utils / views.py
index caf8a43..f2270cc 100644 (file)
@@ -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)