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
1d625153
Commit
1d625153
authored
Apr 19, 2017
by
Waheed Ahmed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed course-key getting blanked.
ECOM-7723
parent
8939eea9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
12 deletions
+43
-12
course_discovery/apps/publisher/emails.py
+5
-6
course_discovery/apps/publisher/forms.py
+8
-2
course_discovery/apps/publisher/tests/test_views.py
+29
-0
course_discovery/apps/publisher/views.py
+1
-4
No files found.
course_discovery/apps/publisher/emails.py
View file @
1d625153
...
...
@@ -28,9 +28,8 @@ def send_email_for_studio_instance_created(course_run, updated_text=_('created')
to_addresses
=
[
course_run
.
course
.
course_team_admin
.
email
]
from_address
=
settings
.
PUBLISHER_FROM_EMAIL
course_user_roles
=
course_run
.
course
.
course_user_roles
.
all
()
course_team
=
course_user_roles
.
filter
(
role
=
PublisherUserRole
.
CourseTeam
)
.
first
()
project_coordinator
=
course_user_roles
.
filter
(
role
=
PublisherUserRole
.
ProjectCoordinator
)
.
first
()
course_team_admin
=
course_run
.
course
.
course_team_admin
project_coordinator
=
course_run
.
course
.
project_coordinator
context
=
{
'updated_text'
:
updated_text
,
...
...
@@ -40,9 +39,9 @@ def send_email_for_studio_instance_created(course_run, updated_text=_('created')
),
'course_name'
:
course_run
.
course
.
title
,
'from_address'
:
from_address
,
'course_team_name'
:
course_team
.
user
.
full_name
if
course_team
else
''
,
'project_coordinator_name'
:
project_coordinator
.
user
.
full_name
if
project_coordinator
else
''
,
'contact_us_email'
:
project_coordinator
.
user
.
email
if
project_coordinator
else
''
'course_team_name'
:
course_team
_admin
.
get_full_name
()
or
course_team_admin
.
username
,
'project_coordinator_name'
:
project_coordinator
.
get_full_name
()
or
project_coordinator
.
username
,
'contact_us_email'
:
project_coordinator
.
email
}
txt_template_path
=
'publisher/email/studio_instance_created.txt'
...
...
course_discovery/apps/publisher/forms.py
View file @
1d625153
...
...
@@ -295,12 +295,18 @@ class CustomCourseRunForm(CourseRunForm):
return
lms_course_id
instance
=
getattr
(
self
,
'instance'
,
None
)
# If `lms_course_id` is none in `cleaned_data` and user is not project coordinator
# return actual value of the instance, it will prevent `lms_course_id` from getting blanked.
if
instance
and
instance
.
pk
and
hasattr
(
self
,
'is_project_coordinator'
)
and
not
self
.
is_project_coordinator
:
return
instance
.
lms_course_id
return
None
def
__init__
(
self
,
*
args
,
**
kwargs
):
is_project_coordinator
=
kwargs
.
pop
(
'is_project_coordinator'
,
None
)
self
.
is_project_coordinator
=
kwargs
.
pop
(
'is_project_coordinator'
,
None
)
super
(
CustomCourseRunForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
if
not
is_project_coordinator
:
if
not
self
.
is_project_coordinator
:
self
.
fields
[
'lms_course_id'
]
.
widget
=
forms
.
HiddenInput
()
...
...
course_discovery/apps/publisher/tests/test_views.py
View file @
1d625153
...
...
@@ -2707,6 +2707,35 @@ class CourseRunEditViewTests(TestCase):
self
.
assertEqual
(
course_run_state
.
name
,
CourseRunStateChoices
.
Draft
)
self
.
assertEqual
(
course_run_state
.
owner_role
,
PublisherUserRole
.
ProjectCoordinator
)
def
test_course_key_not_getting_blanked
(
self
):
"""
Verify that `lms_course_id` not getting blanked if course team updates with empty value.
"""
self
.
client
.
logout
()
user
=
self
.
new_course
.
course_team_admin
self
.
client
.
login
(
username
=
user
.
username
,
password
=
USER_PASSWORD
)
post_data
=
self
.
_post_data
({
'image'
:
''
},
self
.
new_course
,
self
.
new_course_run
,
None
)
lms_course_id
=
'course-v1:edX+DemoX+Demo_Course'
self
.
new_course_run
.
lms_course_id
=
lms_course_id
self
.
new_course_run
.
save
()
# Verify that post data has empty value for `lms_course_id`
self
.
assertEqual
(
post_data
[
'lms_course_id'
],
''
)
response
=
self
.
client
.
post
(
self
.
edit_page_url
,
post_data
)
self
.
assertRedirects
(
response
,
expected_url
=
reverse
(
'publisher:publisher_course_run_detail'
,
kwargs
=
{
'pk'
:
self
.
new_course_run
.
id
}),
status_code
=
302
,
target_status_code
=
200
)
self
.
new_course_run
=
CourseRun
.
objects
.
get
(
id
=
self
.
new_course_run
.
id
)
# Verify that `lms_course_id` not wiped.
self
.
assertEqual
(
self
.
new_course_run
.
lms_course_id
,
lms_course_id
)
class
CourseRevisionViewTests
(
TestCase
):
""" Tests for CourseReview"""
...
...
course_discovery/apps/publisher/views.py
View file @
1d625153
...
...
@@ -526,7 +526,6 @@ class CreateCourseRunView(mixins.LoginRequiredMixin, CreateView):
class
CourseRunEditView
(
mixins
.
LoginRequiredMixin
,
mixins
.
PublisherPermissionMixin
,
UpdateView
):
""" Course Run Edit View."""
model
=
CourseRun
course_form
=
CustomCourseForm
run_form
=
CustomCourseRunForm
seat_form
=
CustomSeatForm
template_name
=
'publisher/course_run/edit_run_form.html'
...
...
@@ -582,9 +581,7 @@ class CourseRunEditView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMix
try
:
with
transaction
.
atomic
():
course_run
=
run_form
.
save
(
commit
=
False
)
course_run
.
changed_by
=
self
.
request
.
user
course_run
.
save
()
course_run
=
run_form
.
save
(
changed_by
=
user
)
run_form
.
save_m2m
()
...
...
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