Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #175 from tomscytale/develop

fix Django1.4 compatibility issue
  • Loading branch information...
commit a911ccd0a6bafb3779579ff3bb0f5cfb26e5ef90 2 parents 19c4169 + f102089
Stefan Foulis authored
12 filer/admin/folderadmin.py
View
@@ -354,7 +354,7 @@ def filter_file(qs, terms=[]):
'is_popup': popup_status(request),
'select_folder': selectfolder_status(request),
# needed in the admin/base.html template for logout links
- 'root_path': "/%s" % admin.site.root_path,
+ 'root_path': reverse('admin:index'),
'action_form': action_form,
'actions_on_top': self.actions_on_top,
'actions_on_bottom': self.actions_on_bottom,
@@ -614,7 +614,7 @@ def delete_files_or_folders(self, request, files_queryset, folders_queryset):
"perms_lacking": all_perms_needed,
"protected": all_protected,
"opts": opts,
- "root_path": self.admin_site.root_path,
+ "root_path": reverse('admin:index'),
"app_label": app_label,
"action_checkbox_name": helpers.ACTION_CHECKBOX_NAME,
}
@@ -755,7 +755,7 @@ def move_files_and_folders(self, request, files_queryset, folders_queryset):
"folders_queryset": folders_queryset,
"perms_lacking": perms_needed,
"opts": opts,
- "root_path": self.admin_site.root_path,
+ "root_path": reverse('admin:index'),
"app_label": app_label,
"action_checkbox_name": helpers.ACTION_CHECKBOX_NAME,
}
@@ -839,7 +839,7 @@ def rename_files(self, request, files_queryset, folders_queryset):
"folders_queryset": folders_queryset,
"perms_lacking": perms_needed,
"opts": opts,
- "root_path": self.admin_site.root_path,
+ "root_path": reverse('admin:index'),
"app_label": app_label,
"action_checkbox_name": helpers.ACTION_CHECKBOX_NAME,
}
@@ -968,7 +968,7 @@ def copy_files_and_folders(self, request, files_queryset, folders_queryset):
"folders_queryset": folders_queryset,
"perms_lacking": perms_needed,
"opts": opts,
- "root_path": self.admin_site.root_path,
+ "root_path": reverse('admin:index'),
"app_label": app_label,
"action_checkbox_name": helpers.ACTION_CHECKBOX_NAME,
}
@@ -1091,7 +1091,7 @@ def resize_images(self, request, files_queryset, folders_queryset):
"folders_queryset": folders_queryset,
"perms_lacking": perms_needed,
"opts": opts,
- "root_path": self.admin_site.root_path,
+ "root_path": reverse('admin:index'),
"app_label": app_label,
"action_checkbox_name": helpers.ACTION_CHECKBOX_NAME,
}
8 filer/fields/file.py
View
@@ -1,7 +1,9 @@
#-*- coding: utf-8 -*-
+import inspect
from django import forms
from django.conf import settings as globalsettings
from django.contrib.admin.widgets import ForeignKeyRawIdWidget
+from django.contrib.admin.sites import site
from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import reverse
from django.db import models
@@ -88,7 +90,11 @@ def __init__(self, rel, queryset, to_field_name, *args, **kwargs):
self.max_value = None
self.min_value = None
other_widget = kwargs.pop('widget', None)
- forms.Field.__init__(self, widget=self.widget(rel), *args, **kwargs)
+ if 'admin_site' in inspect.getargspec(self.widget.__init__)[0]: # Django 1.4
+ widget_instance = self.widget(rel, site)
+ else: # Django <= 1.3
+ widget_instance = self.widget(rel)
+ forms.Field.__init__(self, widget=widget_instance, *args, **kwargs)
def widget_attrs(self, widget):
widget.required = self.required
8 filer/fields/folder.py
View
@@ -1,7 +1,9 @@
#-*- coding: utf-8 -*-
+import inspect
from django import forms
from django.conf import settings
from django.contrib.admin.widgets import ForeignKeyRawIdWidget
+from django.contrib.admin.sites import site
from django.core.urlresolvers import reverse
from django.db import models
from django.utils.safestring import mark_safe
@@ -107,7 +109,11 @@ def __init__(self, rel, queryset, to_field_name, *args, **kwargs):
self.max_value = None
self.min_value = None
kwargs.pop('widget', None)
- forms.Field.__init__(self, widget=self.widget(rel), *args, **kwargs)
+ if 'admin_site' in inspect.getargspec(self.widget.__init__)[0]: # Django 1.4
+ widget_instance = self.widget(rel, site)
+ else: # Django <= 1.3
+ widget_instance = self.widget(rel)
+ forms.Field.__init__(self, widget=widget_instance, *args, **kwargs)
def widget_attrs(self, widget):
widget.required = self.required
Please sign in to comment.
Something went wrong with that request. Please try again.