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
ba9ef89e
Commit
ba9ef89e
authored
8 years ago
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix CCX migration to be resilient to course-not-found
parent
4d301b9b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
lms/djangoapps/ccx/migrations/0005_change_ccx_coach_to_staff.py
+12
-3
lms/djangoapps/courseware/courses.py
+1
-1
No files found.
lms/djangoapps/ccx/migrations/0005_change_ccx_coach_to_staff.py
View file @
ba9ef89e
...
@@ -4,10 +4,11 @@ import logging
...
@@ -4,10 +4,11 @@ import logging
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.db
import
migrations
from
django.db
import
migrations
from
django.http
import
Http404
from
ccx_keys.locator
import
CCXLocator
from
ccx_keys.locator
import
CCXLocator
from
courseware.courses
import
get_course_by_id
from
instructor.access
import
allow_access
,
revoke_access
from
instructor.access
import
allow_access
,
revoke_access
from
lms.djangoapps.ccx.utils
import
ccx_course
log
=
logging
.
getLogger
(
"edx.ccx"
)
log
=
logging
.
getLogger
(
"edx.ccx"
)
...
@@ -31,7 +32,11 @@ def change_existing_ccx_coaches_to_staff(apps, schema_editor):
...
@@ -31,7 +32,11 @@ def change_existing_ccx_coaches_to_staff(apps, schema_editor):
list_ccx
=
CustomCourseForEdX
.
objects
.
using
(
db_alias
)
.
all
()
list_ccx
=
CustomCourseForEdX
.
objects
.
using
(
db_alias
)
.
all
()
for
ccx
in
list_ccx
:
for
ccx
in
list_ccx
:
ccx_locator
=
CCXLocator
.
from_course_locator
(
ccx
.
course_id
,
unicode
(
ccx
.
id
))
ccx_locator
=
CCXLocator
.
from_course_locator
(
ccx
.
course_id
,
unicode
(
ccx
.
id
))
with
ccx_course
(
ccx_locator
)
as
course
:
try
:
course
=
get_course_by_id
(
ccx_locator
)
except
Http404
:
log
.
error
(
'Could not migrate access for CCX course:
%
s'
,
unicode
(
ccx_locator
))
else
:
coach
=
User
.
objects
.
get
(
id
=
ccx
.
coach
.
id
)
coach
=
User
.
objects
.
get
(
id
=
ccx
.
coach
.
id
)
allow_access
(
course
,
coach
,
'staff'
,
send_email
=
False
)
allow_access
(
course
,
coach
,
'staff'
,
send_email
=
False
)
revoke_access
(
course
,
coach
,
'ccx_coach'
,
send_email
=
False
)
revoke_access
(
course
,
coach
,
'ccx_coach'
,
send_email
=
False
)
...
@@ -57,7 +62,11 @@ def revert_ccx_staff_to_coaches(apps, schema_editor):
...
@@ -57,7 +62,11 @@ def revert_ccx_staff_to_coaches(apps, schema_editor):
list_ccx
=
CustomCourseForEdX
.
objects
.
using
(
db_alias
)
.
all
()
list_ccx
=
CustomCourseForEdX
.
objects
.
using
(
db_alias
)
.
all
()
for
ccx
in
list_ccx
:
for
ccx
in
list_ccx
:
ccx_locator
=
CCXLocator
.
from_course_locator
(
ccx
.
course_id
,
unicode
(
ccx
.
id
))
ccx_locator
=
CCXLocator
.
from_course_locator
(
ccx
.
course_id
,
unicode
(
ccx
.
id
))
with
ccx_course
(
ccx_locator
)
as
course
:
try
:
course
=
get_course_by_id
(
ccx_locator
)
except
Http404
:
log
.
error
(
'Could not migrate access for CCX course:
%
s'
,
unicode
(
ccx_locator
))
else
:
coach
=
User
.
objects
.
get
(
id
=
ccx
.
coach
.
id
)
coach
=
User
.
objects
.
get
(
id
=
ccx
.
coach
.
id
)
allow_access
(
course
,
coach
,
'ccx_coach'
,
send_email
=
False
)
allow_access
(
course
,
coach
,
'ccx_coach'
,
send_email
=
False
)
revoke_access
(
course
,
coach
,
'staff'
,
send_email
=
False
)
revoke_access
(
course
,
coach
,
'staff'
,
send_email
=
False
)
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/courseware/courses.py
View file @
ba9ef89e
...
@@ -70,7 +70,7 @@ def get_course_by_id(course_key, depth=0):
...
@@ -70,7 +70,7 @@ def get_course_by_id(course_key, depth=0):
if
course
:
if
course
:
return
course
return
course
else
:
else
:
raise
Http404
(
"Course not found
."
)
raise
Http404
(
"Course not found
: {}."
.
format
(
unicode
(
course_key
))
)
class
UserNotEnrolled
(
Http404
):
class
UserNotEnrolled
(
Http404
):
...
...
This diff is collapsed.
Click to expand it.
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