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
866d38c0
Commit
866d38c0
authored
Jun 25, 2018
by
Sanford Student
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug
parent
b890f884
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
course_discovery/apps/publisher/dataloader/create_courses.py
+6
-0
course_discovery/apps/publisher/signals.py
+3
-2
No files found.
course_discovery/apps/publisher/dataloader/create_courses.py
View file @
866d38c0
...
@@ -6,6 +6,7 @@ from django.core.files import File
...
@@ -6,6 +6,7 @@ from django.core.files import File
from
course_discovery.apps.publisher.choices
import
CourseRunStateChoices
,
CourseStateChoices
,
PublisherUserRole
from
course_discovery.apps.publisher.choices
import
CourseRunStateChoices
,
CourseStateChoices
,
PublisherUserRole
from
course_discovery.apps.publisher.models
import
Course
,
CourseRun
,
CourseRunState
,
CourseState
,
Seat
from
course_discovery.apps.publisher.models
import
Course
,
CourseRun
,
CourseRunState
,
CourseState
,
Seat
from
course_discovery.apps.publisher.signals
import
PUBLISHER_COURSE_RUN_CREATED
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -142,6 +143,11 @@ def create_course_runs(meta_data_course, publisher_course):
...
@@ -142,6 +143,11 @@ def create_course_runs(meta_data_course, publisher_course):
# Initialize workflow for Course-run.
# Initialize workflow for Course-run.
if
created
:
if
created
:
PUBLISHER_COURSE_RUN_CREATED
.
send
(
model
=
publisher_course_run
,
start
=
canonical_course_run
.
start
,
end
=
canonical_course_run
.
end
)
state
,
created
=
CourseRunState
.
objects
.
get_or_create
(
course_run
=
publisher_course_run
)
state
,
created
=
CourseRunState
.
objects
.
get_or_create
(
course_run
=
publisher_course_run
)
if
created
:
if
created
:
state
.
approved_by_role
=
PublisherUserRole
.
ProjectCoordinator
state
.
approved_by_role
=
PublisherUserRole
.
ProjectCoordinator
...
...
course_discovery/apps/publisher/signals.py
View file @
866d38c0
...
@@ -4,7 +4,7 @@ import waffle
...
@@ -4,7 +4,7 @@ import waffle
from
django.contrib.auth.models
import
Permission
from
django.contrib.auth.models
import
Permission
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.db.models.signals
import
post_save
from
django.db.models.signals
import
post_save
from
django.dispatch
import
receiver
from
django.dispatch
import
receiver
,
Signal
from
slumber.exceptions
import
SlumberBaseException
from
slumber.exceptions
import
SlumberBaseException
from
course_discovery.apps.publisher.models
import
CourseRun
,
OrganizationExtension
from
course_discovery.apps.publisher.models
import
CourseRun
,
OrganizationExtension
...
@@ -12,6 +12,7 @@ from course_discovery.apps.publisher.studio_api_utils import StudioAPI
...
@@ -12,6 +12,7 @@ from course_discovery.apps.publisher.studio_api_utils import StudioAPI
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
PUBLISHER_COURSE_RUN_CREATED
=
Signal
(
providing_args
=
[
'model'
,
'start'
,
'end'
])
def
get_related_discovery_course_run
(
publisher_course_run
):
def
get_related_discovery_course_run
(
publisher_course_run
):
try
:
try
:
...
@@ -21,7 +22,7 @@ def get_related_discovery_course_run(publisher_course_run):
...
@@ -21,7 +22,7 @@ def get_related_discovery_course_run(publisher_course_run):
return
return
@receiver
(
post_save
,
sender
=
CourseRun
)
@receiver
(
PUBLISHER_COURSE_RUN_CREATED
,
sender
=
CourseRun
)
def
create_course_run_in_studio_receiver
(
sender
,
instance
,
created
,
**
kwargs
):
# pylint: disable=unused-argument
def
create_course_run_in_studio_receiver
(
sender
,
instance
,
created
,
**
kwargs
):
# pylint: disable=unused-argument
if
created
and
waffle
.
switch_is_active
(
'enable_publisher_create_course_run_in_studio'
):
if
created
and
waffle
.
switch_is_active
(
'enable_publisher_create_course_run_in_studio'
):
course
=
instance
.
course
course
=
instance
.
course
...
...
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