Commits

Gregory Petukhov committed 91cf72d

Add UnderConstructionMiddleware

  • Participants
  • Parent commits 1113330

Comments (0)

Files changed (3)

common/middleware.py

-from urlparse import urlsplit
+# coding: utf-8
+from django.shortcuts import redirect
+from django.contrib import messages
 
-from django.conf import settings
-from django.views.static import serve
-
-PREFIX = urlsplit(settings.MEDIA_URL).path
-
-class StaticFilesMiddleware(object):
-    """
-    Django middleware for serving static files instead of using urls.py
-    """
-
+class UnderConstructionMiddleware(object):
     def process_request(self, request):
-        if settings.DEBUG:
-            if request.path.startswith(PREFIX):
-                path = request.path[len(PREFIX):]
-                return serve(request, path, settings.MEDIA_ROOT)
+        if request.method == 'POST':
+            messages.error(request, u'Извините. Сайт переезжает на другой сервер. Все изменения данных временно запрещены')
+            return redirect(request.get_full_path())
+        else:
+            return None
 #!/bin/sh
 hg push
-python setup.py register sdist upload build_sphinx upload_sphinx
+python setup.py register sdist upload # build_sphinx upload_sphinx
 setup(
     name = 'django-common',
     description = 'A number of useful django shortcuts and helpers',
-    version = '0.1.50',
+    version = '0.1.51',
     author = 'Grigoriy Petukhov',
     author_email = 'lorien@lorien.name',
     url = 'http://bitbucket.org/lorien/django-common/',