Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-val
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-val
Commits
5a9da6d0
Commit
5a9da6d0
authored
Nov 09, 2015
by
Ned Batchelder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert the data migration to a Django migration
parent
2e0bfb88
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
23 deletions
+39
-23
edxval/migrations/0001_initial.py
+0
-23
edxval/migrations/0002_data__default_profiles.py
+39
-0
No files found.
edxval/migrations/0001_initial.py
View file @
5a9da6d0
...
...
@@ -6,28 +6,6 @@ import django.core.validators
import
edxval.models
def
forwards_default_profiles
(
apps
,
schema_editor
):
""" Add default profiles """
Profile
=
apps
.
get_model
(
"edxval"
,
"Profile"
)
db_alias
=
schema_editor
.
connection
.
alias
Profile
.
objects
.
using
(
db_alias
)
.
bulk_create
([
Profile
(
profile_name
=
"desktop_mp4"
),
Profile
(
profile_name
=
"desktop_webm"
),
Profile
(
profile_name
=
"mobile_high"
),
Profile
(
profile_name
=
"mobile_low"
),
Profile
(
profile_name
=
"youtube"
),
])
def
reverse_default_profiles
(
apps
,
schema_editor
):
""" Remove default profiles """
Profile
=
apps
.
get_model
(
"edxval"
,
"Profile"
)
db_alias
=
schema_editor
.
connection
.
alias
Profile
.
objects
.
using
(
db_alias
)
.
filter
(
profile_name__in
=
[
"desktop_mp4"
,
"desktop_webm"
,
"mobile_high"
,
"mobile_low"
,
"youtube"
]
)
.
delete
()
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
...
...
@@ -106,5 +84,4 @@ class Migration(migrations.Migration):
name
=
'coursevideo'
,
unique_together
=
set
([(
'course_id'
,
'video'
)]),
),
migrations
.
RunPython
(
forwards_default_profiles
,
reverse_default_profiles
,
atomic
=
False
),
]
edxval/migrations/0002_data__default_profiles.py
0 → 100644
View file @
5a9da6d0
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
DEFAULT_PROFILES
=
[
"desktop_mp4"
,
"desktop_webm"
,
"mobile_high"
,
"mobile_low"
,
"youtube"
,
]
def
create_default_profiles
(
apps
,
schema_editor
):
""" Add default profiles """
Profile
=
apps
.
get_model
(
"edxval"
,
"Profile"
)
db_alias
=
schema_editor
.
connection
.
alias
for
profile
in
DEFAULT_PROFILES
:
Profile
.
objects
.
using
(
db_alias
)
.
get_or_create
(
profile_name
=
profile
)
def
delete_default_profiles
(
apps
,
schema_editor
):
""" Remove default profiles """
Profile
=
apps
.
get_model
(
"edxval"
,
"Profile"
)
db_alias
=
schema_editor
.
connection
.
alias
Profile
.
objects
.
using
(
db_alias
)
.
filter
(
profile_name__in
=
DEFAULT_PROFILES
)
.
delete
()
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'edxval'
,
'0001_initial'
),
]
operations
=
[
migrations
.
RunPython
(
create_default_profiles
,
delete_default_profiles
),
]
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