Permalink
Browse files

Merge pull request #2723 from digi604/fix-2685

fixes #2685 (tree view has links to current page language)
  • Loading branch information...
digi604 committed Feb 27, 2014
2 parents 7f06aea + b7137c2 commit 3a09d5c39b3469e64aeecc0205a193f5b70c2061
View
@@ -62,6 +62,10 @@ def __init__(self, request, *args, **kwargs):
def get_query_set(self, request=None):
if COPY_VAR in self.params:
del self.params[COPY_VAR]
+ if 'language' in self.params:
+ del self.params['language']
+ if 'page_id' in self.params:
+ del self.params['page_id']
if django.VERSION[1] > 3:
qs = super(CMSChangeList, self).get_query_set(request).drafts()
else:
@@ -82,7 +86,7 @@ def get_query_set(self, request=None):
def is_filtered(self):
from cms.utils.plugins import SITE_VAR
lookup_params = self.params.copy() # a dictionary of the query string
- for i in (ALL_VAR, ORDER_VAR, ORDER_TYPE_VAR, SEARCH_VAR, IS_POPUP_VAR, SITE_VAR):
+ for i in (ALL_VAR, ORDER_VAR, ORDER_TYPE_VAR, SEARCH_VAR, IS_POPUP_VAR, SITE_VAR, 'language', 'page_id'):
if i in lookup_params:
del lookup_params[i]
if not lookup_params.items() and not self.query:
View
@@ -20,7 +20,7 @@
from django.shortcuts import render_to_response, get_object_or_404
from django.template.context import RequestContext
from django.template.defaultfilters import escape
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import ugettext_lazy as _, get_language
from django.utils.decorators import method_decorator
from django.views.decorators.http import require_POST
@@ -636,6 +636,7 @@ def changelist_view(self, request, extra_context=None):
'has_add_permission': self.has_add_permission(request),
'root_path': reverse('admin:index'),
'app_label': app_label,
+ 'preview_language': request.GET.get('language', get_language()),
'CMS_MEDIA_URL': get_cms_setting('MEDIA_URL'),
'CMS_PERMISSION': get_cms_setting('PERMISSION'),
'DEBUG': settings.DEBUG,
View
@@ -249,7 +249,10 @@ def change_language_menu(self):
def change_admin_menu(self):
admin_menu = self.toolbar.get_or_create_menu(ADMIN_MENU_IDENTIFIER)
# cms page admin
- admin_menu.add_sideframe_item(_('Pages'), url=reverse("admin:cms_page_changelist"), position=0)
+ url = "%s?language=%s" % (reverse("admin:cms_page_changelist"), self.toolbar.language)
+ if self.page:
+ url += "&page_id=%s" % self.page.pk
+ admin_menu.add_sideframe_item(_('Pages'), url=url, position=0)
def add_page_menu(self):
# menu for current page

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -89,8 +89,10 @@ $(document).ready(function () {
open: function (url, animate) {
// prepare iframe
var that = this;
+ var language = 'language=' + CMS.config.request.language;
+ var page_id = 'page_id=' + CMS.config.request.page_id;
var holder = this.sideframe.find('.cms_sideframe-frame');
- var iframe = $('<iframe src="'+url+'" class="" frameborder="0" />');
+ var iframe = $('<iframe src="'+this._url(url, [language, page_id])+'" class="" frameborder="0" />');
iframe.hide();
var width = this.settings.sideframe.position || this.options.sideframeWidth;
@@ -294,6 +296,47 @@ $(document).ready(function () {
this.sideframe.find('.cms_sideframe-shim').css('z-index', 1);
$(document).unbind('mousemove.cms');
+ },
+
+ _url: function (url, params) {
+ // return url if there is no param
+ if(url.split('?').length <= 1 || window.JSON === undefined) return url;
+ // setup local vars
+ var urlArray = url.split('?');
+ var urlParams = urlArray[1].split('&');
+ var origin = urlArray[0];
+ var arr = [];
+ var keys = [];
+ var values = [];
+ var tmp = '';
+
+ // loop through the available params
+ $.each(urlParams, function (index, param) {
+ arr.push({ 'param': param.split('=')[0], 'value': param.split('=')[1] });
+ });
+ // loop through the new params
+ $.each(params, function (index, param) {
+ arr.push({ 'param': param.split('=')[0], 'value': param.split('=')[1] });
+ });
+
+ // merge manually because jquery...
+ $.each(arr, function (index, item) {
+ if(keys.indexOf(item.param) === -1) {
+ keys.push(item.param);
+ values.push(item.value);
+ } else {
+ values[keys.indexOf(item.param)] = item.value;
+ }
+ });
+
+ // merge new url
+ $.each(keys, function (index, key) {
+ tmp += '&' + key + '=' + values[index];
+ });
+ tmp = tmp.replace('&', '?');
+ url = origin + tmp;
+
+ return url;
}
});
@@ -103,6 +103,9 @@ $color-background-blue-hover: #e6f6fd;
// edit button
.cont:hover .col1 a.changelink { display:block; }
+ // active state
+ .cont-active { background:lighten(#ffff99, 10%); }
+
// drag modus
li#dragged { min-width:500px; }
li#dragged .col2 { display:none; }
Oops, something went wrong.

0 comments on commit 3a09d5c

Please sign in to comment.