Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
84 additions
and
4 deletions
+84
-4
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
+34
-2
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):
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
):
ACL_LEVELS
=
(
(
'operator'
,
_
(
'operator'
)),
...
...
@@ -210,6 +222,10 @@ if hasattr(settings, 'SAML_ORG_ID_ATTRIBUTE'):
group
,
unicode
(
g
))
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'
,
[])
for
group
in
chain
(
*
[
attributes
[
i
]
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 @@
</td>
</tr>
{% 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>
<td><i
class=
"icon-plus"
></i></td>
<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>
</tr>
</tbody>
</table>
<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"
>
<button
type=
"submit"
class=
"btn btn-success"
>
{% trans "Save" %}
</button>
</div>
...
...
circle/dashboard/urls.py
View file @
ff62083a
...
...
@@ -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
,
...
...
@@ -159,6 +160,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 @
ff62083a
...
...
@@ -74,7 +74,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"
)
...
...
@@ -802,6 +802,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
)
...
...
@@ -835,6 +837,10 @@ class GroupDetailView(CheckedDetailView):
entity
=
User
.
objects
.
get
(
username
=
name
)
self
.
object
.
user_set
.
add
(
entity
)
except
User
.
DoesNotExist
:
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
):
...
...
@@ -1354,6 +1360,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
...
...
@@ -1395,7 +1402,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
():
...
...
@@ -1408,6 +1415,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