Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
fcf7744c
authored
May 28, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: use PermissionRequiredMixin in UserCreationView
parent
fbb9f2aa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
6 deletions
+5
-6
circle/dashboard/views.py
+5
-6
No files found.
circle/dashboard/views.py
View file @
fcf7744c
...
...
@@ -48,7 +48,8 @@ from django.template import RequestContext
from
django.forms.models
import
inlineformset_factory
from
django_tables2
import
SingleTableView
from
braces.views
import
LoginRequiredMixin
,
SuperuserRequiredMixin
from
braces.views
import
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
PermissionRequiredMixin
)
from
braces.views._access
import
AccessMixin
from
.forms
import
(
...
...
@@ -2577,10 +2578,12 @@ class InstanceActivityDetail(SuperuserRequiredMixin, DetailView):
return
ctx
class
UserCreationView
(
CreateView
):
class
UserCreationView
(
LoginRequiredMixin
,
PermissionRequiredMixin
,
CreateView
):
form_class
=
UserCreationForm
model
=
User
template_name
=
'dashboard/user-create.html'
permission_required
=
"auth.add_user"
def
get_group
(
self
,
group_pk
):
self
.
group
=
get_object_or_404
(
Group
,
pk
=
group_pk
)
...
...
@@ -2588,14 +2591,10 @@ class UserCreationView(CreateView):
raise
PermissionDenied
()
def
get
(
self
,
*
args
,
**
kwargs
):
if
not
self
.
request
.
user
.
has_perm
(
'auth.add_user'
):
raise
PermissionDenied
()
self
.
get_group
(
kwargs
.
pop
(
'group_pk'
))
return
super
(
UserCreationView
,
self
)
.
get
(
*
args
,
**
kwargs
)
def
post
(
self
,
*
args
,
**
kwargs
):
if
not
self
.
request
.
user
.
has_perm
(
'auth.add_user'
):
raise
PermissionDenied
()
group_pk
=
kwargs
.
pop
(
'group_pk'
)
self
.
get_group
(
group_pk
)
ret
=
super
(
UserCreationView
,
self
)
.
post
(
*
args
,
**
kwargs
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment