|
|
|
@ -2,8 +2,10 @@ |
|
|
|
# from django.contrib.redirects.middleware import RedirectFallbackMiddleware |
|
|
|
# from django.contrib.redirects.middleware import RedirectFallbackMiddleware |
|
|
|
import re |
|
|
|
import re |
|
|
|
|
|
|
|
|
|
|
|
from django.http import HttpResponsePermanentRedirect |
|
|
|
|
|
|
|
from django.core.urlresolvers import reverse |
|
|
|
from django.core.urlresolvers import reverse |
|
|
|
|
|
|
|
from django.conf import settings |
|
|
|
|
|
|
|
from django.http import HttpResponsePermanentRedirect |
|
|
|
|
|
|
|
from django.utils.html import strip_spaces_between_tags |
|
|
|
|
|
|
|
|
|
|
|
from exposition.models import Exposition |
|
|
|
from exposition.models import Exposition |
|
|
|
from country.models import Country |
|
|
|
from country.models import Country |
|
|
|
@ -63,3 +65,16 @@ def check_places(slug): |
|
|
|
if Country.objects.filter(url=slug).exists(): |
|
|
|
if Country.objects.filter(url=slug).exists(): |
|
|
|
return HttpResponsePermanentRedirect(reverse('place_country', kwargs={'slug': slug})) |
|
|
|
return HttpResponsePermanentRedirect(reverse('place_country', kwargs={'slug': slug})) |
|
|
|
return None |
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# https://gist.github.com/b1/3155460 |
|
|
|
|
|
|
|
""" spaceless middleware |
|
|
|
|
|
|
|
MIDDLEWARE_CLASSES += ('core_utils.middleware.SpacelessMiddleware',) |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
class SpacelessMiddleware(object): |
|
|
|
|
|
|
|
""" trim spaces between tags if not in DEBUG """ |
|
|
|
|
|
|
|
def process_response(self, request, response): |
|
|
|
|
|
|
|
cont = response.content |
|
|
|
|
|
|
|
cont = strip_spaces_between_tags(cont) |
|
|
|
|
|
|
|
response.content = re.sub(r'^\s+<','<', cont ) |
|
|
|
|
|
|
|
return response |
|
|
|
|