Merge pull request #20222 from edx/bmedx/course_enrollment_history

Re-adding django-simple-history for CourseEnrollment
This commit is contained in:
Brian Mesick
2019-05-09 13:02:07 -04:00
committed by GitHub
9 changed files with 116 additions and 27 deletions

View File

@@ -47,6 +47,7 @@ from model_utils.models import TimeStampedModel
from opaque_keys.edx.django.models import CourseKeyField
from opaque_keys.edx.keys import CourseKey
from pytz import UTC
from simple_history.models import HistoricalRecords
from six import text_type
from six.moves import range
from six.moves.urllib.parse import urlencode
@@ -1130,6 +1131,14 @@ class CourseEnrollment(models.Model):
# list of possible values.
mode = models.CharField(default=CourseMode.DEFAULT_MODE_SLUG, max_length=100)
# An audit row will be created for every change to a CourseEnrollment. This
# will create a new model behind the scenes - HistoricalCourseEnrollment and a
# table named 'student_courseenrollment_history'.
history = HistoricalRecords(
history_id_field=models.UUIDField(default=uuid.uuid4),
table_name='student_courseenrollment_history'
)
objects = CourseEnrollmentManager()
# cache key format e.g enrollment.<username>.<course_key>.mode = 'honor'