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
1c8d90ae
Unverified
Commit
1c8d90ae
authored
4 years ago
by
Matt Tuchfarber
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #24917 from edx/tuchfarber/add_debug_messaging_programs
Add debugging for programs enrollment
parents
ad6a6257
f90bcabc
No related branches found
Branches containing commit
Tags
release-2020-10-30-12.40
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openedx/core/djangoapps/programs/utils.py
+42
-0
42 additions, 0 deletions
openedx/core/djangoapps/programs/utils.py
with
42 additions
and
0 deletions
openedx/core/djangoapps/programs/utils.py
+
42
−
0
View file @
1c8d90ae
...
...
@@ -923,6 +923,25 @@ def is_user_enrolled_in_program_type(user, program_type_slug, paid_modes=False,
Returns:
bool: True is the user is enrolled in programs of the requested type
"""
# NOTE: Used to debug production issue on 9/4/20.
if
getattr
(
settings
,
"
DEBUG_PROGRAM_ENROLLMENT_TYPE
"
,
False
):
log
.
info
(
"""
is_user_enrolled_in_program_type called with the following parameters:
User: {},
program_type_slug: {},
paid_modes: {},
enrollments: {},
entitlements: {}
"""
.
format
(
user
.
id
,
program_type_slug
,
str
(
paid_modes
),
str
(
enrollments
),
str
(
entitlements
)
)
)
course_runs
=
set
()
course_uuids
=
set
()
programs
=
get_programs_by_type
(
Site
.
objects
.
get_current
(),
program_type_slug
)
...
...
@@ -940,6 +959,13 @@ def is_user_enrolled_in_program_type(user, program_type_slug, paid_modes=False,
student_entitlements
=
entitlements
if
entitlements
is
not
None
else
get_active_entitlement_list_for_user
(
user
)
for
entitlement
in
student_entitlements
:
if
str
(
entitlement
.
course_uuid
)
in
course_uuids
:
if
getattr
(
settings
,
"
DEBUG_PROGRAM_ENROLLMENT_TYPE
"
,
False
):
# NOTE: Used to debug production issue on 9/4/20.
log
.
info
(
"
User {} has an entitlement for course {} which is in a {} program
"
.
format
(
str
(
user
.
id
),
str
(
entitlement
.
course_uuid
),
str
(
program_type_slug
)
))
return
True
student_enrollments
=
enrollments
if
enrollments
is
not
None
else
get_enrollments
(
user
.
username
)
...
...
@@ -949,7 +975,23 @@ def is_user_enrolled_in_program_type(user, program_type_slug, paid_modes=False,
course_run_key
=
CourseKey
.
from_string
(
course_run_id
)
paid_modes
=
[
mode
.
slug
for
mode
in
get_paid_modes_for_course
(
course_run_key
)]
if
enrollment
[
'
mode
'
]
in
paid_modes
and
course_run_id
in
course_runs
:
if
getattr
(
settings
,
"
DEBUG_PROGRAM_ENROLLMENT_TYPE
"
,
False
):
# NOTE: Used to debug production issue on 9/4/20.
log
.
info
(
"
User {} has an enrollment mode of {} for course {} which is in a {} program and has {} paid modes
"
.
format
(
str
(
user
.
id
),
str
(
enrollment
[
'
mode
'
]),
str
(
course_run_id
),
str
(
program_type_slug
),
str
(
paid_modes
)
))
return
True
elif
course_run_id
in
course_runs
:
if
getattr
(
settings
,
"
DEBUG_PROGRAM_ENROLLMENT_TYPE
"
,
False
):
# NOTE: Used to debug production issue on 9/4/20.
log
.
info
(
"
User {} is enrolled in course {} which is in a {} program
"
.
format
(
str
(
user
.
id
),
str
(
course_run_id
),
str
(
program_type_slug
)
))
return
True
return
False
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