Browse Source

Merge branch 'dev' of github.com:HarryLafranc/django-jet into feature/django-2.0

Denis K 7 years ago
parent
commit
d17a2c73d9

+ 5 - 5
jet/dashboard/forms.py

@@ -17,7 +17,7 @@ class UpdateDashboardModulesForm(forms.Form):
     def clean(self):
         data = super(UpdateDashboardModulesForm, self).clean()
 
-        if not self.request.user.is_authenticated() or not self.request.user.is_staff:
+        if not self.request.user.is_authenticated or not self.request.user.is_staff:
             raise ValidationError('error')
 
         try:
@@ -68,7 +68,7 @@ class AddUserDashboardModuleForm(forms.ModelForm):
     def clean(self):
         data = super(AddUserDashboardModuleForm, self).clean()
 
-        if not self.request.user.is_authenticated() or not self.request.user.is_staff:
+        if not self.request.user.is_authenticated or not self.request.user.is_staff:
             raise ValidationError('error')
 
         if 'app_label' in data:
@@ -110,7 +110,7 @@ class UpdateDashboardModuleCollapseForm(forms.ModelForm):
     def clean(self):
         data = super(UpdateDashboardModuleCollapseForm, self).clean()
 
-        if not self.request.user.is_authenticated() or not self.request.user.is_staff:
+        if not self.request.user.is_authenticated or not self.request.user.is_staff:
             raise ValidationError('error')
 
         if self.instance.user != self.request.user.pk:
@@ -131,7 +131,7 @@ class RemoveDashboardModuleForm(forms.ModelForm):
     def clean(self):
         cleaned_data = super(RemoveDashboardModuleForm, self).clean()
 
-        if not self.request.user.is_authenticated() or self.instance.user != self.request.user.pk:
+        if not self.request.user.is_authenticated or self.instance.user != self.request.user.pk:
             raise ValidationError('error')
 
         return cleaned_data
@@ -156,7 +156,7 @@ class ResetDashboardForm(forms.Form):
         data = super(ResetDashboardForm, self).clean()
         data['app_label'] = data['app_label'] if data['app_label'] else None
 
-        if not self.request.user.is_authenticated() or not self.request.user.is_staff:
+        if not self.request.user.is_authenticated or not self.request.user.is_staff:
             raise ValidationError('error')
 
         return data

+ 1 - 1
jet/dashboard/templatetags/jet_dashboard_tags.py

@@ -5,7 +5,7 @@ from jet.dashboard.utils import get_current_dashboard
 register = template.Library()
 
 
-@register.assignment_tag(takes_context=True)
+@register.simple_tag(takes_context=True)
 def get_dashboard(context, location):
     dashboard_cls = get_current_dashboard(location)
 

+ 9 - 2
jet/dashboard/urls.py

@@ -1,6 +1,13 @@
 import django
 from django.conf.urls import url
-from django.views.i18n import javascript_catalog
+
+try:
+    from django.views.i18n import javascript_catalog
+    jsc_view = javascript_catalog
+except ImportError:
+    from django.views.i18n import JavaScriptCatalog
+    jsc_view = JavaScriptCatalog.as_view()
+
 from jet.dashboard import dashboard
 from jet.dashboard.views import update_dashboard_modules_view, add_user_dashboard_module_view, \
     update_dashboard_module_collapse_view, remove_dashboard_module_view, UpdateDashboardModuleView, \
@@ -44,7 +51,7 @@ urlpatterns = [
     ),
     url(
         r'^jsi18n/$',
-        javascript_catalog,
+        jsc_view,
         {'packages': ('jet',)},
         name='jsi18n'
     ),

+ 1 - 1
jet/dashboard/views.py

@@ -216,7 +216,7 @@ def load_dashboard_module_view(request, pk):
     result = {'error': False}
 
     try:
-        if not request.user.is_authenticated() or not request.user.is_staff:
+        if not request.user.is_authenticated or not request.user.is_staff:
             raise ValidationError('error')
 
         instance = UserDashboardModule.objects.get(pk=pk, user=request.user.pk)

+ 4 - 4
jet/forms.py

@@ -27,7 +27,7 @@ class AddBookmarkForm(forms.ModelForm):
 
     def clean(self):
         data = super(AddBookmarkForm, self).clean()
-        if not self.request.user.is_authenticated() or not self.request.user.is_staff:
+        if not self.request.user.is_authenticated or not self.request.user.is_staff:
             raise ValidationError('error')
         if not self.request.user.has_perm('jet.change_bookmark'):
             raise ValidationError('error')
@@ -49,7 +49,7 @@ class RemoveBookmarkForm(forms.ModelForm):
 
     def clean(self):
         data = super(RemoveBookmarkForm, self).clean()
-        if not self.request.user.is_authenticated() or not self.request.user.is_staff:
+        if not self.request.user.is_authenticated or not self.request.user.is_staff:
             raise ValidationError('error')
         if self.instance.user != self.request.user.pk:
             raise ValidationError('error')
@@ -71,7 +71,7 @@ class ToggleApplicationPinForm(forms.ModelForm):
 
     def clean(self):
         data = super(ToggleApplicationPinForm, self).clean()
-        if not self.request.user.is_authenticated() or not self.request.user.is_staff:
+        if not self.request.user.is_authenticated or not self.request.user.is_staff:
             raise ValidationError('error')
         return data
 
@@ -108,7 +108,7 @@ class ModelLookupForm(forms.Form):
     def clean(self):
         data = super(ModelLookupForm, self).clean()
 
-        if not self.request.user.is_authenticated() or not self.request.user.is_staff:
+        if not self.request.user.is_authenticated or not self.request.user.is_staff:
             raise ValidationError('error')
 
         try:

+ 11 - 11
jet/templatetags/jet_tags.py

@@ -41,12 +41,12 @@ def jet_get_datetime_format():
     return get_format('DATETIME_INPUT_FORMATS')[0]
 
 
-@register.assignment_tag(takes_context=True)
+@register.simple_tag(takes_context=True)
 def jet_get_menu(context):
     return get_menu_items(context)
 
 
-@register.assignment_tag
+@register.simple_tag
 def jet_get_bookmarks(user):
     if user is None:
         return None
@@ -110,7 +110,7 @@ def jet_select2_lookups(field):
     return field
 
 
-@register.assignment_tag(takes_context=True)
+@register.simple_tag(takes_context=True)
 def jet_get_current_theme(context):
     if 'request' in context and 'JET_THEME' in context['request'].COOKIES:
         theme = context['request'].COOKIES['JET_THEME']
@@ -121,12 +121,12 @@ def jet_get_current_theme(context):
     return settings.JET_DEFAULT_THEME
 
 
-@register.assignment_tag
+@register.simple_tag
 def jet_get_themes():
     return settings.JET_THEMES
 
 
-@register.assignment_tag
+@register.simple_tag
 def jet_get_current_version():
     return VERSION
 
@@ -139,12 +139,12 @@ def jet_append_version(url):
         return '%s?v=%s' % (url, VERSION)
 
 
-@register.assignment_tag
+@register.simple_tag
 def jet_get_side_menu_compact():
     return settings.JET_SIDE_MENU_COMPACT
 
 
-@register.assignment_tag
+@register.simple_tag
 def jet_change_form_sibling_links_enabled():
     return settings.JET_CHANGE_FORM_SIBLING_LINKS
 
@@ -198,17 +198,17 @@ def jet_sibling_object(context, next):
     }
 
 
-@register.assignment_tag(takes_context=True)
+@register.simple_tag(takes_context=True)
 def jet_previous_object(context):
     return jet_sibling_object(context, False)
 
 
-@register.assignment_tag(takes_context=True)
+@register.simple_tag(takes_context=True)
 def jet_next_object(context):
     return jet_sibling_object(context, True)
 
 
-@register.assignment_tag(takes_context=True)
+@register.simple_tag(takes_context=True)
 def jet_popup_response_data(context):
     if context.get('popup_response_data'):
         return context['popup_response_data']
@@ -228,7 +228,7 @@ def jet_delete_confirmation_context(context):
     return mark_safe('<div class="delete-confirmation-marker"></div>')
 
 
-@register.assignment_tag
+@register.simple_tag
 def jet_static_translation_urls():
     language_codes = get_possible_language_codes()
 

+ 9 - 3
jet/urls.py

@@ -1,6 +1,13 @@
 import django
 from django.conf.urls import url
-from django.views.i18n import javascript_catalog
+
+try:
+    from django.views.i18n import javascript_catalog
+    jsc_view = javascript_catalog
+except ImportError:
+    from django.views.i18n import JavaScriptCatalog
+    jsc_view = JavaScriptCatalog.as_view()
+
 from jet.views import add_bookmark_view, remove_bookmark_view, toggle_application_pin_view, model_lookup_view
 
 urlpatterns = [
@@ -26,8 +33,7 @@ urlpatterns = [
     ),
     url(
         r'^jsi18n/$',
-        javascript_catalog,
-        {'packages': ('django.conf', 'django.contrib.admin', 'jet',)},
+        jsc_view,
         name='jsi18n'
     ),
 ]

+ 1 - 1
jet/utils.py

@@ -250,7 +250,7 @@ def get_possible_language_codes():
 
 
 def get_original_menu_items(context):
-    if context.get('user') and context['user'].is_authenticated():
+    if context.get('user') and context['user'].is_authenticated:
         pinned_apps = PinnedApplication.objects.filter(user=context['user'].pk).values_list('app_label', flat=True)
     else:
         pinned_apps = []