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
f6e236a5
Commit
f6e236a5
authored
Feb 03, 2015
by
Matt Drayer
Committed by
Jonathan Piacenti
Aug 20, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mattdrayer/MCKIN-2725: Added support for course roles deletion
parent
ed50d4c6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
1 deletions
+78
-1
lms/djangoapps/api_manager/users/views.py
+2
-1
lms/djangoapps/instructor/receivers.py
+18
-0
lms/djangoapps/instructor/tests/__init__.py
+4
-0
lms/djangoapps/instructor/tests/test_receivers.py
+54
-0
No files found.
lms/djangoapps/api_manager/users/views.py
View file @
f6e236a5
...
...
@@ -1307,7 +1307,8 @@ class UsersRolesList(SecureListAPIView):
for
current_role
in
current_roles
:
if
current_role
.
role
not
in
ignore_roles
:
course_descriptor
,
course_key
,
course_content
=
get_course
(
request
,
user
,
unicode
(
current_role
.
course_id
))
# pylint: disable=W0612
_manage_role
(
course_descriptor
,
user
,
current_role
.
role
,
'revoke'
)
if
course_descriptor
:
_manage_role
(
course_descriptor
,
user
,
current_role
.
role
,
'revoke'
)
for
role
in
request
.
DATA
[
'roles'
]:
if
role
[
'role'
]
not
in
ignore_roles
:
try
:
...
...
lms/djangoapps/instructor/receivers.py
0 → 100644
View file @
f6e236a5
"""
Signal handlers supporting various gradebook use cases
"""
from
django.dispatch
import
receiver
from
util.signals
import
course_deleted
from
student.models
import
CourseAccessRole
@receiver
(
course_deleted
)
def
on_course_deleted
(
sender
,
**
kwargs
):
# pylint: disable=W0613
"""
Listens for a 'course_deleted' signal and when observed
removes model entries for the specified course
"""
course_key
=
kwargs
[
'course_key'
]
CourseAccessRole
.
objects
.
filter
(
course_id
=
course_key
)
.
delete
()
lms/djangoapps/instructor/tests/__init__.py
View file @
f6e236a5
"""
Initialization module for instructor djangoapp
"""
import
instructor.receivers
lms/djangoapps/instructor/tests/test_receivers.py
0 → 100644
View file @
f6e236a5
# pylint: disable=E1101
"""
Run these tests @ Devstack:
paver test_system -s lms --test_id=lms/djangoapps/gradebook/tests.py
"""
from
datetime
import
datetime
import
uuid
from
django.contrib.auth.models
import
Group
,
User
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
util.signals
import
course_deleted
from
student.models
import
CourseAccessRole
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
class
InstructorReceiversTests
(
TestCase
):
""" Test suite for signal receivers """
def
setUp
(
self
):
# Create a course to work with
self
.
course
=
CourseFactory
.
create
(
start
=
datetime
(
2014
,
6
,
16
,
14
,
30
),
end
=
datetime
(
2015
,
1
,
16
)
)
test_data
=
'<html>{}</html>'
.
format
(
str
(
uuid
.
uuid4
()))
self
.
chapter
=
ItemFactory
.
create
(
category
=
"chapter"
,
parent_location
=
self
.
course
.
location
,
data
=
test_data
,
due
=
datetime
(
2014
,
5
,
16
,
14
,
30
),
display_name
=
"Overview"
)
self
.
user
=
User
.
objects
.
create
(
email
=
'testuser@edx.org'
,
username
=
'testuser'
,
password
=
'testpassword'
,
is_active
=
True
)
def
test_receiver_on_course_deleted
(
self
):
"""
Test the workflow
"""
# Set up the data to be removed
CourseAccessRole
.
objects
.
create
(
course_id
=
self
.
course
.
id
,
user
=
self
.
user
,
role
=
'instructor'
)
# Emit the signal
course_deleted
.
send
(
sender
=
None
,
course_key
=
self
.
course
.
id
)
# Validate that the course references were removed
self
.
assertEqual
(
CourseAccessRole
.
objects
.
filter
(
course_id
=
self
.
course
.
id
)
.
count
(),
0
)
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