core: sort sources on login view

This commit is contained in:
Jens Langhammer 2020-02-23 20:16:25 +01:00
parent 6e9d297f02
commit 70ede8581a
2 changed files with 3 additions and 7 deletions

View file

@ -7,7 +7,3 @@ const-rgx=[a-zA-Z0-9_]{1,40}$
ignored-modules=django-otp ignored-modules=django-otp
jobs=4 jobs=4
[SIMILARITIES]
# Minimum lines number of a similarity.
min-similarity-lines=20

View file

@ -44,13 +44,13 @@ class LoginView(UserPassesTestMixin, FormView):
kwargs["primary_action"] = _("Log in") kwargs["primary_action"] = _("Log in")
kwargs["show_sign_up_notice"] = CONFIG.y("passbook.sign_up.enabled") kwargs["show_sign_up_notice"] = CONFIG.y("passbook.sign_up.enabled")
kwargs["sources"] = [] kwargs["sources"] = []
sources = Source.objects.filter(enabled=True).select_subclasses() sources = (
Source.objects.filter(enabled=True).order_by("name").select_subclasses()
)
for source in sources: for source in sources:
ui_login_button = source.ui_login_button ui_login_button = source.ui_login_button
if ui_login_button: if ui_login_button:
kwargs["sources"].append(ui_login_button) kwargs["sources"].append(ui_login_button)
# if kwargs["sources"]:
# self.template_name = "login/with_sources.html"
return super().get_context_data(**kwargs) return super().get_context_data(**kwargs)
def get_user(self, uid_value) -> Optional[User]: def get_user(self, uid_value) -> Optional[User]: