Changeset - e8434f637f9f
[Not reviewed]
default
1 3 0
Branko Majic (branko) - 11 years ago 2013-03-24 13:32:48
branko@majic.rs
Removed the line stripper middleware since it interfered with regular template lookups. Added some custom code to remove all blank lines from iptables rendering instead.
4 files changed with 8 insertions and 82 deletions:
0 comments (0 inline, 0 general)
conntrackt/stripper.py
Show inline comments
 
deleted file
conntrackt/templates/conntrackt/entity_iptables.html
Show inline comments
 
@@ -8,6 +8,8 @@
 

	
 
      {% if communication.description %}
 
# {{communication.description}}
 
      {% else  %}
 
# Communications without desecription.
 
      {% endif %}
 
    {% endifchanged %}
 
{% iptables communication %}
conntrackt/views.py
Show inline comments
 
# For generating ZIP files.
 
from StringIO import StringIO
 
from zipfile import ZipFile, ZIP_DEFLATED
 
import re
 

	
 
# Django-specific imports.
 
from django.http import HttpResponse
 
@@ -99,6 +100,11 @@ class IptablesView(DetailView):
 
        # browser to download the file with suggested filename.
 
        response['Content-Disposition']="attachment; filename=%s-iptables.conf" % self.object.name.lower().replace(" ", "_")
 

	
 
        # Render the response, and remove the blank lines from the template.
 
        response.render()
 
        response.content = re.sub('^\s*\n', '', response.content)
 
        response.content = re.sub('\n\s*\n', '\n', response.content)
 

	
 
        # Return the modified response.
 
        return response
 

	
projtest/projtest/settings.py
Show inline comments
 
@@ -81,7 +81,6 @@ SECRET_KEY = '%s-x^wskhxu#5%o)0ck71g7o@7
 

	
 
# List of callables that know how to import templates from various sources.
 
TEMPLATE_LOADERS = (
 
    'conntrackt.stripper.Loader',
 
    'django.template.loaders.filesystem.Loader',
 
    'django.template.loaders.app_directories.Loader',
 
#     'django.template.loaders.eggs.Loader',
 
@@ -95,7 +94,6 @@ MIDDLEWARE_CLASSES = (
 
    'django.contrib.messages.middleware.MessageMiddleware',
 
    # Uncomment the next line for simple clickjacking protection:
 
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 
    'conntrackt.stripper.StripperMiddleware'
 
)
 

	
 
ROOT_URLCONF = 'projtest.urls'
0 comments (0 inline, 0 general)