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
2c60a1d5
Commit
2c60a1d5
authored
Feb 09, 2015
by
Will Daly
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6934 from edx/will/fix-embargo-migration
Fix embargo migration to the new data models.
parents
78deaed2
7e746f7d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
common/djangoapps/embargo/migrations/0004_migrate_embargo_config.py
+8
-2
No files found.
common/djangoapps/embargo/migrations/0004_migrate_embargo_config.py
View file @
2c60a1d5
...
...
@@ -11,13 +11,16 @@ class Migration(DataMigration):
for
old_course
in
orm
.
EmbargoedCourse
.
objects
.
all
():
new_course
,
__
=
orm
.
RestrictedCourse
.
objects
.
get_or_create
(
course_key
=
old_course
.
course_id
)
# Set the message keys to 'embargo'
new_course
.
enroll_msg_key
=
'embargo'
new_course
.
access_msg_key
=
'embargo'
new_course
.
save
()
for
country
in
self
.
_embargoed_countries_list
(
orm
):
country_model
=
orm
.
Country
.
objects
.
get
(
country
=
country
)
orm
.
CountryAccessRule
.
objects
.
get_or_create
(
country
=
country_model
,
rule_type
=
'blacklist'
,
enroll_msg_key
=
'embargo'
,
access_msg_key
=
'embargo'
,
restricted_course
=
new_course
)
...
...
@@ -31,11 +34,14 @@ class Migration(DataMigration):
# doesn't give us access to class methods on the Django model objects.
try
:
current_config
=
orm
.
EmbargoedState
.
objects
.
order_by
(
'-change_date'
)[
0
]
if
current_config
.
enabled
and
current_config
.
embargoed_countries
:
return
[
country
.
strip
()
.
upper
()
for
country
in
current_config
.
embargoed_countries
.
split
(
','
)
]
except
IndexError
:
pass
return
[]
models
=
{
...
...
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