*: fix formatting

This commit is contained in:
Jens Langhammer 2020-11-22 22:14:36 +01:00
parent d5e34bb71d
commit fa004876e9
8 changed files with 28 additions and 17 deletions

View file

@ -1,7 +1,6 @@
"""passbook HaveIBeenPwned Policy forms""" """passbook HaveIBeenPwned Policy forms"""
from django import forms from django import forms
from django.utils.translation import gettext as _
from passbook.policies.forms import GENERAL_FIELDS from passbook.policies.forms import GENERAL_FIELDS
from passbook.policies.hibp.models import HaveIBeenPwendPolicy from passbook.policies.hibp.models import HaveIBeenPwendPolicy

View file

@ -21,7 +21,12 @@ def ldap_sync_all():
@CELERY_APP.task(bind=True, base=MonitoredTask) @CELERY_APP.task(bind=True, base=MonitoredTask)
def ldap_sync(self: MonitoredTask, source_pk: int): def ldap_sync(self: MonitoredTask, source_pk: int):
"""Synchronization of an LDAP Source""" """Synchronization of an LDAP Source"""
try:
source: LDAPSource = LDAPSource.objects.get(pk=source_pk) source: LDAPSource = LDAPSource.objects.get(pk=source_pk)
except LDAPSource.DoesNotExist:
# Because the source couldn't be found, we don't have a UID
# to set the state with
return
self.set_uid(slugify(source.name)) self.set_uid(slugify(source.name))
try: try:
syncer = LDAPSynchronizer(source) syncer = LDAPSynchronizer(source)

View file

@ -53,7 +53,5 @@ class PasswordStageForm(forms.ModelForm):
fields = ["name", "backends", "configure_flow", "failed_attempts_before_cancel"] fields = ["name", "backends", "configure_flow", "failed_attempts_before_cancel"]
widgets = { widgets = {
"name": forms.TextInput(), "name": forms.TextInput(),
"backends": forms.SelectMultiple( "backends": forms.SelectMultiple(get_authentication_backends()),
get_authentication_backends()
),
} }

View file

@ -4,10 +4,10 @@ from typing import Optional, Type
from django.contrib.postgres.fields import ArrayField from django.contrib.postgres.fields import ArrayField
from django.db import models from django.db import models
from django.forms import ModelForm from django.forms import ModelForm
from django.shortcuts import reverse
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from django.views import View from django.views import View
from rest_framework.serializers import BaseSerializer from rest_framework.serializers import BaseSerializer
from django.shortcuts import reverse
from passbook.flows.models import ConfigurableStage, Stage from passbook.flows.models import ConfigurableStage, Stage
@ -51,7 +51,9 @@ class PasswordStage(ConfigurableStage, Stage):
def ui_user_settings(self) -> Optional[str]: def ui_user_settings(self) -> Optional[str]:
if not self.configure_flow: if not self.configure_flow:
return None return None
return reverse("passbook_stages_password:user-settings", kwargs={"stage_uuid": self.pk}) return reverse(
"passbook_stages_password:user-settings", kwargs={"stage_uuid": self.pk}
)
def __str__(self): def __str__(self):
return f"Password Stage {self.name}" return f"Password Stage {self.name}"

View file

@ -5,6 +5,8 @@ from passbook.stages.password.views import UserSettingsCardView
urlpatterns = [ urlpatterns = [
path( path(
"<uuid:stage_uuid>/change-card/", UserSettingsCardView.as_view(), name="user-settings" "<uuid:stage_uuid>/change-card/",
UserSettingsCardView.as_view(),
name="user-settings",
), ),
] ]

View file

@ -1,18 +1,23 @@
"""password stage user settings card"""
from typing import Any from typing import Any
from django.contrib.auth.mixins import LoginRequiredMixin
from django.views.generic import TemplateView
from django.contrib.auth.mixins import LoginRequiredMixin
from django.shortcuts import reverse from django.shortcuts import reverse
from django.utils.http import urlencode from django.utils.http import urlencode
from django.views.generic import TemplateView
from passbook.flows.views import NEXT_ARG_NAME from passbook.flows.views import NEXT_ARG_NAME
class UserSettingsCardView(LoginRequiredMixin, TemplateView): class UserSettingsCardView(LoginRequiredMixin, TemplateView):
"""Card shown on user settings page to allow user to change their password"""
template_name = "stages/password/user-settings-card.html" template_name = "stages/password/user-settings-card.html"
def get_context_data(self, **kwargs: Any) -> dict[str, Any]: def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
base_url = reverse("passbook_flows:configure", kwargs={"stage_uuid": self.kwargs["stage_uuid"]}) base_url = reverse(
"passbook_flows:configure", kwargs={"stage_uuid": self.kwargs["stage_uuid"]}
)
args = urlencode({NEXT_ARG_NAME: reverse("passbook_core:user-settings")}) args = urlencode({NEXT_ARG_NAME: reverse("passbook_core:user-settings")})
kwargs = super().get_context_data(**kwargs) kwargs = super().get_context_data(**kwargs)