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
f4aad11e
authored
Feb 09, 2013
by
Dányi Bence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
school: group management (add/remove individual users)
parent
2485bb32
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
1 deletions
+38
-1
cloud/urls.py
+2
-0
school/templates/show-group.html
+6
-1
school/views.py
+30
-0
No files found.
cloud/urls.py
View file @
f4aad11e
...
@@ -45,4 +45,6 @@ urlpatterns = patterns('',
...
@@ -45,4 +45,6 @@ urlpatterns = patterns('',
url
(
r'^b/(?P<token>.*)/$'
,
'one.views.boot_token'
,
name
=
'boot_token'
),
url
(
r'^b/(?P<token>.*)/$'
,
'one.views.boot_token'
,
name
=
'boot_token'
),
url
(
r'^group/show/(?P<gid>\d+)/$'
,
'school.views.group_show'
,
name
=
'group_show'
),
url
(
r'^group/show/(?P<gid>\d+)/$'
,
'school.views.group_show'
,
name
=
'group_show'
),
url
(
r'^group/new/$'
,
'school.views.group_new'
,
name
=
'group_new'
),
url
(
r'^group/new/$'
,
'school.views.group_new'
,
name
=
'group_new'
),
url
(
r'^ajax/group/(?P<gid>\d+)/add/$'
,
'school.views.group_ajax_add_new_member'
,
name
=
'group_ajax_add_new_member'
),
url
(
r'^ajax/group/(?P<gid>\d+)/remove/$'
,
'school.views.group_ajax_remove_member'
,
name
=
'group_ajax_remove_member'
),
)
)
school/templates/show-group.html
View file @
f4aad11e
...
@@ -19,6 +19,11 @@
...
@@ -19,6 +19,11 @@
{{member}} ({{member.code}})
{{member}} ({{member.code}})
{% endif %}
{% endif %}
</div>
</div>
<div
class=
"actions"
>
<a
href=
"#"
class=
"remove"
data-gid=
"{{group.id}}"
data-neptun=
"{{member.code}}"
>
<img
src=
"/static/icons/minus-circle.png"
alt=
"{% trans 'Remove' %}"
/>
</a>
</div>
<div
class=
"clear"
></div>
<div
class=
"clear"
></div>
</div>
</div>
<div
class=
"details"
>
<div
class=
"details"
>
...
@@ -37,7 +42,7 @@
...
@@ -37,7 +42,7 @@
<div
class=
"name"
>
{% trans "Add user" %}
</div>
<div
class=
"name"
>
{% trans "Add user" %}
</div>
<div
id=
"new-member-form"
>
<div
id=
"new-member-form"
>
<input
type=
"text"
placeholder=
"{% trans "
User
NEPTUN
code
"
%}"
/>
<input
type=
"text"
placeholder=
"{% trans "
User
NEPTUN
code
"
%}"
/>
<input
type=
"submit"
value=
"{% trans "
Add
user
"
%}"
/>
<input
type=
"submit"
value=
"{% trans "
Add
user
"
%}"
data-id=
"{{group.id}}"
/>
</div>
</div>
<div
class=
"clear"
></div>
<div
class=
"clear"
></div>
</div>
</div>
...
...
school/views.py
View file @
f4aad11e
...
@@ -169,3 +169,33 @@ def group_new(request):
...
@@ -169,3 +169,33 @@ def group_new(request):
group
.
owners
.
add
(
owner
)
group
.
owners
.
add
(
owner
)
group
.
save
()
group
.
save
()
return
redirect
(
'/group/show/
%
s'
%
group
.
id
)
return
redirect
(
'/group/show/
%
s'
%
group
.
id
)
@login_required
def
group_ajax_add_new_member
(
request
,
gid
):
group
=
get_object_or_404
(
Group
,
id
=
gid
)
member
=
request
.
POST
[
'neptun'
]
if
re
.
match
(
'^[a-zA-Z][a-zA-Z0-9]{5}$'
,
member
)
==
None
:
status
=
json
.
dumps
({
'status'
:
'Error'
})
messages
.
error
(
request
,
_
(
'Invalid NEPTUN code'
))
return
HttpResponse
(
status
)
person
,
created
=
Person
.
objects
.
get_or_create
(
code
=
member
)
group
.
members
.
add
(
person
)
group
.
save
()
return
HttpResponse
(
json
.
dumps
({
'status'
:
'OK'
}))
@login_required
def
group_ajax_remove_member
(
request
,
gid
):
group
=
get_object_or_404
(
Group
,
id
=
gid
)
member
=
request
.
POST
[
'neptun'
]
if
re
.
match
(
'^[a-zA-Z][a-zA-Z0-9]{5}$'
,
member
)
==
None
:
status
=
json
.
dumps
({
'status'
:
'Error'
})
messages
.
error
(
request
,
_
(
'Invalid NEPTUN code'
))
return
HttpResponse
(
status
)
person
,
created
=
Person
.
objects
.
get_or_create
(
code
=
member
)
group
.
members
.
remove
(
person
)
group
.
save
()
return
HttpResponse
(
json
.
dumps
({
'status'
:
'OK'
}))
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