Skip to content

Commit

Permalink
Add dashboard views is_staff checks
Browse files Browse the repository at this point in the history
  • Loading branch information
f1nality committed Dec 3, 2016
1 parent bd86a24 commit 8c63bb4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions jet/dashboard/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, request, *args, **kwargs):
def clean(self):
data = super(UpdateDashboardModulesForm, self).clean()

if not self.request.user.is_authenticated():
if not self.request.user.is_authenticated() or not self.request.user.is_staff:
raise ValidationError('error')

try:
Expand Down Expand Up @@ -68,7 +68,7 @@ def clean_app_label(self):
def clean(self):
data = super(AddUserDashboardModuleForm, self).clean()

if not self.request.user.is_authenticated():
if not self.request.user.is_authenticated() or not self.request.user.is_staff:
raise ValidationError('error')

if 'app_label' in data:
Expand Down Expand Up @@ -110,7 +110,10 @@ class Meta:
def clean(self):
data = super(UpdateDashboardModuleCollapseForm, 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 not self.request.user.is_staff:
raise ValidationError('error')

if self.instance.user != self.request.user.pk:
raise ValidationError('error')

return data
Expand Down Expand Up @@ -153,7 +156,7 @@ def clean(self):
data = super(ResetDashboardForm, self).clean()
data['app_label'] = data['app_label'] if data['app_label'] else None

if not self.request.user.is_authenticated():
if not self.request.user.is_authenticated() or not self.request.user.is_staff:
raise ValidationError('error')

return data
Expand Down

0 comments on commit 8c63bb4

Please sign in to comment.