Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
684d7a89
authored
Jun 26, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: handle future users in view
parent
a76c9e7d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
3 deletions
+39
-3
circle/dashboard/urls.py
+4
-0
circle/dashboard/views.py
+35
-3
No files found.
circle/dashboard/urls.py
View file @
684d7a89
...
...
@@ -31,6 +31,7 @@ from .views import (
VmDetailVncTokenView
,
VmGraphView
,
VmList
,
VmMassDelete
,
VmMigrateView
,
VmRenewView
,
DiskRemoveView
,
get_disk_download_status
,
InterfaceDeleteView
,
GroupRemoveAclUserView
,
GroupRemoveAclGroupView
,
GroupRemoveUserView
,
GroupRemoveFutureUserView
,
GroupCreate
,
GroupProfileUpdate
,
TemplateChoose
,
UserCreationView
,
...
...
@@ -154,6 +155,9 @@ urlpatterns = patterns(
url
(
r'^group/(?P<group_pk>\d+)/remove/user/(?P<member_pk>\d+)/$'
,
GroupRemoveUserView
.
as_view
(),
name
=
"dashboard.views.remove-user"
),
url
(
r'^group/(?P<group_pk>\d+)/remove/futureuser/(?P<member_org_id>.+)/$'
,
GroupRemoveFutureUserView
.
as_view
(),
name
=
"dashboard.views.remove-future-user"
),
url
(
r'^group/create/$'
,
GroupCreate
.
as_view
(),
name
=
'dashboard.views.group-create'
),
url
(
r'^group/(?P<group_pk>\d+)/create/$'
,
...
...
circle/dashboard/views.py
View file @
684d7a89
...
...
@@ -73,7 +73,7 @@ from vm.models import (
)
from
storage.models
import
Disk
from
firewall.models
import
Vlan
,
Host
,
Rule
from
.models
import
Favourite
,
Profile
,
GroupProfile
from
.models
import
Favourite
,
Profile
,
GroupProfile
,
FutureMember
logger
=
logging
.
getLogger
(
__name__
)
saml_available
=
hasattr
(
settings
,
"SAML_CONFIG"
)
...
...
@@ -756,6 +756,8 @@ class GroupDetailView(CheckedDetailView):
context
=
super
(
GroupDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
context
[
'group'
]
=
self
.
object
context
[
'users'
]
=
self
.
object
.
user_set
.
all
()
context
[
'future_users'
]
=
FutureMember
.
objects
.
filter
(
group
=
self
.
object
)
context
[
'acl'
]
=
get_group_acl_data
(
self
.
object
)
context
[
'group_profile_form'
]
=
GroupProfileUpdate
.
get_form_object
(
self
.
request
,
self
.
object
.
profile
)
...
...
@@ -789,7 +791,11 @@ class GroupDetailView(CheckedDetailView):
entity
=
User
.
objects
.
get
(
username
=
name
)
self
.
object
.
user_set
.
add
(
entity
)
except
User
.
DoesNotExist
:
warning
(
request
,
_
(
'User "
%
s" not found.'
)
%
name
)
if
saml_available
:
FutureMember
.
objects
.
get_or_create
(
org_id
=
name
,
group
=
self
.
object
)
else
:
warning
(
request
,
_
(
'User "
%
s" not found.'
)
%
name
)
def
__add_list
(
self
,
request
):
if
not
self
.
get_has_level
()(
request
.
user
,
'operator'
):
...
...
@@ -1308,6 +1314,7 @@ class GroupRemoveUserView(CheckedDetailView, DeleteView):
slug_field
=
'pk'
slug_url_kwarg
=
'group_pk'
read_level
=
'operator'
member_key
=
'member_pk'
def
get_has_level
(
self
):
return
self
.
object
.
profile
.
has_level
...
...
@@ -1349,7 +1356,7 @@ class GroupRemoveUserView(CheckedDetailView, DeleteView):
object
=
self
.
get_object
()
if
not
object
.
profile
.
has_level
(
request
.
user
,
'operator'
):
raise
PermissionDenied
()
self
.
remove_member
(
kwargs
[
"member_pk"
])
self
.
remove_member
(
kwargs
[
self
.
member_key
])
success_url
=
self
.
get_success_url
()
success_message
=
self
.
get_success_message
()
if
request
.
is_ajax
():
...
...
@@ -1362,6 +1369,31 @@ class GroupRemoveUserView(CheckedDetailView, DeleteView):
return
HttpResponseRedirect
(
success_url
)
class
GroupRemoveFutureUserView
(
GroupRemoveUserView
):
member_key
=
'member_org_id'
def
get
(
self
,
request
,
member_org_id
,
*
args
,
**
kwargs
):
self
.
member_org_id
=
member_org_id
return
super
(
GroupRemoveUserView
,
self
)
.
get
(
request
,
*
args
,
**
kwargs
)
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
GroupRemoveUserView
,
self
)
.
get_context_data
(
**
kwargs
)
try
:
context
[
'member'
]
=
FutureMember
.
objects
.
get
(
org_id
=
self
.
member_org_id
,
group
=
self
.
get_object
())
except
FutureMember
.
DoesNotExist
:
raise
Http404
()
return
context
def
remove_member
(
self
,
org_id
):
FutureMember
.
objects
.
filter
(
org_id
=
org_id
,
group
=
self
.
get_object
())
.
delete
()
def
get_success_message
(
self
):
return
_
(
"Future user successfully removed from group."
)
class
GroupRemoveAclUserView
(
GroupRemoveUserView
):
def
remove_member
(
self
,
pk
):
...
...
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