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
94b8b0ac
Commit
94b8b0ac
authored
Nov 08, 2013
by
Julia Hansbrough
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
all CourseEnrollment modifications route through create_or_update
parent
73af5d01
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
common/djangoapps/student/models.py
+10
-10
No files found.
common/djangoapps/student/models.py
View file @
94b8b0ac
...
...
@@ -872,12 +872,11 @@ class CourseEnrollment(models.Model):
"""
try
:
record
=
CourseEnrollment
.
objects
.
get
(
user
=
user
,
course_id
=
course_id
)
if
record
.
is_active
:
record
.
is_active
=
False
record
.
save
()
cls
.
create_or_update_enrollment
(
user
,
course_id
,
record
.
mode
,
is_active
=
False
)
unenroll_done
.
send
(
sender
=
cls
,
course_enrollment
=
record
)
record
.
emit_event
(
EVENT_NAME_ENROLLMENT_DEACTIVATED
)
unenroll_done
.
send
(
sender
=
cls
,
course_enrollment
=
record
)
# TODO: Do we still need to emit this event since unenroll now calls create_or_update_enrollment?
#record.emit_event(EVENT_NAME_ENROLLMENT_DEACTIVATED
)
except
cls
.
DoesNotExist
:
err_msg
=
u"Tried to unenroll student {} from {} but they were not enrolled"
...
...
@@ -968,8 +967,7 @@ class CourseEnrollment(models.Model):
"""Makes this `CourseEnrollment` record active. Saves immediately."""
if
not
self
.
is_active
:
self
.
is_active
=
True
self
.
save
()
self
.
emit_event
(
EVENT_NAME_ENROLLMENT_ACTIVATED
)
CourseEnrollment
.
create_or_update_enrollment
(
self
.
user
,
self
.
course_id
,
self
.
mode
,
True
)
def
deactivate
(
self
):
"""Makes this `CourseEnrollment` record inactive. Saves immediately. An
...
...
@@ -977,8 +975,11 @@ class CourseEnrollment(models.Model):
"""
if
self
.
is_active
:
self
.
is_active
=
False
self
.
save
()
self
.
emit_event
(
EVENT_NAME_ENROLLMENT_DEACTIVATED
)
CourseEnrollment
.
create_or_update_enrollment
(
self
.
user
,
self
.
course_id
,
self
.
mode
,
False
)
def
change_mode
(
self
,
mode
):
self
.
mode
=
mode
CourseEnrollment
.
create_or_update_enrollment
(
self
.
user
,
self
.
course_id
,
mode
,
self
.
is_active
)
def
refundable
(
self
):
"""
...
...
@@ -992,7 +993,6 @@ class CourseEnrollment(models.Model):
return
True
class
CourseEnrollmentAllowed
(
models
.
Model
):
"""
Table of users (specified by email address strings) who are allowed to enroll in a specified course.
...
...
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