|
@@ -3,6 +3,7 @@ from django import forms
|
|
|
from django.core.exceptions import ValidationError
|
|
|
from jet.dashboard.models import UserDashboardModule
|
|
|
from jet.dashboard.utils import get_current_dashboard
|
|
|
+from jet.utils import user_is_authenticated
|
|
|
|
|
|
|
|
|
class UpdateDashboardModulesForm(forms.Form):
|
|
@@ -17,7 +18,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 user_is_authenticated(self.request.user) or not self.request.user.is_staff:
|
|
|
raise ValidationError('error')
|
|
|
|
|
|
try:
|
|
@@ -68,7 +69,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 user_is_authenticated(self.request.user) or not self.request.user.is_staff:
|
|
|
raise ValidationError('error')
|
|
|
|
|
|
if 'app_label' in data:
|
|
@@ -110,7 +111,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 user_is_authenticated(self.request.user) or not self.request.user.is_staff:
|
|
|
raise ValidationError('error')
|
|
|
|
|
|
if self.instance.user != self.request.user.pk:
|
|
@@ -131,7 +132,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 user_is_authenticated(self.request.user) or self.instance.user != self.request.user.pk:
|
|
|
raise ValidationError('error')
|
|
|
|
|
|
return cleaned_data
|
|
@@ -156,7 +157,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 user_is_authenticated(self.request.user) or not self.request.user.is_staff:
|
|
|
raise ValidationError('error')
|
|
|
|
|
|
return data
|