Skip to content

Commit

Permalink
add app_label to models: fix breaking tests
Browse files Browse the repository at this point in the history
tests in Open edX `common` don't have the `organizations` in the
INSTALLED_APPS this change and throws an error like:

"Model xyz is not in INSTALLED_APP and doesn't declare `app_label`"

This fixes it by adding app_label.

Also, removing unneeded @python_2_unicode_compatible now we're past
Python 2.
  • Loading branch information
OmarIthawi committed Jun 2, 2021
1 parent f8506c3 commit 7842355
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions organizations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class Organization(TimeStampedModel):

history = HistoricalRecords()

class Meta:
app_label = 'organizations'

def __str__(self):
return u"{name} ({short_name})".format(name=self.name, short_name=self.short_name)

Expand Down Expand Up @@ -76,7 +79,6 @@ def clean(self):
'and underscore (_).'))


@python_2_unicode_compatible
class OrganizationCourse(TimeStampedModel):
"""
An OrganizationCourse represents the link between an Organization and a
Expand All @@ -93,6 +95,7 @@ class Meta:
unique_together = (('course_id', 'organization'),)
verbose_name = _('Link Course')
verbose_name_plural = _('Link Courses')
app_label = 'organizations'

def __str__(self):
org = self.organization
Expand All @@ -102,7 +105,6 @@ def __str__(self):
)


@python_2_unicode_compatible
class UserOrganizationMapping(models.Model):
"""
User membership in an organization.
Expand All @@ -115,6 +117,9 @@ class UserOrganizationMapping(models.Model):
is_active = models.BooleanField(default=True)
is_amc_admin = models.BooleanField(default=False)

class Meta:
app_label = 'organizations'

def __str__(self):
org = self.organization
return 'UserOrganizationMapping<{email}, {organization}>'.format(
Expand Down

0 comments on commit 7842355

Please sign in to comment.