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
73af5d01
Commit
73af5d01
authored
Nov 08, 2013
by
Julia Hansbrough
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed create_enrollment to create_or_update_enrollment
parent
de8b378d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
4 deletions
+4
-4
common/djangoapps/student/models.py
+2
-2
common/djangoapps/student/tests/tests.py
+1
-1
lms/djangoapps/shoppingcart/models.py
+1
-1
No files found.
common/djangoapps/student/models.py
View file @
73af5d01
...
...
@@ -713,7 +713,7 @@ class CourseEnrollment(models.Model):
)
.
format
(
self
.
user
,
self
.
course_id
,
self
.
created
,
self
.
is_active
)
@classmethod
def
create_enrollment
(
cls
,
user
,
course_id
,
mode
=
"honor"
,
is_active
=
False
):
def
create_
or_update_
enrollment
(
cls
,
user
,
course_id
,
mode
=
"honor"
,
is_active
=
False
):
"""
Create an enrollment for a user in a class. By default *this enrollment
is not active*. This is useful for when an enrollment needs to go
...
...
@@ -818,7 +818,7 @@ class CourseEnrollment(models.Model):
It is expected that this method is called from a method which has already
verified the user authentication and access.
"""
return
cls
.
create_enrollment
(
user
,
course_id
,
mode
,
is_active
=
True
)
return
cls
.
create_
or_update_
enrollment
(
user
,
course_id
,
mode
,
is_active
=
True
)
@classmethod
def
enroll_by_email
(
cls
,
email
,
course_id
,
mode
=
"honor"
,
ignore_errors
=
True
):
...
...
common/djangoapps/student/tests/tests.py
View file @
73af5d01
...
...
@@ -443,7 +443,7 @@ class EnrollInCourseTest(TestCase):
# Creating an enrollment doesn't actually enroll a student
# (calling CourseEnrollment.enroll() would have)
enrollment
=
CourseEnrollment
.
create_enrollment
(
user
,
course_id
)
enrollment
=
CourseEnrollment
.
create_
or_update_
enrollment
(
user
,
course_id
)
self
.
assertFalse
(
CourseEnrollment
.
is_enrolled
(
user
,
course_id
))
self
.
assert_no_events_were_emitted
()
...
...
lms/djangoapps/shoppingcart/models.py
View file @
73af5d01
...
...
@@ -467,7 +467,7 @@ class CertificateItem(OrderItem):
try
:
course_enrollment
=
CourseEnrollment
.
objects
.
get
(
user
=
order
.
user
,
course_id
=
course_id
)
except
ObjectDoesNotExist
:
course_enrollment
=
CourseEnrollment
.
create_enrollment
(
order
.
user
,
course_id
,
mode
=
mode
)
course_enrollment
=
CourseEnrollment
.
create_
or_update_
enrollment
(
order
.
user
,
course_id
,
mode
=
mode
)
# do some validation on the enrollment mode
valid_modes
=
CourseMode
.
modes_for_course_dict
(
course_id
)
...
...
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