Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
a7b1f79d
Commit
a7b1f79d
authored
Feb 11, 2016
by
Peter Fogg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better error logging for full courses during enrollment.
ECOM-3685
parent
90e1b626
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
common/djangoapps/student/models.py
+13
-12
No files found.
common/djangoapps/student/models.py
View file @
a7b1f79d
...
...
@@ -984,7 +984,7 @@ class CourseEnrollment(models.Model):
if
user
.
id
is
None
:
user
.
save
()
enrollment
,
created
=
CourseEnrollment
.
objects
.
get_or_create
(
enrollment
,
created
=
cls
.
objects
.
get_or_create
(
user
=
user
,
course_id
=
course_key
,
)
...
...
@@ -1009,7 +1009,7 @@ class CourseEnrollment(models.Model):
Course enrollment object or None
"""
try
:
return
CourseEnrollment
.
objects
.
get
(
return
cls
.
objects
.
get
(
user
=
user
,
course_id
=
course_key
)
...
...
@@ -1171,7 +1171,7 @@ class CourseEnrollment(models.Model):
raise
NonExistentCourseError
if
check_access
:
if
CourseEnrollment
.
is_enrollment_closed
(
user
,
course
):
if
cls
.
is_enrollment_closed
(
user
,
course
):
log
.
warning
(
u"User
%
s failed to enroll in course
%
s because enrollment is closed"
,
user
.
username
,
...
...
@@ -1179,14 +1179,15 @@ class CourseEnrollment(models.Model):
)
raise
EnrollmentClosedError
if
CourseEnrollment
.
objects
.
is_course_full
(
course
):
if
cls
.
objects
.
is_course_full
(
course
):
log
.
warning
(
u"User
%
s failed to enroll in full course
%
s"
,
user
.
username
,
u"Course
%
s has reached its maximum enrollment of
%
d learners. User
%
s failed to enroll."
,
course_key
.
to_deprecated_string
(),
course
.
max_student_enrollments_allowed
,
user
.
username
,
)
raise
CourseFullError
if
CourseEnrollment
.
is_enrolled
(
user
,
course_key
):
if
cls
.
is_enrolled
(
user
,
course_key
):
log
.
warning
(
u"User
%
s attempted to enroll in
%
s, but they were already enrolled"
,
user
.
username
,
...
...
@@ -1254,7 +1255,7 @@ class CourseEnrollment(models.Model):
`skip_refund` can be set to True to avoid the refund process.
"""
try
:
record
=
CourseEnrollment
.
objects
.
get
(
user
=
user
,
course_id
=
course_id
)
record
=
cls
.
objects
.
get
(
user
=
user
,
course_id
=
course_id
)
record
.
update_enrollment
(
is_active
=
False
,
skip_refund
=
skip_refund
)
except
cls
.
DoesNotExist
:
...
...
@@ -1300,7 +1301,7 @@ class CourseEnrollment(models.Model):
return
False
try
:
record
=
CourseEnrollment
.
objects
.
get
(
user
=
user
,
course_id
=
course_key
)
record
=
cls
.
objects
.
get
(
user
=
user
,
course_id
=
course_key
)
return
record
.
is_active
except
cls
.
DoesNotExist
:
return
False
...
...
@@ -1325,7 +1326,7 @@ class CourseEnrollment(models.Model):
course_key
=
SlashSeparatedCourseKey
(
course_id_partial
.
org
,
course_id_partial
.
course
,
''
)
querystring
=
unicode
(
course_key
.
to_deprecated_string
())
try
:
return
CourseEnrollment
.
objects
.
filter
(
return
cls
.
objects
.
filter
(
user
=
user
,
course_id__startswith
=
querystring
,
is_active
=
1
...
...
@@ -1346,14 +1347,14 @@ class CourseEnrollment(models.Model):
Returns (None, None) if the courseenrollment record does not exist.
"""
try
:
record
=
CourseEnrollment
.
objects
.
get
(
user
=
user
,
course_id
=
course_id
)
record
=
cls
.
objects
.
get
(
user
=
user
,
course_id
=
course_id
)
return
(
record
.
mode
,
record
.
is_active
)
except
cls
.
DoesNotExist
:
return
(
None
,
None
)
@classmethod
def
enrollments_for_user
(
cls
,
user
):
return
CourseEnrollment
.
objects
.
filter
(
user
=
user
,
is_active
=
1
)
return
cls
.
objects
.
filter
(
user
=
user
,
is_active
=
1
)
def
is_paid_course
(
self
):
"""
...
...
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