Skip to content

Commit

Permalink
Bump version and fix broken unit tests by using the processed filer s…
Browse files Browse the repository at this point in the history
…ettings rather than the ones in django.conf.settings
  • Loading branch information
kux committed Apr 24, 2013
1 parent a1537cc commit 6af79b6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
4 changes: 2 additions & 2 deletions filertags/settings.py
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.conf import settings import filer.settings


filer_storages = getattr(settings, 'FILER_STORAGES', {}) filer_storages = getattr(filer.settings, 'FILER_STORAGES', {})


LOGICAL_EQ_ACTUAL_URL = all( LOGICAL_EQ_ACTUAL_URL = all(
storage['main']['UPLOAD_TO'] == 'filer.utils.generate_filename.by_path' storage['main']['UPLOAD_TO'] == 'filer.utils.generate_filename.by_path'
Expand Down
11 changes: 10 additions & 1 deletion filertags/signals.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -250,8 +250,17 @@ def update_referencing_css_files(instance, **kwargs):
update_url_statements_in_css(css, resource_file, logical_file_path) update_url_statements_in_css(css, resource_file, logical_file_path)




if not LOGICAL_EQ_ACTUAL_URL: def attach_css_rewriting_rules():
signals.pre_save.connect(resolve_resource_urls, sender=File) signals.pre_save.connect(resolve_resource_urls, sender=File)
signals.post_save.connect(update_referencing_css_files, sender=File) signals.post_save.connect(update_referencing_css_files, sender=File)
signals.post_save.connect(update_referencing_css_files, sender=Image) signals.post_save.connect(update_referencing_css_files, sender=Image)


def detach_css_rewriting_rules():
signals.pre_save.disconnect(resolve_resource_urls, sender=File)
signals.post_save.disconnect(update_referencing_css_files, sender=File)
signals.post_save.disconnect(update_referencing_css_files, sender=Image)



if not LOGICAL_EQ_ACTUAL_URL:
attach_css_rewriting_rules()
4 changes: 2 additions & 2 deletions filertags/templatetags/filertags.py
Original file line number Original file line Diff line number Diff line change
@@ -1,11 +1,11 @@
import logging import logging


from django import template from django import template
from django.conf import settings
from django.db.models import Q from django.db.models import Q
from django.template.defaultfilters import stringfilter from django.template.defaultfilters import stringfilter


from filer.models import File, Folder from filer.models import File, Folder
import filer.settings as filer_settings
# TODO: this is ugly: the ..settings is because the toplevel package # TODO: this is ugly: the ..settings is because the toplevel package
# name has the same name as this module; should probably rename the toplevel package? # name has the same name as this module; should probably rename the toplevel package?
from ..settings import LOGICAL_EQ_ACTUAL_URL from ..settings import LOGICAL_EQ_ACTUAL_URL
Expand Down Expand Up @@ -39,7 +39,7 @@ def filerthumbnail(path):


def get_possible_paths(path): def get_possible_paths(path):
return ['%s/%s' % (storage['main']['UPLOAD_TO_PREFIX'], path) return ['%s/%s' % (storage['main']['UPLOAD_TO_PREFIX'], path)
for storage in settings.FILER_STORAGES.values()] for storage in filer_settings.FILER_STORAGES.values()]




def filerfile(path): def filerfile(path):
Expand Down
5 changes: 4 additions & 1 deletion filertags/tests.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from filer.settings import FILER_PUBLICMEDIA_STORAGE from filer.settings import FILER_PUBLICMEDIA_STORAGE
from filer.tests.helpers import create_superuser from filer.tests.helpers import create_superuser


from filertags.signals import _ALREADY_PARSED_MARKER, _LOGICAL_URL_TEMPLATE from filertags.signals import _ALREADY_PARSED_MARKER, _LOGICAL_URL_TEMPLATE,\
attach_css_rewriting_rules, detach_css_rewriting_rules




class CssRewriteTest(TestCase): class CssRewriteTest(TestCase):
Expand All @@ -22,6 +23,7 @@ def _get_test_usermedia_location(self):
return os.path.join(HERE, 'tmp_user_media') return os.path.join(HERE, 'tmp_user_media')


def setUp(self): def setUp(self):
attach_css_rewriting_rules()
self.superuser = create_superuser() self.superuser = create_superuser()
self.client.login(username='admin', password='secret') self.client.login(username='admin', password='secret')
media_folder = Folder.objects.create(name='media') media_folder = Folder.objects.create(name='media')
Expand All @@ -37,6 +39,7 @@ def tearDown(self):
cache.clear() cache.clear()
shutil.rmtree(FILER_PUBLICMEDIA_STORAGE.location) shutil.rmtree(FILER_PUBLICMEDIA_STORAGE.location)
FILER_PUBLICMEDIA_STORAGE.location = self.usual_location FILER_PUBLICMEDIA_STORAGE.location = self.usual_location
detach_css_rewriting_rules()


def create_file(self, name, folder, content=None): def create_file(self, name, folder, content=None):
if content is None: if content is None:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


setup( setup(
name='django-filer-tags', name='django-filer-tags',
version='0.6.2', version='0.6.3',
description='Extra template filters and tags for filer', description='Extra template filters and tags for filer',
long_description = open(README_PATH, 'r').read(), long_description = open(README_PATH, 'r').read(),
author='Sever Banesiu', author='Sever Banesiu',
Expand Down

0 comments on commit 6af79b6

Please sign in to comment.