Contact forms app.
[prawokultury.git] / prawokultury / helpers.py
index 5877e0b..9b943de 100644 (file)
@@ -3,6 +3,7 @@
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
 from django.conf import settings
+from django.http import HttpResponse, HttpResponseRedirect
 from textile import Textile
 
 
@@ -23,7 +24,7 @@ def textile_restricted_pl(text):
                         text, rel='nofollow')
 
 
-class LazyUGettextLazy():
+class LazyUGettextLazy(object):
     """You can use it to internationalize strings in settings.
 
     Just import this class as gettext.
@@ -64,3 +65,13 @@ class AppSettings(object):
         if hasattr(self, more):
             value = getattr(self, more)(value)
         return value
+
+
+def serve_file(url):
+    if settings.X_ACCEL_REDIRECT:
+        response = HttpResponse()
+        response['Content-Type'] = ""
+        response['X-Accel-Redirect'] = url
+        return response
+    else:
+        return HttpResponseRedirect(url)