Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
5c356bd3
Commit
5c356bd3
authored
Jul 22, 2013
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add button to add/remove instructor priviledges on course team page
parent
21a32370
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
16 deletions
+51
-16
cms/djangoapps/contentstore/views/user.py
+10
-8
cms/templates/manage_users.html
+41
-8
No files found.
cms/djangoapps/contentstore/views/user.py
View file @
5c356bd3
import
json
from
django.conf
import
settings
from
django.core.exceptions
import
PermissionDenied
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
,
Group
from
django.contrib.auth.decorators
import
login_required
from
django.views.decorators.http
import
require_http_methods
from
django.utils.translation
import
ugettext
as
_
...
...
@@ -13,8 +13,10 @@ from django.core.context_processors import csrf
from
xmodule.modulestore.django
import
modulestore
from
contentstore.utils
import
get_url_reverse
,
get_lms_link_for_item
from
util.json_request
import
JsonResponse
from
auth.authz
import
STAFF_ROLE_NAME
,
INSTRUCTOR_ROLE_NAME
,
get_users_in_course_group_by_role
from
auth.authz
import
add_user_to_course_group
,
remove_user_from_course_group
from
auth.authz
import
(
STAFF_ROLE_NAME
,
INSTRUCTOR_ROLE_NAME
,
get_users_in_course_group_by_role
,
add_user_to_course_group
,
remove_user_from_course_group
,
get_course_groupname_for_role
)
from
course_creators.views
import
get_course_creator_status
,
add_user_with_status_unrequested
,
user_requested_access
from
.access
import
has_access
...
...
@@ -122,9 +124,9 @@ def course_team_user(request, org, course, name, email):
# all other operations require the requesting user to specify a role --
# or if no role is specified, default to "staff"
if
"role"
in
request
.
POST
:
role
=
request
.
POST
[
"role"
]
el
if
request
.
body
:
if
not
request
.
body
:
role
=
STAFF_ROLE_NAME
el
se
:
try
:
payload
=
json
.
loads
(
request
.
body
)
except
:
...
...
@@ -133,8 +135,8 @@ def course_team_user(request, org, course, name, email):
role
=
payload
[
"role"
]
except
KeyError
:
return
JsonResponse
({
"error"
:
"`role` is required"
},
400
)
else
:
role
=
STAFF_ROLE_NAME
groupname
=
get_course_groupname_for_role
(
location
,
role
)
group
=
Group
.
objects
.
get_or_create
(
name
=
groupname
)
if
request
.
method
in
(
"POST"
,
"PUT"
):
add_user_to_course_group
(
request
.
user
,
user
,
location
,
role
)
...
...
cms/templates/manage_users.html
View file @
5c356bd3
<
%!
from
django
.
utils
.
translation
import
ugettext
as
_
%
>
<
%!
from
django
.
core
.
urlresolvers
import
reverse
%
>
<
%!
from
auth
.
authz
import
is_user_in_course_group_role
%
>
<
%
inherit
file=
"base.html"
/>
<
%
block
name=
"title"
>
${_("Course Team Settings")}
</
%
block>
<
%
block
name=
"bodyclass"
>
is-signedin course users settings team
</
%
block>
...
...
@@ -55,13 +56,21 @@
))}"
>
<span
class=
"user-name"
>
${user.username}
</span>
<span
class=
"user-email"
>
${user.email}
</span>
%
if allow_actions
:
%
if allow_actions
:
<div
class=
"item-actions"
>
%if request.user.id != user.id:
% if request.user.id != user.id:
% if is_user_in_course_group_role(user, context_course.location, 'instructor'):
<
%
admin_class =
"remove-admin"
%
>
<
%
admin_text =
"Remove Admin"
%
>
% else:
<
%
admin_class =
"add-admin"
%
>
<
%
admin_text =
"Add Admin"
%
>
% endif
<a
href=
"#"
class=
"toggle-admin ${admin_class}"
>
${admin_text}
</a>
<a
href=
"#"
class=
"delete-button remove-user"
data-id=
"${user.email}"
><span
class=
"delete-icon"
></span></a>
%endif
%
endif
</div>
%endif
%
endif
</li>
% endfor
</ol>
...
...
@@ -90,9 +99,9 @@
type
:
'POST'
,
dataType
:
'json'
,
contentType
:
'application/json'
,
data
:
{
data
:
JSON
.
stringify
(
{
role
:
'staff'
,
},
}
)
,
success
:
function
(
data
)
{
location
.
reload
();
},
...
...
@@ -131,14 +140,38 @@
type
:
'DELETE'
,
dataType
:
'json'
,
contentType
:
'application/json'
,
data
:
{
data
:
JSON
.
stringify
(
{
role
:
'staff'
,
},
}
)
,
complete
:
function
()
{
location
.
reload
();
}
});
});
$
(
".toggle-admin"
).
click
(
function
(
e
)
{
e
.
preventDefault
()
var
type
;
if
(
$
(
this
).
hasClass
(
"add-admin"
))
{
type
=
'POST'
;
}
else
{
type
=
'DELETE'
;
}
var
url
=
$
(
this
).
closest
(
"li"
).
data
(
"url"
);
$
.
ajax
({
url
:
url
,
type
:
type
,
dataType
:
'json'
,
contentType
:
'application/json'
,
data
:
JSON
.
stringify
({
role
:
'instructor'
,
}),
complete
:
function
()
{
location
.
reload
();
}
})
})
});
</script>
</
%
block>
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