Commit bb5c28c0 by John Eskew

Remove deprecation warnings from Django models.

Add app_label definitions in Meta classes for models.
Move import of course_mode model into methods to prevent importing
the models at startup time.
parent 9ae0dada
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('course_modes', '0005_auto_20151217_0958'),
]
operations = [
migrations.AlterModelOptions(
name='coursemodeexpirationconfig',
options={},
),
]
...@@ -30,6 +30,9 @@ class CourseMode(models.Model): ...@@ -30,6 +30,9 @@ class CourseMode(models.Model):
We would like to offer a course in a variety of modes. We would like to offer a course in a variety of modes.
""" """
class Meta(object):
app_label = "course_modes"
# the course that this mode is attached to # the course that this mode is attached to
course_id = CourseKeyField(max_length=255, db_index=True, verbose_name=_("Course")) course_id = CourseKeyField(max_length=255, db_index=True, verbose_name=_("Course"))
...@@ -636,6 +639,9 @@ class CourseModesArchive(models.Model): ...@@ -636,6 +639,9 @@ class CourseModesArchive(models.Model):
field pair in CourseModes. Having a separate table allows us to have an audit trail of any changes field pair in CourseModes. Having a separate table allows us to have an audit trail of any changes
such as course price changes such as course price changes
""" """
class Meta(object):
app_label = "course_modes"
# the course that this mode is attached to # the course that this mode is attached to
course_id = CourseKeyField(max_length=255, db_index=True) course_id = CourseKeyField(max_length=255, db_index=True)
...@@ -665,6 +671,9 @@ class CourseModeExpirationConfig(ConfigurationModel): ...@@ -665,6 +671,9 @@ class CourseModeExpirationConfig(ConfigurationModel):
""" """
Configuration for time period from end of course to auto-expire a course mode. Configuration for time period from end of course to auto-expire a course mode.
""" """
class Meta(object):
app_label = "course_modes"
verification_window = models.DurationField( verification_window = models.DurationField(
default=timedelta(days=10), default=timedelta(days=10),
help_text=_( help_text=_(
......
...@@ -65,7 +65,6 @@ from model_utils.models import TimeStampedModel ...@@ -65,7 +65,6 @@ from model_utils.models import TimeStampedModel
from openedx.core.djangoapps.signals.signals import COURSE_CERT_AWARDED from openedx.core.djangoapps.signals.signals import COURSE_CERT_AWARDED
from config_models.models import ConfigurationModel from config_models.models import ConfigurationModel
from course_modes.models import CourseMode
from instructor_task.models import InstructorTask from instructor_task.models import InstructorTask
from util.milestones_helpers import fulfill_course_milestone, is_prerequisite_courses_enabled from util.milestones_helpers import fulfill_course_milestone, is_prerequisite_courses_enabled
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
...@@ -206,6 +205,9 @@ class GeneratedCertificate(models.Model): ...@@ -206,6 +205,9 @@ class GeneratedCertificate(models.Model):
""" """
Base model for generated certificates Base model for generated certificates
""" """
# Import here instead of top of file since this module gets imported before
# the course_modes app is loaded, resulting in a Django deprecation warning.
from course_modes.models import CourseMode
# Only returns eligible certificates. This should be used in # Only returns eligible certificates. This should be used in
# preference to the default `objects` manager in most cases. # preference to the default `objects` manager in most cases.
...@@ -463,6 +465,9 @@ def certificate_status_for_student(student, course_id): ...@@ -463,6 +465,9 @@ def certificate_status_for_student(student, course_id):
If the student has been graded, the dictionary also contains their If the student has been graded, the dictionary also contains their
grade for the course with the key "grade". grade for the course with the key "grade".
''' '''
# Import here instead of top of file since this module gets imported before
# the course_modes app is loaded, resulting in a Django deprecation warning.
from course_modes.models import CourseMode
try: try:
generated_certificate = GeneratedCertificate.objects.get( # pylint: disable=no-member generated_certificate = GeneratedCertificate.objects.get( # pylint: disable=no-member
...@@ -545,6 +550,9 @@ class ExampleCertificateSet(TimeStampedModel): ...@@ -545,6 +550,9 @@ class ExampleCertificateSet(TimeStampedModel):
ExampleCertificateSet ExampleCertificateSet
""" """
# Import here instead of top of file since this module gets imported before
# the course_modes app is loaded, resulting in a Django deprecation warning.
from course_modes.models import CourseMode
cert_set = cls.objects.create(course_key=course_key) cert_set = cls.objects.create(course_key=course_key)
ExampleCertificate.objects.bulk_create([ ExampleCertificate.objects.bulk_create([
......
...@@ -58,6 +58,9 @@ class InstructorTask(models.Model): ...@@ -58,6 +58,9 @@ class InstructorTask(models.Model):
`created` stores date that entry was first created `created` stores date that entry was first created
`updated` stores date that entry was last modified `updated` stores date that entry was last modified
""" """
class Meta(object):
app_label = "instructor_task"
task_type = models.CharField(max_length=50, db_index=True) task_type = models.CharField(max_length=50, db_index=True)
course_id = CourseKeyField(max_length=255, db_index=True) course_id = CourseKeyField(max_length=255, db_index=True)
task_key = models.CharField(max_length=255, db_index=True) task_key = models.CharField(max_length=255, db_index=True)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment