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
86c851a6
Commit
86c851a6
authored
Jun 09, 2017
by
Awais
Committed by
Awais Qureshi
Jun 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip Preview Stage if Course Edit Comes in After the Course-run Has Been Published.
ECOM-7811
parent
909138c5
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
2 deletions
+56
-2
course_discovery/apps/publisher/emails.py
+2
-2
course_discovery/apps/publisher/tests/test_views.py
+45
-0
course_discovery/apps/publisher/views.py
+9
-0
No files found.
course_discovery/apps/publisher/emails.py
View file @
86c851a6
...
@@ -640,8 +640,8 @@ def send_email_for_published_course_run_editing(course_run):
...
@@ -640,8 +640,8 @@ def send_email_for_published_course_run_editing(course_run):
context
=
{
context
=
{
'course_name'
:
course
.
title
,
'course_name'
:
course
.
title
,
'course_team'
:
course_team_user
.
get_full_name
(),
'course_team'
:
course_team_user
.
get_full_name
()
or
course_team_user
.
username
,
'recipient_name'
:
publisher_user
.
get_full_name
(),
'recipient_name'
:
publisher_user
.
get_full_name
()
or
publisher_user
.
username
,
'contact_us_email'
:
course
.
project_coordinator
.
email
,
'contact_us_email'
:
course
.
project_coordinator
.
email
,
'course_run_page_url'
:
'https://{host}{path}'
.
format
(
'course_run_page_url'
:
'https://{host}{path}'
.
format
(
host
=
Site
.
objects
.
get_current
()
.
domain
.
strip
(
'/'
),
path
=
object_path
host
=
Site
.
objects
.
get_current
()
.
domain
.
strip
(
'/'
),
path
=
object_path
...
...
course_discovery/apps/publisher/tests/test_views.py
View file @
86c851a6
...
@@ -2456,6 +2456,51 @@ class CourseEditViewTests(TestCase):
...
@@ -2456,6 +2456,51 @@ class CourseEditViewTests(TestCase):
response
=
self
.
client
.
get
(
self
.
edit_page_url
+
'?history_id={}'
.
format
(
100
))
response
=
self
.
client
.
get
(
self
.
edit_page_url
+
'?history_id={}'
.
format
(
100
))
self
.
assertIsNone
(
response
.
context
[
'history_object'
])
self
.
assertIsNone
(
response
.
context
[
'history_object'
])
def
test_course_with_published_course_run
(
self
):
"""
Verify that editing course with published course run does not changed state
and an email is sent to Publisher.
"""
toggle_switch
(
'enable_publisher_email_notifications'
,
True
)
self
.
client
.
logout
()
self
.
client
.
login
(
username
=
self
.
course_team_role
.
user
.
username
,
password
=
USER_PASSWORD
)
self
.
_assign_permissions
(
self
.
organization_extension
)
self
.
course
.
course_state
.
name
=
CourseStateChoices
.
Approved
self
.
course
.
course_state
.
save
()
course_run
=
factories
.
CourseRunFactory
(
course
=
self
.
course
,
lms_course_id
=
'course-v1:edxTest+Test342+2016Q1'
)
factories
.
CourseRunStateFactory
(
course_run
=
course_run
,
name
=
CourseRunStateChoices
.
Published
)
factories
.
CourseUserRoleFactory
(
course
=
self
.
course
,
role
=
PublisherUserRole
.
Publisher
)
factories
.
CourseUserRoleFactory
(
course
=
self
.
course
,
role
=
PublisherUserRole
.
ProjectCoordinator
)
post_data
=
self
.
_post_data
(
self
.
organization_extension
)
post_data
[
'number'
]
=
'testX654'
response
=
self
.
client
.
post
(
self
.
edit_page_url
,
data
=
post_data
)
self
.
assertRedirects
(
response
,
expected_url
=
reverse
(
'publisher:publisher_course_detail'
,
kwargs
=
{
'pk'
:
self
.
course
.
id
}),
status_code
=
302
,
target_status_code
=
200
)
course_state
=
CourseState
.
objects
.
get
(
id
=
self
.
course
.
course_state
.
id
)
self
.
assertEqual
(
course_state
.
name
,
CourseStateChoices
.
Approved
)
# email send after editing.
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
self
.
assertEqual
([
self
.
course
.
publisher
.
email
],
mail
.
outbox
[
0
]
.
to
)
course_key
=
CourseKey
.
from_string
(
course_run
.
lms_course_id
)
expected_subject
=
'Changes to published course run: {title} {run_number}'
.
format
(
title
=
self
.
course
.
title
,
run_number
=
course_key
.
run
)
self
.
assertEqual
(
str
(
mail
.
outbox
[
0
]
.
subject
),
expected_subject
)
@ddt.ddt
@ddt.ddt
class
CourseRunEditViewTests
(
TestCase
):
class
CourseRunEditViewTests
(
TestCase
):
...
...
course_discovery/apps/publisher/views.py
View file @
86c851a6
...
@@ -393,6 +393,15 @@ class CourseEditView(mixins.PublisherPermissionMixin, UpdateView):
...
@@ -393,6 +393,15 @@ class CourseEditView(mixins.PublisherPermissionMixin, UpdateView):
self
.
object
.
organizations
.
remove
(
self
.
object
.
organizations
.
first
())
self
.
object
.
organizations
.
remove
(
self
.
object
.
organizations
.
first
())
self
.
object
.
organizations
.
add
(
organization_extension
.
organization
)
self
.
object
.
organizations
.
add
(
organization_extension
.
organization
)
try
:
latest_run
=
self
.
object
.
course_runs
.
latest
()
except
CourseRun
.
DoesNotExist
:
latest_run
=
None
if
latest_run
and
latest_run
.
course_run_state
.
name
==
CourseRunStateChoices
.
Published
:
# If latest run of this course is published send an email to Publisher and don't change state.
send_email_for_published_course_run_editing
(
latest_run
)
else
:
user_role
=
self
.
object
.
course_user_roles
.
get
(
user
=
user
)
user_role
=
self
.
object
.
course_user_roles
.
get
(
user
=
user
)
# Change course state to draft if marketing not yet reviewed or
# Change course state to draft if marketing not yet reviewed or
# if marketing person updating the course.
# if marketing person updating the 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