Skip to content

Commit

Permalink
Merge 38db881 into eb343e8
Browse files Browse the repository at this point in the history
  • Loading branch information
fmr committed Apr 9, 2015
2 parents eb343e8 + 38db881 commit 1d3fdfd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ env:
- PIP_OPTS="--download-cache $HOME/.pip-cache"

matrix:
# Testing against Django 1.4
- DJANGO="Django>=1.4,<1.5" MODEL_UTILS_VERSION=">2.0" TARGET='test-standalone-fancypages'
- DJANGO="Django>=1.4,<1.5" MODEL_UTILS_VERSION=">2.0" TARGET='test-oscar-fancypages'

# Testing against Django 1.5
- DJANGO="Django>=1.5,<1.6" MODEL_UTILS_VERSION="==1.5" TARGET='test-standalone-fancypages'
Expand Down
17 changes: 14 additions & 3 deletions fancypages/templatetags/fp_container_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ def get_object(self, context):

def get_container(self, context):
Container = get_model('fancypages', 'Container')

rc = context.render_context[self]

if 'language_code' not in rc:
rc['language_code'] = self.language_code or get_language()

# check first if the container name refers to a
# variable in the context and use it a container
try:
Expand All @@ -73,7 +79,7 @@ def get_container(self, context):
try:
ctn = Container.get_container_by_name(
name=self.container_name.var, obj=self.object,
language_code=self.language_code)
language_code=rc['language_code'])
except KeyError:
ctn = None
return ctn
Expand All @@ -86,6 +92,11 @@ def render(self, context):
we try to retrieve a container based on the variable name using
the ``object`` variable in the context.
"""

if self not in context.render_context:
# For the first time the node is rendered in the template
context.render_context[self] = {}

self.object = self.get_object(context)
self.container = self.get_container(context)

Expand All @@ -101,15 +112,15 @@ class FancyContainerNode(ContainerNodeMixin, template.Node):
def __init__(self, container_name, language=None):
self.container_name = template.Variable(container_name)
self.object_name = None
self.language_code = language or get_language()
self.language_code = language


class FancyObjectContainerNode(ContainerNodeMixin, template.Node):

def __init__(self, container_name, object_name=None, language=None):
self.container_name = template.Variable(container_name)
self.object_name = template.Variable(object_name or 'object')
self.language_code = language or get_language()
self.language_code = language


@register.tag
Expand Down
4 changes: 2 additions & 2 deletions fancypages/templatetags/fp_sitemap_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def get_page_tree(group=None, depth=1, relative_to=None):
if relative_to:
depth_offset = relative_to.depth
pages = pages.filter(
Q(node__path__startswith=relative_to.path) &
~Q(node__path=relative_to.path))
Q(node__path__startswith=relative_to.path) & ~Q(
node__path=relative_to.path))

pages = pages.filter(node__depth__lte=(depth + depth_offset))

Expand Down
3 changes: 2 additions & 1 deletion fancypages/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def loaddata(orm, fixture_name):
"""
from dingus import patch

_get_model = lambda model_identifier: orm[model_identifier]
def _get_model(model_identifier):
return orm.get(model_identifier)

with patch('django.core.serializers.python._get_model', _get_model):
from django.core.management import call_command
Expand Down

0 comments on commit 1d3fdfd

Please sign in to comment.