Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Review and merge unique template used when duplicates are stored (LUN…

…-368)
  • Loading branch information...
commit 741c192d423656ab39aa6fbb66e8f0b94b41847b 2 parents 04fa1cd + 7db291d
Bogdan Hodorog authored
6 cms_templates/loader.py
@@ -5,6 +5,8 @@
5 5 class CmsTemplatesLoader(Loader):
6 6
7 7 def load_and_store_template(self, template_name, cache_key, site, **params):
8   - site_ids = [s.id for s in Site.objects.filter(name__in=shared_sites)] + [site.id]
  8 + if 'sites__in' in params:
  9 + shared_ids = (s.id for s in Site.objects.filter(name__in=shared_sites).distinct())
  10 + params['sites__in'].extend(shared_ids)
9 11 return super(CmsTemplatesLoader, self).load_and_store_template(
10   - template_name, cache_key, site, sites__in=site_ids)
  12 + template_name, cache_key, site, **params)
3  cms_templates/middleware.py
@@ -64,8 +64,7 @@ class DBTemplatesMiddleware(object):
64 64 def process_request(self, request):
65 65
66 66 site_id = request.session.get('cms_admin_site', settings.SITE_ID)
67   - t = get_restricted_instances(Template, site_id, shared_sites, include_orphan)
68   -
  67 + t = get_restricted_instances(Template, site_id, shared_sites)
69 68 CMS_TEMPLATES.value = [(templ.name, templ.name) for templ in t]
70 69 if not CMS_TEMPLATES.value:
71 70 CMS_TEMPLATES.value = [('dummy',
4 cms_templates/restricted_admin_decorators.py
@@ -112,7 +112,7 @@ def __change_view(self, request, object_id, extra_context=None):
112 112 return cls
113 113 return _change_view
114 114
115   -def get_restricted_instances(model, site_id=None, shared_sites=(), include_orphan=False):
  115 +def get_restricted_instances(model, site_id=None, shared_sites=()):
116 116 if not issubclass(model, Model):
117 117 raise TypeError('%s should be a django model.' % model.__name__)
118 118
@@ -122,6 +122,4 @@ def get_restricted_instances(model, site_id=None, shared_sites=(), include_orpha
122 122 f = Q(sites=Site.objects.get_current())
123 123 if shared_sites:
124 124 f |= Q(sites__name__in=shared_sites)
125   - if include_orphan:
126   - f |= Q(sites__isnull=True)
127 125 return model.objects.filter(f).distinct()

0 comments on commit 741c192

Please sign in to comment.
Something went wrong with that request. Please try again.