Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Use python_2_unicode_compatible decorator on models.
Browse files Browse the repository at this point in the history
  • Loading branch information
fyber authored and clintonb committed Oct 24, 2017
1 parent 9b05e66 commit 8a8785d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions provider/oauth2/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.conf import settings
from django.db import models
from django.utils import timezone
from django.utils.encoding import python_2_unicode_compatible

from provider import constants
from provider.constants import CLIENT_TYPES
Expand All @@ -17,6 +18,7 @@
AUTH_USER_MODEL = settings.AUTH_USER_MODEL


@python_2_unicode_compatible
class Client(models.Model):
"""
Default client implementation.
Expand Down Expand Up @@ -49,7 +51,7 @@ class Meta:
client_type = models.IntegerField(choices=CLIENT_TYPES)
logout_uri = models.URLField(help_text="Your application's logout URL", null=True, blank=True)

def __unicode__(self):
def __str__(self):
return self.redirect_uri

def get_default_token_expiry(self):
Expand Down Expand Up @@ -87,6 +89,7 @@ def deserialize(cls, data):
return cls(**kwargs)


@python_2_unicode_compatible
class Grant(models.Model):
"""
Default grant implementation. A grant is a code that can be swapped for an
Expand Down Expand Up @@ -116,10 +119,11 @@ class Meta:
redirect_uri = models.CharField(max_length=255, blank=True)
scope = models.IntegerField(default=0)

def __unicode__(self):
def __str__(self):
return self.code


@python_2_unicode_compatible
class AccessToken(models.Model):
"""
Default access token implementation. An access token is a time limited
Expand Down Expand Up @@ -153,7 +157,7 @@ class Meta:

objects = AccessTokenManager()

def __unicode__(self):
def __str__(self):
return self.token

def save(self, *args, **kwargs):
Expand Down Expand Up @@ -181,6 +185,7 @@ def get_expire_delta(self, reference=None):
return timedelta.days * 86400 + timedelta.seconds


@python_2_unicode_compatible
class RefreshToken(models.Model):
"""
Default refresh token implementation. A refresh token can be swapped for a
Expand All @@ -205,5 +210,5 @@ class Meta:
client = models.ForeignKey(Client)
expired = models.BooleanField(default=False)

def __unicode__(self):
def __str__(self):
return self.token

0 comments on commit 8a8785d

Please sign in to comment.