Commit 22bbdace by Sarina Canelake

Convert Meta classes to new-style classes

parent b41e70f5
...@@ -10,7 +10,7 @@ class CourseActionStateManager(models.Manager): ...@@ -10,7 +10,7 @@ class CourseActionStateManager(models.Manager):
An abstract Model Manager class for Course Action State models. An abstract Model Manager class for Course Action State models.
This abstract class expects child classes to define the ACTION (string) field. This abstract class expects child classes to define the ACTION (string) field.
""" """
class Meta: class Meta(object):
"""Abstract manager class, with subclasses defining the ACTION (string) field.""" """Abstract manager class, with subclasses defining the ACTION (string) field."""
abstract = True abstract = True
......
...@@ -21,7 +21,7 @@ class CourseActionState(models.Model): ...@@ -21,7 +21,7 @@ class CourseActionState(models.Model):
For example: course copying (reruns), import, export, and validation. For example: course copying (reruns), import, export, and validation.
""" """
class Meta: class Meta(object):
""" """
For performance reasons, we disable "concrete inheritance", by making the Model base class abstract. For performance reasons, we disable "concrete inheritance", by making the Model base class abstract.
With the "abstract base class" inheritance model, tables are only created for derived models, not for With the "abstract base class" inheritance model, tables are only created for derived models, not for
...@@ -77,7 +77,7 @@ class CourseActionUIState(CourseActionState): ...@@ -77,7 +77,7 @@ class CourseActionUIState(CourseActionState):
""" """
An abstract django model that is a sub-class of CourseActionState with additional fields related to UI. An abstract django model that is a sub-class of CourseActionState with additional fields related to UI.
""" """
class Meta: class Meta(object):
""" """
See comment in CourseActionState on disabling "concrete inheritance". See comment in CourseActionState on disabling "concrete inheritance".
""" """
...@@ -101,7 +101,7 @@ class CourseRerunState(CourseActionUIState): ...@@ -101,7 +101,7 @@ class CourseRerunState(CourseActionUIState):
""" """
A concrete django model for maintaining state specifically for the Action Course Reruns. A concrete django model for maintaining state specifically for the Action Course Reruns.
""" """
class Meta: class Meta(object):
""" """
Set the (destination) course_key field to be unique for the rerun action Set the (destination) course_key field to be unique for the rerun action
Although multiple reruns can be in progress simultaneously for a particular source course_key, Although multiple reruns can be in progress simultaneously for a particular source course_key,
......
...@@ -16,7 +16,7 @@ from util.date_utils import get_time_display ...@@ -16,7 +16,7 @@ from util.date_utils import get_time_display
class CourseModeForm(forms.ModelForm): class CourseModeForm(forms.ModelForm):
class Meta: class Meta(object): # pylint: disable=missing-docstring
model = CourseMode model = CourseMode
COURSE_MODE_SLUG_CHOICES = ( COURSE_MODE_SLUG_CHOICES = (
......
...@@ -82,7 +82,7 @@ class CourseMode(models.Model): ...@@ -82,7 +82,7 @@ class CourseMode(models.Model):
# Modes that allow a student to earn credit with a university partner # Modes that allow a student to earn credit with a university partner
CREDIT_MODES = [CREDIT_MODE] CREDIT_MODES = [CREDIT_MODE]
class Meta: class Meta(object):
""" meta attributes of this model """ """ meta attributes of this model """
unique_together = ('course_id', 'mode_slug', 'currency') unique_together = ('course_id', 'mode_slug', 'currency')
......
...@@ -57,7 +57,7 @@ class Role(models.Model): ...@@ -57,7 +57,7 @@ class Role(models.Model):
users = models.ManyToManyField(User, related_name="roles") users = models.ManyToManyField(User, related_name="roles")
course_id = CourseKeyField(max_length=255, blank=True, db_index=True) course_id = CourseKeyField(max_length=255, blank=True, db_index=True)
class Meta: class Meta(object): # pylint: disable=missing-docstring
# use existing table that was originally created from django_comment_client app # use existing table that was originally created from django_comment_client app
db_table = 'django_comment_client_role' db_table = 'django_comment_client_role'
...@@ -99,7 +99,7 @@ class Permission(models.Model): ...@@ -99,7 +99,7 @@ class Permission(models.Model):
name = models.CharField(max_length=30, null=False, blank=False, primary_key=True) name = models.CharField(max_length=30, null=False, blank=False, primary_key=True)
roles = models.ManyToManyField(Role, related_name="permissions") roles = models.ManyToManyField(Role, related_name="permissions")
class Meta: class Meta(object): # pylint: disable=missing-docstring
# use existing table that was originally created from django_comment_client app # use existing table that was originally created from django_comment_client app
db_table = 'django_comment_client_permission' db_table = 'django_comment_client_permission'
......
...@@ -25,7 +25,7 @@ class RestrictedCourseForm(forms.ModelForm): ...@@ -25,7 +25,7 @@ class RestrictedCourseForm(forms.ModelForm):
error message instead. error message instead.
""" """
class Meta: # pylint: disable=missing-docstring class Meta(object): # pylint: disable=missing-docstring
model = RestrictedCourse model = RestrictedCourse
def clean_course_key(self): def clean_course_key(self):
...@@ -58,7 +58,7 @@ class RestrictedCourseForm(forms.ModelForm): ...@@ -58,7 +58,7 @@ class RestrictedCourseForm(forms.ModelForm):
class IPFilterForm(forms.ModelForm): class IPFilterForm(forms.ModelForm):
"""Form validating entry of IP addresses""" """Form validating entry of IP addresses"""
class Meta: # pylint: disable=missing-docstring class Meta(object): # pylint: disable=missing-docstring
model = IPFilter model = IPFilter
def _is_valid_ip(self, address): def _is_valid_ip(self, address):
......
...@@ -379,7 +379,7 @@ class Country(models.Model): ...@@ -379,7 +379,7 @@ class Country(models.Model):
code=unicode(self.country) code=unicode(self.country)
) )
class Meta: class Meta(object):
"""Default ordering is ascending by country code """ """Default ordering is ascending by country code """
ordering = ['country'] ordering = ['country']
...@@ -522,7 +522,7 @@ class CountryAccessRule(models.Model): ...@@ -522,7 +522,7 @@ class CountryAccessRule(models.Model):
cache.delete(cache_key) cache.delete(cache_key)
log.info("Invalidated country access list for course %s", course_key) log.info("Invalidated country access list for course %s", course_key)
class Meta: class Meta(object):
"""a course can be added with either black or white list. """ """a course can be added with either black or white list. """
unique_together = ( unique_together = (
# This restriction ensures that a country is on # This restriction ensures that a country is on
...@@ -646,7 +646,7 @@ class CourseAccessRuleHistory(models.Model): ...@@ -646,7 +646,7 @@ class CourseAccessRuleHistory(models.Model):
else: else:
CourseAccessRuleHistory.save_snapshot(restricted_course) CourseAccessRuleHistory.save_snapshot(restricted_course)
class Meta: # pylint: disable=missing-docstring,old-style-class class Meta(object): # pylint: disable=missing-docstring
get_latest_by = 'timestamp' get_latest_by = 'timestamp'
......
...@@ -14,7 +14,7 @@ from django.contrib.auth.models import User ...@@ -14,7 +14,7 @@ from django.contrib.auth.models import User
class ExternalAuthMap(models.Model): class ExternalAuthMap(models.Model):
class Meta: class Meta(object): # pylint: disable=missing-docstring
unique_together = (('external_id', 'external_domain'), ) unique_together = (('external_id', 'external_domain'), )
external_id = models.CharField(max_length=255, db_index=True) external_id = models.CharField(max_length=255, db_index=True)
external_domain = models.CharField(max_length=255, db_index=True) external_domain = models.CharField(max_length=255, db_index=True)
......
...@@ -20,7 +20,7 @@ from opaque_keys import InvalidKeyError ...@@ -20,7 +20,7 @@ from opaque_keys import InvalidKeyError
class CourseAccessRoleForm(forms.ModelForm): class CourseAccessRoleForm(forms.ModelForm):
"""Form for adding new Course Access Roles view the Django Admin Panel.""" """Form for adding new Course Access Roles view the Django Admin Panel."""
class Meta: class Meta(object): # pylint: disable=missing-docstring
model = CourseAccessRole model = CourseAccessRole
email = forms.EmailField(required=True) email = forms.EmailField(required=True)
...@@ -123,7 +123,7 @@ class CourseAccessRoleAdmin(admin.ModelAdmin): ...@@ -123,7 +123,7 @@ class CourseAccessRoleAdmin(admin.ModelAdmin):
class LinkedInAddToProfileConfigurationAdmin(admin.ModelAdmin): class LinkedInAddToProfileConfigurationAdmin(admin.ModelAdmin):
"""Admin interface for the LinkedIn Add to Profile configuration. """ """Admin interface for the LinkedIn Add to Profile configuration. """
class Meta: class Meta(object): # pylint: disable=missing-docstring
model = LinkedInAddToProfileConfiguration model = LinkedInAddToProfileConfiguration
# Exclude deprecated fields # Exclude deprecated fields
......
...@@ -216,7 +216,7 @@ class UserProfile(models.Model): ...@@ -216,7 +216,7 @@ class UserProfile(models.Model):
MITx fall prototype. MITx fall prototype.
""" """
class Meta: # pylint: disable=missing-docstring class Meta(object): # pylint: disable=missing-docstring
db_table = "auth_userprofile" db_table = "auth_userprofile"
# CRITICAL TODO/SECURITY # CRITICAL TODO/SECURITY
...@@ -436,7 +436,7 @@ class Registration(models.Model): ...@@ -436,7 +436,7 @@ class Registration(models.Model):
registration profile is created when the user creates an registration profile is created when the user creates an
account, but that account is inactive. Once the user clicks account, but that account is inactive. Once the user clicks
on the activation key, it becomes active. ''' on the activation key, it becomes active. '''
class Meta: class Meta(object): # pylint: disable=missing-docstring
db_table = "auth_registration" db_table = "auth_registration"
user = models.ForeignKey(User, unique=True) user = models.ForeignKey(User, unique=True)
...@@ -846,7 +846,7 @@ class CourseEnrollment(models.Model): ...@@ -846,7 +846,7 @@ class CourseEnrollment(models.Model):
objects = CourseEnrollmentManager() objects = CourseEnrollmentManager()
class Meta: class Meta(object): # pylint: disable=missing-docstring
unique_together = (('user', 'course_id'),) unique_together = (('user', 'course_id'),)
ordering = ('user', 'course_id') ordering = ('user', 'course_id')
...@@ -1407,7 +1407,7 @@ class CourseEnrollmentAllowed(models.Model): ...@@ -1407,7 +1407,7 @@ class CourseEnrollmentAllowed(models.Model):
created = models.DateTimeField(auto_now_add=True, null=True, db_index=True) created = models.DateTimeField(auto_now_add=True, null=True, db_index=True)
class Meta: # pylint: disable=missing-docstring class Meta(object): # pylint: disable=missing-docstring
unique_together = (('email', 'course_id'),) unique_together = (('email', 'course_id'),)
def __unicode__(self): def __unicode__(self):
...@@ -1444,7 +1444,7 @@ class CourseAccessRole(models.Model): ...@@ -1444,7 +1444,7 @@ class CourseAccessRole(models.Model):
course_id = CourseKeyField(max_length=255, db_index=True, blank=True) course_id = CourseKeyField(max_length=255, db_index=True, blank=True)
role = models.CharField(max_length=64, db_index=True) role = models.CharField(max_length=64, db_index=True)
class Meta: # pylint: disable=missing-docstring class Meta(object): # pylint: disable=missing-docstring
unique_together = ('user', 'org', 'course_id', 'role') unique_together = ('user', 'org', 'course_id', 'role')
@property @property
...@@ -1835,7 +1835,7 @@ class LanguageProficiency(models.Model): ...@@ -1835,7 +1835,7 @@ class LanguageProficiency(models.Model):
/edx-platform/openedx/core/djangoapps/user_api/accounts/views.py or its associated api method /edx-platform/openedx/core/djangoapps/user_api/accounts/views.py or its associated api method
(update_account_settings) so that the events are emitted. (update_account_settings) so that the events are emitted.
""" """
class Meta: class Meta(object): # pylint: disable=missing-docstring
unique_together = (('code', 'user_profile'),) unique_together = (('code', 'user_profile'),)
user_profile = models.ForeignKey(UserProfile, db_index=True, related_name='language_proficiencies') user_profile = models.ForeignKey(UserProfile, db_index=True, related_name='language_proficiencies')
......
...@@ -46,7 +46,7 @@ class TrackingLog(models.Model): ...@@ -46,7 +46,7 @@ class TrackingLog(models.Model):
time = models.DateTimeField('event time') time = models.DateTimeField('event time')
host = models.CharField(max_length=64, blank=True) host = models.CharField(max_length=64, blank=True)
class Meta: class Meta(object): # pylint: disable=missing-docstring
app_label = 'track' app_label = 'track'
db_table = 'track_trackinglog' db_table = 'track_trackinglog'
......
...@@ -150,7 +150,7 @@ class CcxFieldOverride(models.Model): ...@@ -150,7 +150,7 @@ class CcxFieldOverride(models.Model):
location = LocationKeyField(max_length=255, db_index=True) location = LocationKeyField(max_length=255, db_index=True)
field = models.CharField(max_length=255) field = models.CharField(max_length=255)
class Meta: # pylint: disable=missing-docstring,old-style-class class Meta(object): # pylint: disable=missing-docstring
unique_together = (('ccx', 'location', 'field'),) unique_together = (('ccx', 'location', 'field'),)
value = models.TextField(default='null') value = models.TextField(default='null')
...@@ -241,7 +241,7 @@ class ExampleCertificateSet(TimeStampedModel): ...@@ -241,7 +241,7 @@ class ExampleCertificateSet(TimeStampedModel):
""" """
course_key = CourseKeyField(max_length=255, db_index=True) course_key = CourseKeyField(max_length=255, db_index=True)
class Meta: # pylint: disable=missing-docstring, old-style-class class Meta(object): # pylint: disable=missing-docstring
get_latest_by = 'created' get_latest_by = 'created'
@classmethod @classmethod
...@@ -498,7 +498,7 @@ class CertificateGenerationCourseSetting(TimeStampedModel): ...@@ -498,7 +498,7 @@ class CertificateGenerationCourseSetting(TimeStampedModel):
course_key = CourseKeyField(max_length=255, db_index=True) course_key = CourseKeyField(max_length=255, db_index=True)
enabled = models.BooleanField(default=False) enabled = models.BooleanField(default=False)
class Meta: # pylint: disable=missing-docstring, old-style-class class Meta(object): # pylint: disable=missing-docstring
get_latest_by = 'created' get_latest_by = 'created'
@classmethod @classmethod
......
...@@ -1163,7 +1163,7 @@ class InvoiceHistory(models.Model): ...@@ -1163,7 +1163,7 @@ class InvoiceHistory(models.Model):
elif hasattr(instance, 'invoice'): elif hasattr(instance, 'invoice'):
InvoiceHistory.save_invoice_snapshot(instance.invoice) InvoiceHistory.save_invoice_snapshot(instance.invoice)
class Meta: # pylint: disable=missing-docstring,old-style-class class Meta(object): # pylint: disable=missing-docstring
get_latest_by = "timestamp" get_latest_by = "timestamp"
......
...@@ -895,7 +895,7 @@ class VerificationCheckpoint(models.Model): ...@@ -895,7 +895,7 @@ class VerificationCheckpoint(models.Model):
checkpoint_location = models.CharField(max_length=255) checkpoint_location = models.CharField(max_length=255)
photo_verification = models.ManyToManyField(SoftwareSecurePhotoVerification) photo_verification = models.ManyToManyField(SoftwareSecurePhotoVerification)
class Meta: # pylint: disable=missing-docstring, old-style-class class Meta(object): # pylint: disable=missing-docstring
unique_together = ('course_id', 'checkpoint_location') unique_together = ('course_id', 'checkpoint_location')
def __unicode__(self): def __unicode__(self):
...@@ -1089,7 +1089,7 @@ class SkippedReverification(models.Model): ...@@ -1089,7 +1089,7 @@ class SkippedReverification(models.Model):
checkpoint = models.ForeignKey(VerificationCheckpoint, related_name="skipped_checkpoint") checkpoint = models.ForeignKey(VerificationCheckpoint, related_name="skipped_checkpoint")
created_at = models.DateTimeField(auto_now_add=True) created_at = models.DateTimeField(auto_now_add=True)
class Meta: # pylint: disable=missing-docstring, old-style-class class Meta(object): # pylint: disable=missing-docstring
unique_together = (('user', 'course_id'),) unique_together = (('user', 'course_id'),)
@classmethod @classmethod
......
...@@ -18,7 +18,7 @@ class CourseUserGroup(models.Model): ...@@ -18,7 +18,7 @@ class CourseUserGroup(models.Model):
which may be treated specially. For example, a user can be in at most one cohort per which may be treated specially. For example, a user can be in at most one cohort per
course, and cohorts are used to split up the forums by group. course, and cohorts are used to split up the forums by group.
""" """
class Meta: class Meta(object): # pylint: disable=missing-docstring
unique_together = (('name', 'course_id'), ) unique_together = (('name', 'course_id'), )
name = models.CharField(max_length=255, name = models.CharField(max_length=255,
......
...@@ -15,7 +15,7 @@ class LanguageProficiencySerializer(serializers.ModelSerializer): ...@@ -15,7 +15,7 @@ class LanguageProficiencySerializer(serializers.ModelSerializer):
Class that serializes the LanguageProficiency model for account Class that serializes the LanguageProficiency model for account
information. information.
""" """
class Meta: class Meta(object): # pylint: disable=missing-docstring
model = LanguageProficiency model = LanguageProficiency
fields = ("code",) fields = ("code",)
...@@ -36,7 +36,7 @@ class AccountUserSerializer(serializers.HyperlinkedModelSerializer, ReadOnlyFiel ...@@ -36,7 +36,7 @@ class AccountUserSerializer(serializers.HyperlinkedModelSerializer, ReadOnlyFiel
""" """
Class that serializes the portion of User model needed for account information. Class that serializes the portion of User model needed for account information.
""" """
class Meta: class Meta(object): # pylint: disable=missing-docstring
model = User model = User
fields = ("username", "email", "date_joined", "is_active") fields = ("username", "email", "date_joined", "is_active")
read_only_fields = ("username", "email", "date_joined", "is_active") read_only_fields = ("username", "email", "date_joined", "is_active")
...@@ -51,7 +51,7 @@ class AccountLegacyProfileSerializer(serializers.HyperlinkedModelSerializer, Rea ...@@ -51,7 +51,7 @@ class AccountLegacyProfileSerializer(serializers.HyperlinkedModelSerializer, Rea
requires_parental_consent = serializers.SerializerMethodField("get_requires_parental_consent") requires_parental_consent = serializers.SerializerMethodField("get_requires_parental_consent")
language_proficiencies = LanguageProficiencySerializer(many=True, allow_add_remove=True, required=False) language_proficiencies = LanguageProficiencySerializer(many=True, allow_add_remove=True, required=False)
class Meta: class Meta(object): # pylint: disable=missing-docstring
model = UserProfile model = UserProfile
fields = ( fields = (
"name", "gender", "goals", "year_of_birth", "level_of_education", "country", "name", "gender", "goals", "year_of_birth", "level_of_education", "country",
......
...@@ -24,7 +24,7 @@ class UserPreference(models.Model): ...@@ -24,7 +24,7 @@ class UserPreference(models.Model):
key = models.CharField(max_length=255, db_index=True, validators=[RegexValidator(KEY_REGEX)]) key = models.CharField(max_length=255, db_index=True, validators=[RegexValidator(KEY_REGEX)])
value = models.TextField() value = models.TextField()
class Meta: # pylint: disable=missing-docstring class Meta(object): # pylint: disable=missing-docstring
unique_together = ("user", "key") unique_together = ("user", "key")
@classmethod @classmethod
...@@ -93,7 +93,7 @@ class UserCourseTag(models.Model): ...@@ -93,7 +93,7 @@ class UserCourseTag(models.Model):
course_id = CourseKeyField(max_length=255, db_index=True) course_id = CourseKeyField(max_length=255, db_index=True)
value = models.TextField() value = models.TextField()
class Meta: # pylint: disable=missing-docstring class Meta(object): # pylint: disable=missing-docstring
unique_together = ("user", "course_id", "key") unique_together = ("user", "course_id", "key")
...@@ -108,6 +108,6 @@ class UserOrgTag(TimeStampedModel): ...@@ -108,6 +108,6 @@ class UserOrgTag(TimeStampedModel):
org = models.CharField(max_length=255, db_index=True) org = models.CharField(max_length=255, db_index=True)
value = models.TextField() value = models.TextField()
class Meta: class Meta(object):
""" Meta class for defining unique constraints. """ """ Meta class for defining unique constraints. """
unique_together = ("user", "org", "key") unique_together = ("user", "org", "key")
...@@ -16,7 +16,7 @@ class UserSerializer(serializers.HyperlinkedModelSerializer): ...@@ -16,7 +16,7 @@ class UserSerializer(serializers.HyperlinkedModelSerializer):
def get_preferences(self, user): def get_preferences(self, user):
return dict([(pref.key, pref.value) for pref in user.preferences.all()]) return dict([(pref.key, pref.value) for pref in user.preferences.all()])
class Meta: class Meta(object): # pylint: disable=missing-docstring
model = User model = User
# This list is the minimal set required by the notification service # This list is the minimal set required by the notification service
fields = ("id", "url", "email", "name", "username", "preferences") fields = ("id", "url", "email", "name", "username", "preferences")
...@@ -26,7 +26,7 @@ class UserSerializer(serializers.HyperlinkedModelSerializer): ...@@ -26,7 +26,7 @@ class UserSerializer(serializers.HyperlinkedModelSerializer):
class UserPreferenceSerializer(serializers.HyperlinkedModelSerializer): class UserPreferenceSerializer(serializers.HyperlinkedModelSerializer):
user = UserSerializer() user = UserSerializer()
class Meta: class Meta(object): # pylint: disable=missing-docstring
model = UserPreference model = UserPreference
depth = 1 depth = 1
...@@ -36,7 +36,7 @@ class RawUserPreferenceSerializer(serializers.ModelSerializer): ...@@ -36,7 +36,7 @@ class RawUserPreferenceSerializer(serializers.ModelSerializer):
""" """
user = serializers.PrimaryKeyRelatedField() user = serializers.PrimaryKeyRelatedField()
class Meta: class Meta(object): # pylint: disable=missing-docstring
model = UserPreference model = UserPreference
depth = 1 depth = 1
......
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