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
54bedfae
Commit
54bedfae
authored
Mar 10, 2017
by
Awais
Committed by
Awais Qureshi
Mar 13, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Course run key getting blanked issue fixed.
ECOM-7411
parent
7873d2d4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
5 deletions
+52
-5
course_discovery/apps/publisher/forms.py
+6
-0
course_discovery/apps/publisher/tests/test_views.py
+37
-1
course_discovery/apps/publisher/views.py
+7
-2
course_discovery/templates/publisher/add_update_course_form.html
+2
-2
No files found.
course_discovery/apps/publisher/forms.py
View file @
54bedfae
...
...
@@ -271,6 +271,12 @@ class CustomCourseRunForm(CourseRunForm):
return
None
def
__init__
(
self
,
*
args
,
**
kwargs
):
is_project_coordinator
=
kwargs
.
pop
(
'is_project_coordinator'
,
None
)
super
(
CustomCourseRunForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
if
not
is_project_coordinator
:
self
.
fields
[
'lms_course_id'
]
.
widget
=
forms
.
HiddenInput
()
class
SeatForm
(
BaseCourseForm
):
""" Course Seat Form. """
...
...
course_discovery/apps/publisher/tests/test_views.py
View file @
54bedfae
...
...
@@ -1937,6 +1937,8 @@ class CourseRunEditViewTests(TestCase):
self
.
group
=
self
.
organization_extension
.
group
self
.
user
.
groups
.
add
(
self
.
group
)
self
.
group_project_coordinator
=
Group
.
objects
.
get
(
name
=
PROJECT_COORDINATOR_GROUP_NAME
)
self
.
course
=
factories
.
CourseFactory
()
self
.
course_run
=
factories
.
CourseRunFactory
(
course
=
self
.
course
)
self
.
seat
=
factories
.
SeatFactory
(
course_run
=
self
.
course_run
,
type
=
Seat
.
VERIFIED
,
price
=
2
)
...
...
@@ -2284,7 +2286,7 @@ class CourseRunEditViewTests(TestCase):
)
response
=
self
.
client
.
get
(
self
.
edit_page_url
)
self
.
assert
NotContains
(
response
,
'name="lms_course_id
"'
)
self
.
assert
Contains
(
response
,
'<input id="id_lms_course_id" name="lms_course_id" type="hidden
"'
)
self
.
assertContains
(
response
,
'Course Run Key'
)
self
.
assertContains
(
response
,
'STUDIO URL'
)
...
...
@@ -2294,6 +2296,40 @@ class CourseRunEditViewTests(TestCase):
self
.
new_course_run
.
save
()
response
=
self
.
client
.
get
(
self
.
edit_page_url
)
self
.
assertContains
(
response
,
'<input id="id_lms_course_id" name="lms_course_id" type="hidden"'
)
self
.
assertContains
(
response
,
'<a class="studio-link"'
)
def
test_studio_instance_with_project_coordinator
(
self
):
"""
Verify that PC can see the course-key input field. And on post course-key remains in db.
"""
pc_user
=
UserFactory
()
pc_user
.
groups
.
add
(
self
.
group_project_coordinator
)
pc_user
.
groups
.
add
(
self
.
organization_extension
.
group
)
assign_perm
(
OrganizationExtension
.
EDIT_COURSE_RUN
,
self
.
organization_extension
.
group
,
self
.
organization_extension
)
self
.
client
.
logout
()
self
.
client
.
login
(
username
=
pc_user
.
username
,
password
=
USER_PASSWORD
)
self
.
new_course_run
.
lms_course_id
=
'course-v1:edxTest+Test342+2016Q1'
self
.
new_course_run
.
save
()
response
=
self
.
client
.
get
(
self
.
edit_page_url
)
self
.
assertContains
(
response
,
self
.
new_course_run
.
lms_course_id
)
self
.
assertContains
(
response
,
'<input class="field-input input-text" id="id_lms_course_id" name="lms_course_id"'
)
self
.
assertNotContains
(
response
,
'<a class="studio-link"'
)
data
=
{
'full_description'
:
'This is testing description.'
,
'image'
:
''
}
updated_dict
=
self
.
_post_data
(
data
,
self
.
new_course
,
None
,
None
)
self
.
client
.
post
(
self
.
edit_page_url
,
updated_dict
)
response
=
self
.
client
.
get
(
self
.
edit_page_url
)
self
.
assertContains
(
response
,
self
.
new_course_run
.
lms_course_id
)
def
test_price_hidden_without_seat
(
self
):
...
...
course_discovery/apps/publisher/views.py
View file @
54bedfae
...
...
@@ -529,6 +529,7 @@ class CourseRunEditView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMix
'publisher_add_instructor_feature'
:
waffle
.
switch_is_active
(
'publisher_add_instructor_feature'
),
'is_internal_user'
:
mixins
.
check_roles_access
(
self
.
request
.
user
),
'edit_mode'
:
True
,
'is_project_coordinator'
:
is_project_coordinator_user
(
self
.
request
.
user
),
}
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
...
...
@@ -541,7 +542,9 @@ class CourseRunEditView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMix
organization
=
context
.
get
(
'organization'
),
edit_mode
=
True
)
context
[
'run_form'
]
=
self
.
run_form
(
instance
=
course_run
)
context
[
'run_form'
]
=
self
.
run_form
(
instance
=
course_run
,
is_project_coordinator
=
context
.
get
(
'is_project_coordinator'
)
)
context
[
'seat_form'
]
=
self
.
seat_form
(
instance
=
course_run
.
seats
.
first
())
context
[
'breadcrumbs'
]
=
make_bread_crumbs
(
...
...
@@ -570,7 +573,9 @@ class CourseRunEditView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMix
organization
=
context
.
get
(
'organization'
),
edit_mode
=
True
)
run_form
=
self
.
run_form
(
request
.
POST
,
instance
=
course_run
)
run_form
=
self
.
run_form
(
request
.
POST
,
instance
=
course_run
,
is_project_coordinator
=
context
.
get
(
'is_project_coordinator'
)
)
seat_form
=
self
.
seat_form
(
request
.
POST
,
instance
=
course_run
.
seats
.
first
())
if
course_form
.
is_valid
()
and
run_form
.
is_valid
()
and
seat_form
.
is_valid
():
try
:
...
...
course_discovery/templates/publisher/add_update_course_form.html
View file @
54bedfae
...
...
@@ -196,9 +196,9 @@
</div>
<div
class=
"col col-6"
>
<label
class=
"field-label "
>
{{ run_form.lms_course_id.label_tag }}
<span
class=
"required"
>
*
</span></label>
{% if is_internal_user %}
{{ run_form.lms_course_id }}
{% else %}
{% if not is_project_coordinator %}
<div
class=
"studio-url"
>
<span
class=
"studio-url-heading"
>
{% trans "STUDIO URL" %} -
</span>
{% if course_run.studio_url %}
...
...
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