core: add is_link and get_url property to base Source
This commit is contained in:
		| @ -82,6 +82,16 @@ class Source(RuleModel): | |||||||
|  |  | ||||||
|     objects = InheritanceManager() |     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): |     def __str__(self): | ||||||
|         return self.name |         return self.name | ||||||
|  |  | ||||||
|  | |||||||
| @ -28,6 +28,10 @@ class LDAPSource(Source): | |||||||
|  |  | ||||||
|     form = 'passbook.ldap.forms.LDAPSourceForm' |     form = 'passbook.ldap.forms.LDAPSourceForm' | ||||||
|  |  | ||||||
|  |     @property | ||||||
|  |     def get_url(self): | ||||||
|  |         raise NotImplementedError() | ||||||
|  |  | ||||||
|     class Meta: |     class Meta: | ||||||
|  |  | ||||||
|         verbose_name = _('LDAP Source') |         verbose_name = _('LDAP Source') | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| """OAuth Client models""" | """OAuth Client models""" | ||||||
|  |  | ||||||
| from django.db import models | from django.db import models | ||||||
|  | from django.urls import reverse_lazy | ||||||
| from django.utils.translation import gettext as _ | from django.utils.translation import gettext as _ | ||||||
|  |  | ||||||
| from passbook.core.models import Source, UserSourceConnection | from passbook.core.models import Source, UserSourceConnection | ||||||
| @ -20,6 +21,15 @@ class OAuthSource(Source): | |||||||
|  |  | ||||||
|     form = 'passbook.oauth_client.forms.GitHubOAuthSourceForm' |     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: |     class Meta: | ||||||
|  |  | ||||||
|         verbose_name = _('Generic OAuth Source') |         verbose_name = _('Generic OAuth Source') | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Jens Langhammer
					Jens Langhammer