diff --git a/passbook/core/models.py b/passbook/core/models.py index 294a18cd4..55ba9c8f2 100644 --- a/passbook/core/models.py +++ b/passbook/core/models.py @@ -152,14 +152,10 @@ class Source(PolicyModel): objects = InheritanceManager() @property - def is_link(self): - """Return true if Source should get a link on the login page""" - return False - - @property - def get_login_button(self): - """Return a tuple of URL, Icon name and Name""" - raise NotImplementedError + def login_button(self): + """Return a tuple of URL, Icon name and Name + if Source should get a link on the login page""" + return None @property def additional_info(self): diff --git a/passbook/core/views/authentication.py b/passbook/core/views/authentication.py index 528f94256..3acd6183b 100644 --- a/passbook/core/views/authentication.py +++ b/passbook/core/views/authentication.py @@ -46,9 +46,11 @@ class LoginView(UserPassesTestMixin, FormView): kwargs['show_sign_up_notice'] = CONFIG.y('passbook.sign_up.enabled') kwargs['sources'] = [] sources = Source.objects.filter(enabled=True).select_subclasses() - if any(source.is_link for source in sources): - for source in sources: - kwargs['sources'].append(source.get_login_button) + for source in sources: + login_button = source.login_button + if login_button: + kwargs['sources'].append(login_button) + if kwargs['sources']: self.template_name = 'login/with_sources.html' return super().get_context_data(**kwargs) diff --git a/passbook/sources/ldap/models.py b/passbook/sources/ldap/models.py index 93a83bbe0..58b5fd0e4 100644 --- a/passbook/sources/ldap/models.py +++ b/passbook/sources/ldap/models.py @@ -32,11 +32,15 @@ class LDAPSource(Source): sync_parent_group = models.ForeignKey(Group, blank=True, null=True, default=None, on_delete=models.SET_DEFAULT) + # This field is written to by the sync_* tasks + # displayed by additional_info + status = models.TextField(default="") + form = 'passbook.sources.ldap.forms.LDAPSourceForm' @property - def get_login_button(self): - raise NotImplementedError() + def additional_info(self): + return self.status class Meta: diff --git a/passbook/sources/oauth/models.py b/passbook/sources/oauth/models.py index be6392966..21826271e 100644 --- a/passbook/sources/oauth/models.py +++ b/passbook/sources/oauth/models.py @@ -22,11 +22,7 @@ class OAuthSource(Source): form = 'passbook.sources.oauth.forms.OAuthSourceForm' @property - def is_link(self): - return True - - @property - def get_login_button(self): + def login_button(self): url = reverse_lazy('passbook_sources_oauth:oauth-client-login', kwargs={'source_slug': self.slug}) return url, self.provider_type, self.name