From 57fed2b92b4cbd20819e34756d5a293de912d510 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 12 May 2020 15:21:53 +0200 Subject: [PATCH] stages/user_delete: fix formatting --- passbook/core/tests/test_views_user.py | 1 - passbook/core/views/user.py | 5 +--- .../migrations/0005_auto_20200512_1158.py | 18 ++++++++++---- passbook/root/urls.py | 4 +++- .../user_delete/migrations/0001_initial.py | 24 +++++++++++++------ passbook/stages/user_delete/stage.py | 3 +-- passbook/stages/user_delete/tests.py | 9 ++----- 7 files changed, 38 insertions(+), 26 deletions(-) diff --git a/passbook/core/tests/test_views_user.py b/passbook/core/tests/test_views_user.py index ab4a75654..88e984f85 100644 --- a/passbook/core/tests/test_views_user.py +++ b/passbook/core/tests/test_views_user.py @@ -28,4 +28,3 @@ class TestUserViews(TestCase): self.assertEqual( self.client.get(reverse("passbook_core:user-settings")).status_code, 200 ) - diff --git a/passbook/core/views/user.py b/passbook/core/views/user.py index a6c6e0ada..bb575ee8e 100644 --- a/passbook/core/views/user.py +++ b/passbook/core/views/user.py @@ -1,12 +1,9 @@ """passbook core user views""" -from django.contrib import messages -from django.contrib.auth import logout from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.messages.views import SuccessMessageMixin -from django.shortcuts import reverse from django.urls import reverse_lazy from django.utils.translation import gettext as _ -from django.views.generic import DeleteView, UpdateView +from django.views.generic import UpdateView from passbook.core.forms.users import UserDetailForm diff --git a/passbook/flows/migrations/0005_auto_20200512_1158.py b/passbook/flows/migrations/0005_auto_20200512_1158.py index f6968079b..92998affc 100644 --- a/passbook/flows/migrations/0005_auto_20200512_1158.py +++ b/passbook/flows/migrations/0005_auto_20200512_1158.py @@ -6,13 +6,23 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('passbook_flows', '0004_auto_20200510_2310'), + ("passbook_flows", "0004_auto_20200510_2310"), ] operations = [ migrations.AlterField( - model_name='flow', - name='designation', - field=models.CharField(choices=[('authentication', 'Authentication'), ('invalidation', 'Invalidation'), ('enrollment', 'Enrollment'), ('unenrollment', 'Unrenollment'), ('recovery', 'Recovery'), ('password_change', 'Password Change')], max_length=100), + model_name="flow", + name="designation", + field=models.CharField( + choices=[ + ("authentication", "Authentication"), + ("invalidation", "Invalidation"), + ("enrollment", "Enrollment"), + ("unenrollment", "Unrenollment"), + ("recovery", "Recovery"), + ("password_change", "Password Change"), + ], + max_length=100, + ), ), ] diff --git a/passbook/root/urls.py b/passbook/root/urls.py index 67bc4af73..17eee10c0 100644 --- a/passbook/root/urls.py +++ b/passbook/root/urls.py @@ -11,7 +11,9 @@ from passbook.root.monitoring import MetricsView LOGGER = get_logger() admin.autodiscover() -admin.site.login = RedirectView.as_view(pattern_name="passbook_flows:default-authentication") +admin.site.login = RedirectView.as_view( + pattern_name="passbook_flows:default-authentication" +) admin.site.logout = RedirectView.as_view( pattern_name="passbook_flows:default-invalidate" ) diff --git a/passbook/stages/user_delete/migrations/0001_initial.py b/passbook/stages/user_delete/migrations/0001_initial.py index ca80b5565..f2e361a86 100644 --- a/passbook/stages/user_delete/migrations/0001_initial.py +++ b/passbook/stages/user_delete/migrations/0001_initial.py @@ -1,7 +1,7 @@ # Generated by Django 3.0.5 on 2020-05-12 11:59 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): @@ -9,19 +9,29 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('passbook_flows', '0005_auto_20200512_1158'), + ("passbook_flows", "0005_auto_20200512_1158"), ] operations = [ migrations.CreateModel( - name='UserDeleteStage', + name="UserDeleteStage", fields=[ - ('stage_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='passbook_flows.Stage')), + ( + "stage_ptr", + models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to="passbook_flows.Stage", + ), + ), ], options={ - 'verbose_name': 'User Delete Stage', - 'verbose_name_plural': 'User Delete Stages', + "verbose_name": "User Delete Stage", + "verbose_name_plural": "User Delete Stages", }, - bases=('passbook_flows.stage',), + bases=("passbook_flows.stage",), ), ] diff --git a/passbook/stages/user_delete/stage.py b/passbook/stages/user_delete/stage.py index 4c4d02fa1..aeed299ce 100644 --- a/passbook/stages/user_delete/stage.py +++ b/passbook/stages/user_delete/stage.py @@ -1,11 +1,10 @@ """Delete stage logic""" from django.contrib import messages -from django.contrib.auth.backends import ModelBackend from django.http import HttpRequest, HttpResponse from django.utils.translation import gettext as _ +from django.views.generic import FormView from structlog import get_logger -from django.views.generic import FormView from passbook.core.models import User from passbook.flows.planner import PLAN_CONTEXT_PENDING_USER from passbook.flows.stage import AuthenticationStage diff --git a/passbook/stages/user_delete/tests.py b/passbook/stages/user_delete/tests.py index 040da90b0..d4aeb2f25 100644 --- a/passbook/stages/user_delete/tests.py +++ b/passbook/stages/user_delete/tests.py @@ -1,7 +1,4 @@ """delete tests""" -import string -from random import SystemRandom - from django.shortcuts import reverse from django.test import Client, TestCase @@ -9,8 +6,6 @@ from passbook.core.models import User from passbook.flows.models import Flow, FlowDesignation, FlowStageBinding from passbook.flows.planner import PLAN_CONTEXT_PENDING_USER, FlowPlan from passbook.flows.views import SESSION_KEY_PLAN -from passbook.stages.prompt.stage import PLAN_CONTEXT_PROMPT -from passbook.stages.user_delete.forms import UserDeleteStageForm from passbook.stages.user_delete.models import UserDeleteStage @@ -19,7 +14,7 @@ class TestUserDeleteStage(TestCase): def setUp(self): super().setUp() - self.username = 'qerqwerqrwqwerwq' + self.username = "qerqwerqrwqwerwq" self.user = User.objects.create(username=self.username, email="test@beryju.org") self.client = Client() @@ -58,7 +53,7 @@ class TestUserDeleteStage(TestCase): reverse( "passbook_flows:flow-executor", kwargs={"flow_slug": self.flow.slug} ), - {} + {}, ) self.assertEqual(response.status_code, 302) self.assertFalse(User.objects.filter(username=self.username).exists())