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
ff62083a
authored
Jul 04, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-future-member' into 'master'
Feature Future Member fixes #59
parents
f816770a
379fd1bd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
85 additions
and
5 deletions
+85
-5
circle/dashboard/migrations/0010_auto__add_futuremember__add_unique_futuremember_org_id_group.py
+0
-0
circle/dashboard/models.py
+16
-0
circle/dashboard/templates/dashboard/confirm/base-remove.html
+14
-0
circle/dashboard/templates/dashboard/group-detail.html
+16
-2
circle/dashboard/urls.py
+4
-0
circle/dashboard/views.py
+35
-3
No files found.
circle/dashboard/migrations/0010_auto__add_futuremember__add_unique_futuremember_org_id_group.py
0 → 100644
View file @
ff62083a
This diff is collapsed.
Click to expand it.
circle/dashboard/models.py
View file @
ff62083a
...
@@ -126,6 +126,18 @@ class Profile(Model):
...
@@ -126,6 +126,18 @@ class Profile(Model):
return
self
.
get_display_name
()
return
self
.
get_display_name
()
class
FutureMember
(
Model
):
org_id
=
CharField
(
max_length
=
64
,
help_text
=
_
(
'Unique identifier of the person, e.g. a student number.'
))
group
=
ForeignKey
(
Group
)
class
Meta
:
unique_together
=
(
'org_id'
,
'group'
)
def
__unicode__
(
self
):
return
u"
%
s (
%
s)"
%
(
self
.
org_id
,
self
.
group
)
class
GroupProfile
(
AclBase
):
class
GroupProfile
(
AclBase
):
ACL_LEVELS
=
(
ACL_LEVELS
=
(
(
'operator'
,
_
(
'operator'
)),
(
'operator'
,
_
(
'operator'
)),
...
@@ -210,6 +222,10 @@ if hasattr(settings, 'SAML_ORG_ID_ATTRIBUTE'):
...
@@ -210,6 +222,10 @@ if hasattr(settings, 'SAML_ORG_ID_ATTRIBUTE'):
group
,
unicode
(
g
))
group
,
unicode
(
g
))
g
.
user_set
.
add
(
sender
)
g
.
user_set
.
add
(
sender
)
for
i
in
FutureMember
.
objects
.
filter
(
org_id
=
value
):
i
.
group
.
user_set
.
add
(
sender
)
i
.
delete
()
owneratrs
=
getattr
(
settings
,
'SAML_GROUP_OWNER_ATTRIBUTES'
,
[])
owneratrs
=
getattr
(
settings
,
'SAML_GROUP_OWNER_ATTRIBUTES'
,
[])
for
group
in
chain
(
*
[
attributes
[
i
]
for
group
in
chain
(
*
[
attributes
[
i
]
for
i
in
owneratrs
if
i
in
attributes
]):
for
i
in
owneratrs
if
i
in
attributes
]):
...
...
circle/dashboard/templates/dashboard/confirm/base-remove.html
0 → 100644
View file @
ff62083a
{% extends "base.html" %}
{% load i18n %}
{% block title-site %}Dashboard | CIRCLE{% endblock %}
{% block content %}
{% blocktrans with group=object member=member %}
Do you really want to remove {{member}} from {{group}}?
{% endblocktrans %}
<form
action=
""
method=
"POST"
>
{% csrf_token %}
<input
type=
"submit"
value=
"{% trans "
Remove
"
%}"
/>
</form>
{% endblock %}
circle/dashboard/templates/dashboard/group-detail.html
View file @
ff62083a
...
@@ -71,16 +71,30 @@
...
@@ -71,16 +71,30 @@
</td>
</td>
</tr>
</tr>
{% endfor %}
{% endfor %}
{% for i in future_users %}
<tr>
<td>
<i
class=
"icon-user text-muted"
></i>
</td>
<td>
{{ i.org_id }}
</td>
<td>
<a
href=
"{% url "
dashboard
.
views
.
remove-future-user
"
member_org_id=
i.org_id
group_pk=
group.pk
%}"
class=
"real-link btn-link btn-xs"
>
<i
class=
"icon-remove"
><span
class=
"sr-only"
>
{% trans "remove" %}
</span></i></a>
</td>
</tr>
{% endfor %}
<tr>
<tr>
<td><i
class=
"icon-plus"
></i></td>
<td><i
class=
"icon-plus"
></i></td>
<td
colspan=
"2"
>
<td
colspan=
"2"
>
<input
type=
"text"
class=
"form-control"
name=
"list-new-name"
placeholder=
"{% trans "
Name
of
user
"
%}"
>
<input
type=
"text"
class=
"form-control"
name=
"list-new-name"
placeholder=
"{% trans "
Name
of
user
"
%}"
>
</td>
</td>
</tr>
</tr>
</tbody>
</tbody>
</table>
</table>
<textarea
name=
"list-new-namelist"
class=
"form-control"
<textarea
name=
"list-new-namelist"
class=
"form-control"
placeholder=
"{% trans "
List
of
usernames
(
one
per
line
)."
%}"
></textarea>
placeholder=
"{% trans "
Add
multiple
users
at
once
(
one
identifier
per
line
)."
%}"
></textarea>
<div
class=
"form-actions"
>
<div
class=
"form-actions"
>
<button
type=
"submit"
class=
"btn btn-success"
>
{% trans "Save" %}
</button>
<button
type=
"submit"
class=
"btn btn-success"
>
{% trans "Save" %}
</button>
</div>
</div>
...
...
circle/dashboard/urls.py
View file @
ff62083a
...
@@ -31,6 +31,7 @@ from .views import (
...
@@ -31,6 +31,7 @@ from .views import (
VmDetailVncTokenView
,
VmGraphView
,
VmList
,
VmMassDelete
,
VmMigrateView
,
VmDetailVncTokenView
,
VmGraphView
,
VmList
,
VmMassDelete
,
VmMigrateView
,
VmRenewView
,
DiskRemoveView
,
get_disk_download_status
,
InterfaceDeleteView
,
VmRenewView
,
DiskRemoveView
,
get_disk_download_status
,
InterfaceDeleteView
,
GroupRemoveAclUserView
,
GroupRemoveAclGroupView
,
GroupRemoveUserView
,
GroupRemoveAclUserView
,
GroupRemoveAclGroupView
,
GroupRemoveUserView
,
GroupRemoveFutureUserView
,
GroupCreate
,
GroupProfileUpdate
,
GroupCreate
,
GroupProfileUpdate
,
TemplateChoose
,
TemplateChoose
,
UserCreationView
,
UserCreationView
,
...
@@ -159,6 +160,9 @@ urlpatterns = patterns(
...
@@ -159,6 +160,9 @@ urlpatterns = patterns(
url
(
r'^group/(?P<group_pk>\d+)/remove/user/(?P<member_pk>\d+)/$'
,
url
(
r'^group/(?P<group_pk>\d+)/remove/user/(?P<member_pk>\d+)/$'
,
GroupRemoveUserView
.
as_view
(),
GroupRemoveUserView
.
as_view
(),
name
=
"dashboard.views.remove-user"
),
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
(),
url
(
r'^group/create/$'
,
GroupCreate
.
as_view
(),
name
=
'dashboard.views.group-create'
),
name
=
'dashboard.views.group-create'
),
url
(
r'^group/(?P<group_pk>\d+)/create/$'
,
url
(
r'^group/(?P<group_pk>\d+)/create/$'
,
...
...
circle/dashboard/views.py
View file @
ff62083a
...
@@ -74,7 +74,7 @@ from vm.models import (
...
@@ -74,7 +74,7 @@ from vm.models import (
)
)
from
storage.models
import
Disk
from
storage.models
import
Disk
from
firewall.models
import
Vlan
,
Host
,
Rule
from
firewall.models
import
Vlan
,
Host
,
Rule
from
.models
import
Favourite
,
Profile
,
GroupProfile
from
.models
import
Favourite
,
Profile
,
GroupProfile
,
FutureMember
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
saml_available
=
hasattr
(
settings
,
"SAML_CONFIG"
)
saml_available
=
hasattr
(
settings
,
"SAML_CONFIG"
)
...
@@ -802,6 +802,8 @@ class GroupDetailView(CheckedDetailView):
...
@@ -802,6 +802,8 @@ class GroupDetailView(CheckedDetailView):
context
=
super
(
GroupDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
context
=
super
(
GroupDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
context
[
'group'
]
=
self
.
object
context
[
'group'
]
=
self
.
object
context
[
'users'
]
=
self
.
object
.
user_set
.
all
()
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
[
'acl'
]
=
get_group_acl_data
(
self
.
object
)
context
[
'group_profile_form'
]
=
GroupProfileUpdate
.
get_form_object
(
context
[
'group_profile_form'
]
=
GroupProfileUpdate
.
get_form_object
(
self
.
request
,
self
.
object
.
profile
)
self
.
request
,
self
.
object
.
profile
)
...
@@ -835,7 +837,11 @@ class GroupDetailView(CheckedDetailView):
...
@@ -835,7 +837,11 @@ class GroupDetailView(CheckedDetailView):
entity
=
User
.
objects
.
get
(
username
=
name
)
entity
=
User
.
objects
.
get
(
username
=
name
)
self
.
object
.
user_set
.
add
(
entity
)
self
.
object
.
user_set
.
add
(
entity
)
except
User
.
DoesNotExist
:
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
):
def
__add_list
(
self
,
request
):
if
not
self
.
get_has_level
()(
request
.
user
,
'operator'
):
if
not
self
.
get_has_level
()(
request
.
user
,
'operator'
):
...
@@ -1354,6 +1360,7 @@ class GroupRemoveUserView(CheckedDetailView, DeleteView):
...
@@ -1354,6 +1360,7 @@ class GroupRemoveUserView(CheckedDetailView, DeleteView):
slug_field
=
'pk'
slug_field
=
'pk'
slug_url_kwarg
=
'group_pk'
slug_url_kwarg
=
'group_pk'
read_level
=
'operator'
read_level
=
'operator'
member_key
=
'member_pk'
def
get_has_level
(
self
):
def
get_has_level
(
self
):
return
self
.
object
.
profile
.
has_level
return
self
.
object
.
profile
.
has_level
...
@@ -1395,7 +1402,7 @@ class GroupRemoveUserView(CheckedDetailView, DeleteView):
...
@@ -1395,7 +1402,7 @@ class GroupRemoveUserView(CheckedDetailView, DeleteView):
object
=
self
.
get_object
()
object
=
self
.
get_object
()
if
not
object
.
profile
.
has_level
(
request
.
user
,
'operator'
):
if
not
object
.
profile
.
has_level
(
request
.
user
,
'operator'
):
raise
PermissionDenied
()
raise
PermissionDenied
()
self
.
remove_member
(
kwargs
[
"member_pk"
])
self
.
remove_member
(
kwargs
[
self
.
member_key
])
success_url
=
self
.
get_success_url
()
success_url
=
self
.
get_success_url
()
success_message
=
self
.
get_success_message
()
success_message
=
self
.
get_success_message
()
if
request
.
is_ajax
():
if
request
.
is_ajax
():
...
@@ -1408,6 +1415,31 @@ class GroupRemoveUserView(CheckedDetailView, DeleteView):
...
@@ -1408,6 +1415,31 @@ class GroupRemoveUserView(CheckedDetailView, DeleteView):
return
HttpResponseRedirect
(
success_url
)
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
):
class
GroupRemoveAclUserView
(
GroupRemoveUserView
):
def
remove_member
(
self
,
pk
):
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