Merge pull request #24 from monkeypants/add_repr_to_models
Add __str__ and __unicode__ to models.
This commit is contained in:
commit
e46ee11f7f
3 changed files with 17 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,3 +4,4 @@ dist/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
*.egg-info
|
*.egg-info
|
||||||
.ropeproject
|
.ropeproject
|
||||||
|
src/
|
2
DOC.md
2
DOC.md
|
@ -46,6 +46,8 @@ Install the package using pip.
|
||||||
pip install django-oidc-provider
|
pip install django-oidc-provider
|
||||||
# Or latest code from repo.
|
# Or latest code from repo.
|
||||||
pip install git+https://github.com/juanifioren/django-oidc-provider.git#egg=oidc_provider
|
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.
|
Add it to your apps.
|
||||||
|
|
|
@ -21,6 +21,12 @@ class Client(models.Model):
|
||||||
|
|
||||||
_redirect_uris = models.TextField(default='')
|
_redirect_uris = models.TextField(default='')
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return self.__str__()
|
||||||
|
|
||||||
def redirect_uris():
|
def redirect_uris():
|
||||||
def fget(self):
|
def fget(self):
|
||||||
return self._redirect_uris.splitlines()
|
return self._redirect_uris.splitlines()
|
||||||
|
@ -40,6 +46,7 @@ class BaseCodeTokenModel(models.Model):
|
||||||
client = models.ForeignKey(Client)
|
client = models.ForeignKey(Client)
|
||||||
expires_at = models.DateTimeField()
|
expires_at = models.DateTimeField()
|
||||||
_scope = models.TextField(default='')
|
_scope = models.TextField(default='')
|
||||||
|
|
||||||
def scope():
|
def scope():
|
||||||
def fget(self):
|
def fget(self):
|
||||||
return self._scope.split()
|
return self._scope.split()
|
||||||
|
@ -51,6 +58,12 @@ class BaseCodeTokenModel(models.Model):
|
||||||
def has_expired(self):
|
def has_expired(self):
|
||||||
return timezone.now() >= self.expires_at
|
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:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue