core: add is_link and get_url property to base Source
This commit is contained in:
parent
f6c5f10d65
commit
b0fa302718
|
@ -82,6 +82,16 @@ class Source(RuleModel):
|
|||
|
||||
objects = InheritanceManager()
|
||||
|
||||
@property
|
||||
def is_link(self):
|
||||
"""Return true if Source should get a link on the login page"""
|
||||
return False
|
||||
|
||||
@property
|
||||
def get_url(self):
|
||||
"""Return URL used for logging in"""
|
||||
raise NotImplementedError
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
|
|
@ -28,6 +28,10 @@ class LDAPSource(Source):
|
|||
|
||||
form = 'passbook.ldap.forms.LDAPSourceForm'
|
||||
|
||||
@property
|
||||
def get_url(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
class Meta:
|
||||
|
||||
verbose_name = _('LDAP Source')
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""OAuth Client models"""
|
||||
|
||||
from django.db import models
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from passbook.core.models import Source, UserSourceConnection
|
||||
|
@ -20,6 +21,15 @@ class OAuthSource(Source):
|
|||
|
||||
form = 'passbook.oauth_client.forms.GitHubOAuthSourceForm'
|
||||
|
||||
@property
|
||||
def is_link(self):
|
||||
return True
|
||||
|
||||
@property
|
||||
def get_url(self):
|
||||
return reverse_lazy('passbook_oauth_client:oauth-client-login',
|
||||
kwargs={'source_slug': self.slug})
|
||||
|
||||
class Meta:
|
||||
|
||||
verbose_name = _('Generic OAuth Source')
|
||||
|
|
Reference in New Issue