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
5439abe9
Commit
5439abe9
authored
Mar 28, 2018
by
Jeff LaJoie
Committed by
Jeff LaJoie
Mar 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EDUCATOR-2585: Adds in check to only handle entitlement updates if there are changes to the form
parent
01dc02d8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
+19
-5
course_discovery/apps/publisher/tests/test_views.py
+16
-4
course_discovery/apps/publisher/views.py
+3
-1
No files found.
course_discovery/apps/publisher/tests/test_views.py
View file @
5439abe9
...
@@ -3180,9 +3180,10 @@ class CourseEditViewTests(SiteMixin, TestCase):
...
@@ -3180,9 +3180,10 @@ class CourseEditViewTests(SiteMixin, TestCase):
self
.
assertEqual
(
verified_seat
.
type
,
Seat
.
VERIFIED
)
self
.
assertEqual
(
verified_seat
.
type
,
Seat
.
VERIFIED
)
self
.
assertEqual
(
verified_seat
.
price
,
1000
)
self
.
assertEqual
(
verified_seat
.
price
,
1000
)
def
test_entitlement_published_run
_failure
(
self
):
def
test_entitlement_published_run
(
self
):
"""
"""
Verify that a course with a published course run cannot be saved with altered enrollment-track or price fields.
Verify that a course with a published course run cannot be saved with altered enrollment-track or price fields,
but can be saved without changing the enrollment-track or price fields.
"""
"""
self
.
client
.
logout
()
self
.
client
.
logout
()
self
.
client
.
login
(
username
=
self
.
course_team_role
.
user
.
username
,
password
=
USER_PASSWORD
)
self
.
client
.
login
(
username
=
self
.
course_team_role
.
user
.
username
,
password
=
USER_PASSWORD
)
...
@@ -3190,7 +3191,9 @@ class CourseEditViewTests(SiteMixin, TestCase):
...
@@ -3190,7 +3191,9 @@ class CourseEditViewTests(SiteMixin, TestCase):
self
.
course
.
version
=
Course
.
ENTITLEMENT_VERSION
self
.
course
.
version
=
Course
.
ENTITLEMENT_VERSION
self
.
course
.
save
()
self
.
course
.
save
()
factories
.
CourseEntitlementFactory
(
course
=
self
.
course
,
mode
=
CourseEntitlement
.
VERIFIED
)
verified_entitlement
=
factories
.
CourseEntitlementFactory
(
course
=
self
.
course
,
mode
=
CourseEntitlement
.
VERIFIED
,
price
=
100
)
course_run
=
factories
.
CourseRunFactory
.
create
(
course_run
=
factories
.
CourseRunFactory
.
create
(
course
=
self
.
course
,
lms_course_id
=
'course-v1:edxTest+Test342+2016Q1'
,
end
=
datetime
.
now
()
+
timedelta
(
days
=
1
)
course
=
self
.
course
,
lms_course_id
=
'course-v1:edxTest+Test342+2016Q1'
,
end
=
datetime
.
now
()
+
timedelta
(
days
=
1
)
)
)
...
@@ -3201,11 +3204,20 @@ class CourseEditViewTests(SiteMixin, TestCase):
...
@@ -3201,11 +3204,20 @@ class CourseEditViewTests(SiteMixin, TestCase):
factories
.
SeatFactory
.
create
(
course_run
=
course_run
,
type
=
Seat
.
VERIFIED
,
price
=
100
)
factories
.
SeatFactory
.
create
(
course_run
=
course_run
,
type
=
Seat
.
VERIFIED
,
price
=
100
)
factories
.
SeatFactory
(
course_run
=
course_run
,
type
=
Seat
.
AUDIT
,
price
=
0
)
factories
.
SeatFactory
(
course_run
=
course_run
,
type
=
Seat
.
AUDIT
,
price
=
0
)
# Success case
post_data
=
self
.
_post_data
(
self
.
organization_extension
)
post_data
[
'team_admin'
]
=
self
.
course_team_role
.
user
.
id
post_data
[
'faq'
]
=
'Test FAQ Content'
post_data
[
'price'
]
=
verified_entitlement
.
price
post_data
[
'mode'
]
=
verified_entitlement
.
mode
response
=
self
.
client
.
post
(
self
.
edit_page_url
,
data
=
post_data
)
self
.
assertEqual
(
response
.
status_code
,
302
)
# Failure case
post_data
=
self
.
_post_data
(
self
.
organization_extension
)
post_data
=
self
.
_post_data
(
self
.
organization_extension
)
post_data
[
'team_admin'
]
=
self
.
course_team_role
.
user
.
id
post_data
[
'team_admin'
]
=
self
.
course_team_role
.
user
.
id
post_data
[
'mode'
]
=
CourseEntitlement
.
PROFESSIONAL
post_data
[
'mode'
]
=
CourseEntitlement
.
PROFESSIONAL
post_data
[
'price'
]
=
100
post_data
[
'price'
]
=
100
response
=
self
.
client
.
post
(
self
.
edit_page_url
,
data
=
post_data
)
response
=
self
.
client
.
post
(
self
.
edit_page_url
,
data
=
post_data
)
self
.
assertEqual
(
response
.
status_code
,
400
)
self
.
assertEqual
(
response
.
status_code
,
400
)
...
...
course_discovery/apps/publisher/views.py
View file @
5439abe9
...
@@ -563,6 +563,7 @@ class CourseEditView(mixins.PublisherPermissionMixin, UpdateView):
...
@@ -563,6 +563,7 @@ class CourseEditView(mixins.PublisherPermissionMixin, UpdateView):
'entitlement_form'
:
entitlement_form
'entitlement_form'
:
entitlement_form
})
})
elif
self
.
object
.
uses_entitlements
:
elif
self
.
object
.
uses_entitlements
:
entitlement
=
self
.
object
.
entitlements
.
first
()
if
not
entitlement_mode
:
if
not
entitlement_mode
:
messages
.
error
(
request
,
_
(
messages
.
error
(
request
,
_
(
"Enrollment track cannot be unset or changed from verified or professional to audit or credit."
"Enrollment track cannot be unset or changed from verified or professional to audit or credit."
...
@@ -572,7 +573,8 @@ class CourseEditView(mixins.PublisherPermissionMixin, UpdateView):
...
@@ -572,7 +573,8 @@ class CourseEditView(mixins.PublisherPermissionMixin, UpdateView):
'entitlement_form'
:
entitlement_form
'entitlement_form'
:
entitlement_form
})
})
published_runs
=
self
.
_get_published_course_runs
(
self
.
object
)
published_runs
=
self
.
_get_published_course_runs
(
self
.
object
)
if
published_runs
:
# Only check published runs if there are changes to the mode or price
if
published_runs
and
(
entitlement
.
mode
!=
entitlement_mode
or
entitlement
.
price
!=
entitlement_price
):
# pylint: disable=no-member
# pylint: disable=no-member
error_message
=
_
(
error_message
=
_
(
'The following active course run(s) are published: {course_runs}. You cannot change the mode '
'The following active course run(s) are published: {course_runs}. You cannot change the mode '
...
...
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