Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

1.4 compatibility + 1.3 backward compatibility #1161

Merged
merged 6 commits into from

8 participants

@noelbush

(I made this pull request a couple of days ago, but I stupidly sent it to my own fork, instead of the divio repo. And then I wondered why nobody replied.....)

These changes now seem to work with 1.4, and also preserve 1.3 backward compatibility. I ran ./runtests.sh and corrected the problems that exposed. test_po_sanity fails with this code, but it also fails with the current develop branch. I hope this is useful.

cms/admin/change_list.py
@@ -70,7 +70,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]
- qs = super(CMSChangeList, self).get_query_set().drafts()
+ if 'request' in ChangeList.get_query_set.func_code.co_varnames: # django 1.4

Is this really necessary? Couldn't we just use if django.VERSION >= (1, 4): instead?

@noelbush
noelbush added a note

That sounds good to me. I was just following the practice I saw elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
cms/admin/pageadmin.py
@@ -640,8 +642,12 @@ def changelist_view(self, request, extra_context=None):
raise PermissionDenied
try:
if hasattr(self, 'list_editable'):# django 1.1

This might be the appropriate time to get rid of the if 1.1 else 1.0.2 logic, as neither version is supported any more as far as I know, and ojii didn't object in #1111.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@noelbush

I have updated the version checking as suggested in previous comments, and I have verified that all tests pass with the Django 1.4 beta 1 (EXCEPT for the previously mentioned test_po_sanity).

@noelbush

All tests pass with the officially released Django 1.4

@tback

I just checked out your django_1.4_compatibility branch and tried running the tests. I get 139 errors when running the tests against 1.4. I can confirm that all tests pass against django 1.3

Here is what I did:
First I provided a buildout django-14.cfg. (I copied django-13.cfg and updated the django version)
Then I ran the tests:
$ ./runtest.sh -d 14 -> 139 errors

$ ./runtest.sh -d 13 -> OK

@noelbush
@tback

Noel, you're right the majority is the context processors.

I've brought it down to 3 errors and 2 failures through some minor changes and through the adaption to reversion 1.6. Now I am kinda lost and looking for pointers. I'd highly appreciate if someone could look through it

A word of caution: I am quite new to django-cms and don't really know what I am doing. I am unsure which admin URLs are correct (example.org/en/admin/... or example.org/admin/...) and the adaption to reversion 1.6 isn't completed. The tests look OK, but I've yet to look at the results on a testserver.

https://github.com/tback/django-cms/tree/django_1.4_compatibility/here_be_dragons

@ojii ojii referenced this pull request
Closed

1.4 support - meta ticket #1228

@stefanfoulis stefanfoulis was assigned
@piquadrat piquadrat merged commit 78638dd into divio:develop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
8 cms/admin/change_list.py
@@ -8,6 +8,7 @@
from django.contrib.admin.views.main import ChangeList, ALL_VAR, IS_POPUP_VAR, \
ORDER_TYPE_VAR, ORDER_VAR, SEARCH_VAR
from django.contrib.sites.models import Site
+import django
COPY_VAR = "copy"
@@ -54,9 +55,9 @@ class CMSChangeList(ChangeList):
real_queryset = False
def __init__(self, request, *args, **kwargs):
- super(CMSChangeList, self).__init__(request, *args, **kwargs)
from cms.utils.plugins import current_site
self._current_site = current_site(request)
+ super(CMSChangeList, self).__init__(request, *args, **kwargs)
try:
self.query_set = self.get_query_set(request)
except:
@@ -70,7 +71,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]
- qs = super(CMSChangeList, self).get_query_set().drafts()
+ if django.VERSION >= (1, 4):
+ qs = super(CMSChangeList, self).get_query_set(request).drafts()
+ else:
+ qs = super(CMSChangeList, self).get_query_set().drafts()
if request:
site = self._current_site
permissions = Page.permissions.get_change_id_list(request.user, site)
View
17 cms/admin/pageadmin.py
@@ -461,7 +461,9 @@ def get_form(self, request, obj=None, **kwargs):
# remove permission inlines, if user isn't allowed to change them
def get_formsets(self, request, obj=None):
if obj:
- for inline in self.inline_instances:
+ inlines = self.get_inline_instances(request) if hasattr(self, 'get_inline_instances') \
+ else self.inline_instances
+ for inline in inlines:
if settings.CMS_PERMISSION and isinstance(inline, PagePermissionInlineAdmin) and not isinstance(inline, ViewRestrictionInlineAdmin):
if "recover" in request.path or "history" in request.path: #do not display permissions in recover mode
continue
@@ -639,12 +641,12 @@ def changelist_view(self, request, extra_context=None):
if not self.has_change_permission(request, None):
raise PermissionDenied
try:
- if hasattr(self, 'list_editable'):# django 1.1
+ if django.VERSION >= (1, 4):
cl = CMSChangeList(request, self.model, self.list_display, self.list_display_links, self.list_filter,
- self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_editable, self)
- else:# django 1.0.2
+ self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_max_show_all, self.list_editable, self)
+ else:
cl = CMSChangeList(request, self.model, self.list_display, self.list_display_links, self.list_filter,
- self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self)
+ self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_editable, self)
except IncorrectLookupParameters:
# Wacky lookup parameters were given, so redirect to the main
# changelist page, without parameters, and pass an 'invalid=1'
@@ -667,14 +669,13 @@ def changelist_view(self, request, extra_context=None):
languages = settings.CMS_SITE_LANGUAGES[site_id]
else:
languages = [x[0] for x in settings.CMS_LANGUAGES]
-
+
context = {
'title': cl.title,
'is_popup': cl.is_popup,
'cl': cl,
'opts':opts,
'has_add_permission': self.has_add_permission(request),
- 'root_path': self.admin_site.root_path,
'app_label': app_label,
'CMS_MEDIA_URL': settings.CMS_MEDIA_URL,
'softroot': settings.CMS_SOFTROOT,
@@ -936,7 +937,6 @@ def delete_translation(self, request, object_id, extra_context=None):
saved_plugins = CMSPlugin.objects.filter(placeholder__page__id=object_id, language=language)
if django.VERSION[1] > 2: # pragma: no cover
- # WARNING: Django 1.3 is not officially supported yet!
using = router.db_for_read(self.model)
kwargs = {
'admin_site': self.admin_site,
@@ -994,7 +994,6 @@ def delete_translation(self, request, object_id, extra_context=None):
"deleted_objects": deleted_objects,
"perms_lacking": perms_needed,
"opts": titleopts,
- "root_path": self.admin_site.root_path,
"app_label": app_label,
}
context.update(extra_context or {})
View
2  cms/templatetags/cms_admin.py
@@ -68,7 +68,7 @@ def get_context(self, context, cl, spec):
if choice['query_string'] != query_string:
unique_choices.append(choice)
query_string = choice['query_string']
- return {'title': spec.title(), 'choices' : unique_choices}
+ return {'title': spec.title, 'choices' : unique_choices}
register.tag(CleanAdminListFilter)
View
11 cms/tests/admin.py
@@ -351,12 +351,15 @@ def test_changelist_items(self):
request.user = admin
page_admin = site._registry[Page]
-
- cl = CMSChangeList(request, page_admin.model, page_admin.list_display,
+
+ cl_params = [request, page_admin.model, page_admin.list_display,
page_admin.list_display_links, page_admin.list_filter,
page_admin.date_hierarchy, page_admin.search_fields,
- page_admin.list_select_related, page_admin.list_per_page,
- page_admin.list_editable, page_admin)
+ page_admin.list_select_related, page_admin.list_per_page]
+ if hasattr(page_admin, 'list_max_show_all'): # django 1.4
+ cl_params.append(page_admin.list_max_show_all)
+ cl_params.extend([page_admin.list_editable, page_admin])
+ cl = CMSChangeList(*tuple(cl_params))
cl.set_items(request)
Something went wrong with that request. Please try again.