Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
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
course-discovery
Commits
bcb8aec5
Commit
bcb8aec5
authored
Nov 03, 2016
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Squashed migrations for the edx_catalog_extensions app
ECOM-6269
parent
e8d0da22
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
course_discovery/apps/edx_catalog_extensions/migrations/0001_squashed_0003_create_publish_to_marketing_site_flag.py
+62
-0
No files found.
course_discovery/apps/edx_catalog_extensions/migrations/0001_squashed_0003_create_publish_to_marketing_site_flag.py
0 → 100644
View file @
bcb8aec5
# -*- coding: utf-8 -*-
# Generated by Django 1.9.10 on 2016-11-03 22:15
from
__future__
import
unicode_literals
from
django.db
import
migrations
PAID_SEAT_TYPES
=
(
'credit'
,
'professional'
,
'verified'
,)
PROGRAM_TYPES
=
(
'XSeries'
,
'MicroMasters'
,)
def
add_program_types
(
apps
,
schema_editor
):
SeatType
=
apps
.
get_model
(
'course_metadata'
,
'SeatType'
)
ProgramType
=
apps
.
get_model
(
'course_metadata'
,
'ProgramType'
)
seat_types
=
SeatType
.
objects
.
filter
(
slug__in
=
PAID_SEAT_TYPES
)
for
name
in
PROGRAM_TYPES
:
program_type
,
__
=
ProgramType
.
objects
.
update_or_create
(
name
=
name
)
program_type
.
applicable_seat_types
.
clear
()
program_type
.
applicable_seat_types
.
add
(
*
seat_types
)
program_type
.
save
()
def
drop_program_types
(
apps
,
schema_editor
):
ProgramType
=
apps
.
get_model
(
'course_metadata'
,
'ProgramType'
)
ProgramType
.
objects
.
filter
(
name__in
=
PROGRAM_TYPES
)
.
delete
()
def
create_switch
(
apps
,
schema_editor
):
"""Create and activate the publish_program_to_marketing_site switch if it does not already exist."""
Switch
=
apps
.
get_model
(
'waffle'
,
'Switch'
)
Switch
.
objects
.
get_or_create
(
name
=
'publish_program_to_marketing_site'
,
defaults
=
{
'active'
:
False
})
def
delete_switch
(
apps
,
schema_editor
):
"""Delete the publish_program_to_marketing_site switch."""
Switch
=
apps
.
get_model
(
'waffle'
,
'Switch'
)
Switch
.
objects
.
filter
(
name
=
'publish_program_to_marketing_site'
)
.
delete
()
class
Migration
(
migrations
.
Migration
):
replaces
=
[(
'edx_catalog_extensions'
,
'0001_create_program_types'
),
(
'edx_catalog_extensions'
,
'0002_convert_program_category_to_type'
),
(
'edx_catalog_extensions'
,
'0003_create_publish_to_marketing_site_flag'
)]
initial
=
True
dependencies
=
[
(
'waffle'
,
'0001_initial'
),
(
'course_metadata'
,
'0001_squashed_0033_courserun_mobile_available'
),
]
operations
=
[
migrations
.
RunPython
(
code
=
add_program_types
,
reverse_code
=
drop_program_types
,
),
migrations
.
RunPython
(
code
=
create_switch
,
reverse_code
=
delete_switch
,
),
]
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