Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
6f8090ea
Commit
6f8090ea
authored
6 years ago
by
Matthew Piatetsky
Browse files
Options
Downloads
Patches
Plain Diff
handle case when list of programs for course is empty
parent
4826b690
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/djangoapps/course_modes/views.py
+20
-18
20 additions, 18 deletions
common/djangoapps/course_modes/views.py
with
20 additions
and
18 deletions
common/djangoapps/course_modes/views.py
+
20
−
18
View file @
6f8090ea
...
...
@@ -154,22 +154,24 @@ class ChooseModeView(View):
meter_inverted_programs
=
meter
.
invert_programs
()
if
len
(
meter_inverted_programs
)
>
0
:
# program for the course on this page
program_for_course
=
meter_inverted_programs
.
get
(
course_id
)[
0
]
program_uuid
=
program_for_course
.
get
(
'
uuid
'
)
if
program_for_course
:
# program data with bundle info
program_data
=
ProgramDataExtender
(
program_for_course
,
request
.
user
,
mobile_only
=
False
).
extend
()
skus
=
program_data
.
get
(
'
skus
'
)
ecommerce_service
=
EcommerceService
()
program_bundle_url
=
ecommerce_service
.
get_checkout_page_url
(
*
skus
,
program_uuid
=
program_uuid
)
bundle_data
=
{
'
program_marketing_site_url
'
:
program_data
.
get
(
'
marketing_url
'
),
'
program_bundle_url
'
:
program_bundle_url
,
'
discount_data
'
:
program_data
.
get
(
'
discount_data
'
),
'
program_type
'
:
program_data
.
get
(
'
type
'
),
'
program_title
'
:
program_data
.
get
(
'
title
'
),
'
program_price
'
:
program_data
.
get
(
'
full_program_price
'
),
}
programs_for_course
=
meter_inverted_programs
.
get
(
course_id
)
if
programs_for_course
:
program_for_course
=
programs_for_course
[
0
]
program_uuid
=
program_for_course
.
get
(
'
uuid
'
)
if
program_for_course
:
# program data with bundle info
program_data
=
ProgramDataExtender
(
program_for_course
,
request
.
user
,
mobile_only
=
False
).
extend
()
skus
=
program_data
.
get
(
'
skus
'
)
ecommerce_service
=
EcommerceService
()
program_bundle_url
=
ecommerce_service
.
get_checkout_page_url
(
*
skus
,
program_uuid
=
program_uuid
)
bundle_data
=
{
'
program_marketing_site_url
'
:
program_data
.
get
(
'
marketing_url
'
),
'
program_bundle_url
'
:
program_bundle_url
,
'
discount_data
'
:
program_data
.
get
(
'
discount_data
'
),
'
program_type
'
:
program_data
.
get
(
'
type
'
),
'
program_title
'
:
program_data
.
get
(
'
title
'
),
'
program_price
'
:
program_data
.
get
(
'
full_program_price
'
),
}
context
=
{
"
bundle_data
"
:
bundle_data
,
...
...
@@ -179,7 +181,7 @@ class ChooseModeView(View):
),
"
modes
"
:
modes
,
"
has_credit_upsell
"
:
has_credit_upsell
,
"
course_name
"
:
course
.
display_name_with_default
_escaped
,
"
course_name
"
:
course
.
display_name_with_default
,
"
course_org
"
:
course
.
display_org_with_default
,
"
course_num
"
:
course
.
display_number_with_default
,
"
chosen_price
"
:
chosen_price
,
...
...
@@ -196,7 +198,7 @@ class ChooseModeView(View):
)
title_content
=
_
(
"
Congratulations! You are now enrolled in {course_name}
"
).
format
(
course_name
=
course
.
display_name_with_default
_escaped
course_name
=
course
.
display_name_with_default
)
context
[
"
title_content
"
]
=
title_content
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment