Merge pull request #24 from monkeypants/add_repr_to_models

Add __str__ and __unicode__ to models.
This commit is contained in:
Juan Ignacio Fiorentino 2015-05-30 13:10:52 -03:00
commit e46ee11f7f
3 changed files with 17 additions and 1 deletions

1
.gitignore vendored
View file

@ -4,3 +4,4 @@ dist/
*.py[cod]
*.egg-info
.ropeproject
src/

2
DOC.md
View file

@ -46,6 +46,8 @@ Install the package using pip.
pip install django-oidc-provider
# Or latest code from repo.
pip install git+https://github.com/juanifioren/django-oidc-provider.git#egg=oidc_provider
# Or if working from a local repo
pip install git+./#egg=oidc_provider
```
Add it to your apps.

View file

@ -21,6 +21,12 @@ class Client(models.Model):
_redirect_uris = models.TextField(default='')
def __str__(self):
return self.name
def __unicode__(self):
return self.__str__()
def redirect_uris():
def fget(self):
return self._redirect_uris.splitlines()
@ -40,6 +46,7 @@ class BaseCodeTokenModel(models.Model):
client = models.ForeignKey(Client)
expires_at = models.DateTimeField()
_scope = models.TextField(default='')
def scope():
def fget(self):
return self._scope.split()
@ -51,6 +58,12 @@ class BaseCodeTokenModel(models.Model):
def has_expired(self):
return timezone.now() >= self.expires_at
def __str__(self):
return "%s - %s (%s)" % (self.client, self.user, self.expires_at)
def __unicode__(self):
return self.__str__()
class Meta:
abstract = True
@ -127,4 +140,4 @@ class UserInfo(models.Model):
if formatted.startswith(', '):
formatted = formatted[2:]
if formatted.endswith(', '):
formatted = formatted[:-2]
formatted = formatted[:-2]