stages/*: remove path-based import from all stages
This commit is contained in:
parent
6fa825e372
commit
a3d92ebc0a
|
@ -1,6 +1,10 @@
|
|||
"""passbook captcha stage"""
|
||||
from typing import Type
|
||||
|
||||
from django.db import models
|
||||
from django.forms import ModelForm
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views import View
|
||||
|
||||
from passbook.flows.models import Stage
|
||||
|
||||
|
@ -19,8 +23,15 @@ class CaptchaStage(Stage):
|
|||
)
|
||||
)
|
||||
|
||||
type = "passbook.stages.captcha.stage.CaptchaStage"
|
||||
form = "passbook.stages.captcha.forms.CaptchaStageForm"
|
||||
def type(self) -> Type[View]:
|
||||
from passbook.stages.captcha.stage import CaptchaStageView
|
||||
|
||||
return CaptchaStageView
|
||||
|
||||
def form(self) -> Type[ModelForm]:
|
||||
from passbook.stages.captcha.forms import CaptchaStageForm
|
||||
|
||||
return CaptchaStageForm
|
||||
|
||||
def __str__(self):
|
||||
return f"Captcha Stage {self.name}"
|
||||
|
|
|
@ -6,7 +6,7 @@ from passbook.flows.stage import StageView
|
|||
from passbook.stages.captcha.forms import CaptchaForm
|
||||
|
||||
|
||||
class CaptchaStage(FormView, StageView):
|
||||
class CaptchaStageView(FormView, StageView):
|
||||
"""Simple captcha checker, logic is handeled in django-captcha module"""
|
||||
|
||||
form_class = CaptchaForm
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
"""passbook consent stage"""
|
||||
from typing import Type
|
||||
|
||||
from django.forms import ModelForm
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views import View
|
||||
|
||||
from passbook.flows.models import Stage
|
||||
|
||||
|
@ -7,8 +11,15 @@ from passbook.flows.models import Stage
|
|||
class ConsentStage(Stage):
|
||||
"""Prompt the user for confirmation."""
|
||||
|
||||
type = "passbook.stages.consent.stage.ConsentStage"
|
||||
form = "passbook.stages.consent.forms.ConsentStageForm"
|
||||
def type(self) -> Type[View]:
|
||||
from passbook.stages.consent.stage import ConsentStageView
|
||||
|
||||
return ConsentStageView
|
||||
|
||||
def form(self) -> Type[ModelForm]:
|
||||
from passbook.stages.consent.forms import ConsentStageForm
|
||||
|
||||
return ConsentStageForm
|
||||
|
||||
def __str__(self):
|
||||
return f"Consent Stage {self.name}"
|
||||
|
|
|
@ -9,7 +9,7 @@ from passbook.stages.consent.forms import ConsentForm
|
|||
PLAN_CONTEXT_CONSENT_TEMPLATE = "consent_template"
|
||||
|
||||
|
||||
class ConsentStage(FormView, StageView):
|
||||
class ConsentStageView(FormView, StageView):
|
||||
"""Simple consent checker."""
|
||||
|
||||
form_class = ConsentForm
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
"""dummy stage models"""
|
||||
from typing import Type
|
||||
|
||||
from django.forms import ModelForm
|
||||
from django.utils.translation import gettext as _
|
||||
from django.views import View
|
||||
|
||||
from passbook.flows.models import Stage
|
||||
|
||||
|
@ -9,8 +13,15 @@ class DummyStage(Stage):
|
|||
|
||||
__debug_only__ = True
|
||||
|
||||
type = "passbook.stages.dummy.stage.DummyStage"
|
||||
form = "passbook.stages.dummy.forms.DummyStageForm"
|
||||
def type(self) -> Type[View]:
|
||||
from passbook.stages.dummy.stage import DummyStageView
|
||||
|
||||
return DummyStageView
|
||||
|
||||
def form(self) -> Type[ModelForm]:
|
||||
from passbook.stages.dummy.forms import DummyStageForm
|
||||
|
||||
return DummyStageForm
|
||||
|
||||
def __str__(self):
|
||||
return f"Dummy Stage {self.name}"
|
||||
|
|
|
@ -6,7 +6,7 @@ from django.http import HttpRequest
|
|||
from passbook.flows.stage import StageView
|
||||
|
||||
|
||||
class DummyStage(StageView):
|
||||
class DummyStageView(StageView):
|
||||
"""Dummy stage for testing with multiple stages"""
|
||||
|
||||
def post(self, request: HttpRequest):
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
"""email stage models"""
|
||||
from typing import Type
|
||||
|
||||
from django.core.mail import get_connection
|
||||
from django.core.mail.backends.base import BaseEmailBackend
|
||||
from django.db import models
|
||||
from django.forms import ModelForm
|
||||
from django.utils.translation import gettext as _
|
||||
from django.views import View
|
||||
|
||||
from passbook.flows.models import Stage
|
||||
|
||||
|
@ -40,8 +44,15 @@ class EmailStage(Stage):
|
|||
choices=EmailTemplates.choices, default=EmailTemplates.PASSWORD_RESET
|
||||
)
|
||||
|
||||
type = "passbook.stages.email.stage.EmailStageView"
|
||||
form = "passbook.stages.email.forms.EmailStageForm"
|
||||
def type(self) -> Type[View]:
|
||||
from passbook.stages.email.stage import EmailStageView
|
||||
|
||||
return EmailStageView
|
||||
|
||||
def form(self) -> Type[ModelForm]:
|
||||
from passbook.stages.email.forms import EmailStageForm
|
||||
|
||||
return EmailStageForm
|
||||
|
||||
@property
|
||||
def backend(self) -> BaseEmailBackend:
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
"""identification stage models"""
|
||||
from typing import Type
|
||||
|
||||
from django.contrib.postgres.fields import ArrayField
|
||||
from django.db import models
|
||||
from django.forms import ModelForm
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views import View
|
||||
|
||||
from passbook.flows.models import Flow, Stage
|
||||
|
||||
|
@ -52,8 +56,15 @@ class IdentificationStage(Stage):
|
|||
),
|
||||
)
|
||||
|
||||
type = "passbook.stages.identification.stage.IdentificationStageView"
|
||||
form = "passbook.stages.identification.forms.IdentificationStageForm"
|
||||
def type(self) -> Type[View]:
|
||||
from passbook.stages.identification.stage import IdentificationStageView
|
||||
|
||||
return IdentificationStageView
|
||||
|
||||
def form(self) -> Type[ModelForm]:
|
||||
from passbook.stages.identification.forms import IdentificationStageForm
|
||||
|
||||
return IdentificationStageForm
|
||||
|
||||
def __str__(self):
|
||||
return f"Identification Stage {self.name}"
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
"""invitation stage models"""
|
||||
from typing import Type
|
||||
from uuid import uuid4
|
||||
|
||||
from django.contrib.postgres.fields import JSONField
|
||||
from django.db import models
|
||||
from django.forms import ModelForm
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views import View
|
||||
|
||||
from passbook.core.models import User
|
||||
from passbook.flows.models import Stage
|
||||
|
@ -24,8 +27,15 @@ class InvitationStage(Stage):
|
|||
),
|
||||
)
|
||||
|
||||
type = "passbook.stages.invitation.stage.InvitationStageView"
|
||||
form = "passbook.stages.invitation.forms.InvitationStageForm"
|
||||
def type(self) -> Type[View]:
|
||||
from passbook.stages.invitation.stage import InvitationStageView
|
||||
|
||||
return InvitationStageView
|
||||
|
||||
def form(self) -> Type[ModelForm]:
|
||||
from passbook.stages.invitation.forms import InvitationStageForm
|
||||
|
||||
return InvitationStageForm
|
||||
|
||||
def __str__(self):
|
||||
return f"Invitation Stage {self.name}"
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
"""OTP Static models"""
|
||||
from typing import Optional
|
||||
from typing import Optional, Type
|
||||
|
||||
from django.db import models
|
||||
from django.forms import ModelForm
|
||||
from django.shortcuts import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views import View
|
||||
|
||||
from passbook.core.types import UIUserSettings
|
||||
from passbook.flows.models import Stage
|
||||
|
@ -14,8 +16,15 @@ class OTPStaticStage(Stage):
|
|||
|
||||
token_count = models.IntegerField(default=6)
|
||||
|
||||
type = "passbook.stages.otp_static.stage.OTPStaticStageView"
|
||||
form = "passbook.stages.otp_static.forms.OTPStaticStageForm"
|
||||
def type(self) -> Type[View]:
|
||||
from passbook.stages.otp_static.stage import OTPStaticStageView
|
||||
|
||||
return OTPStaticStageView
|
||||
|
||||
def form(self) -> Type[ModelForm]:
|
||||
from passbook.stages.otp_static.forms import OTPStaticStageForm
|
||||
|
||||
return OTPStaticStageForm
|
||||
|
||||
@property
|
||||
def ui_user_settings(self) -> Optional[UIUserSettings]:
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
"""OTP Time-based models"""
|
||||
from typing import Optional
|
||||
from typing import Optional, Type
|
||||
|
||||
from django.db import models
|
||||
from django.forms import ModelForm
|
||||
from django.shortcuts import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views import View
|
||||
|
||||
from passbook.core.types import UIUserSettings
|
||||
from passbook.flows.models import Stage
|
||||
|
@ -21,8 +23,15 @@ class OTPTimeStage(Stage):
|
|||
|
||||
digits = models.IntegerField(choices=TOTPDigits.choices)
|
||||
|
||||
type = "passbook.stages.otp_time.stage.OTPTimeStageView"
|
||||
form = "passbook.stages.otp_time.forms.OTPTimeStageForm"
|
||||
def type(self) -> Type[View]:
|
||||
from passbook.stages.otp_time.stage import OTPTimeStageView
|
||||
|
||||
return OTPTimeStageView
|
||||
|
||||
def form(self) -> Type[ModelForm]:
|
||||
from passbook.stages.otp_time.forms import OTPTimeStageForm
|
||||
|
||||
return OTPTimeStageForm
|
||||
|
||||
@property
|
||||
def ui_user_settings(self) -> Optional[UIUserSettings]:
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
"""OTP Validation Stage"""
|
||||
from typing import Type
|
||||
|
||||
from django.db import models
|
||||
from django.forms import ModelForm
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views import View
|
||||
|
||||
from passbook.flows.models import NotConfiguredAction, Stage
|
||||
|
||||
|
@ -12,8 +16,15 @@ class OTPValidateStage(Stage):
|
|||
choices=NotConfiguredAction.choices, default=NotConfiguredAction.SKIP
|
||||
)
|
||||
|
||||
type = "passbook.stages.otp_validate.stage.OTPValidateStageView"
|
||||
form = "passbook.stages.otp_validate.forms.OTPValidateStageForm"
|
||||
def type(self) -> Type[View]:
|
||||
from passbook.stages.otp_validate.stage import OTPValidateStageView
|
||||
|
||||
return OTPValidateStageView
|
||||
|
||||
def form(self) -> Type[ModelForm]:
|
||||
from passbook.stages.otp_validate.forms import OTPValidateStageForm
|
||||
|
||||
return OTPValidateStageForm
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"OTP Validation Stage {self.name}"
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
"""password stage models"""
|
||||
from typing import Optional
|
||||
from typing import Optional, Type
|
||||
|
||||
from django.contrib.postgres.fields import ArrayField
|
||||
from django.db import models
|
||||
from django.forms import ModelForm
|
||||
from django.shortcuts import reverse
|
||||
from django.utils.http import urlencode
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views import View
|
||||
|
||||
from passbook.core.types import UIUserSettings
|
||||
from passbook.flows.models import Flow, Stage
|
||||
|
@ -33,8 +35,15 @@ class PasswordStage(Stage):
|
|||
),
|
||||
)
|
||||
|
||||
type = "passbook.stages.password.stage.PasswordStage"
|
||||
form = "passbook.stages.password.forms.PasswordStageForm"
|
||||
def type(self) -> Type[View]:
|
||||
from passbook.stages.password.stage import PasswordStageView
|
||||
|
||||
return PasswordStageView
|
||||
|
||||
def form(self) -> Type[ModelForm]:
|
||||
from passbook.stages.password.forms import PasswordStageForm
|
||||
|
||||
return PasswordStageForm
|
||||
|
||||
@property
|
||||
def ui_user_settings(self) -> Optional[UIUserSettings]:
|
||||
|
|
|
@ -46,7 +46,7 @@ def authenticate(
|
|||
)
|
||||
|
||||
|
||||
class PasswordStage(FormView, StageView):
|
||||
class PasswordStageView(FormView, StageView):
|
||||
"""Authentication stage which authenticates against django's AuthBackend"""
|
||||
|
||||
form_class = PasswordForm
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
"""prompt models"""
|
||||
from typing import Type
|
||||
from uuid import uuid4
|
||||
|
||||
from django import forms
|
||||
from django.db import models
|
||||
from django.forms import ModelForm
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views import View
|
||||
|
||||
from passbook.flows.models import Stage
|
||||
from passbook.policies.models import PolicyBindingModel
|
||||
|
@ -117,8 +120,15 @@ class PromptStage(PolicyBindingModel, Stage):
|
|||
|
||||
fields = models.ManyToManyField(Prompt)
|
||||
|
||||
type = "passbook.stages.prompt.stage.PromptStageView"
|
||||
form = "passbook.stages.prompt.forms.PromptStageForm"
|
||||
def type(self) -> Type[View]:
|
||||
from passbook.stages.prompt.stage import PromptStageView
|
||||
|
||||
return PromptStageView
|
||||
|
||||
def form(self) -> Type[ModelForm]:
|
||||
from passbook.stages.prompt.forms import PromptStageForm
|
||||
|
||||
return PromptStageForm
|
||||
|
||||
def __str__(self):
|
||||
return f"Prompt Stage {self.name}"
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
"""delete stage models"""
|
||||
from typing import Type
|
||||
|
||||
from django.forms import ModelForm
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views import View
|
||||
|
||||
from passbook.flows.models import Stage
|
||||
|
||||
|
@ -8,8 +12,15 @@ class UserDeleteStage(Stage):
|
|||
"""Deletes the currently pending user without confirmation.
|
||||
Use with caution."""
|
||||
|
||||
type = "passbook.stages.user_delete.stage.UserDeleteStageView"
|
||||
form = "passbook.stages.user_delete.forms.UserDeleteStageForm"
|
||||
def type(self) -> Type[View]:
|
||||
from passbook.stages.user_delete.stage import UserDeleteStageView
|
||||
|
||||
return UserDeleteStageView
|
||||
|
||||
def form(self) -> Type[ModelForm]:
|
||||
from passbook.stages.user_delete.forms import UserDeleteStageForm
|
||||
|
||||
return UserDeleteStageForm
|
||||
|
||||
def __str__(self):
|
||||
return f"User Delete Stage {self.name}"
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
"""login stage models"""
|
||||
from typing import Type
|
||||
|
||||
from django.db import models
|
||||
from django.forms import ModelForm
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views import View
|
||||
|
||||
from passbook.flows.models import Stage
|
||||
|
||||
|
@ -16,8 +20,15 @@ class UserLoginStage(Stage):
|
|||
),
|
||||
)
|
||||
|
||||
type = "passbook.stages.user_login.stage.UserLoginStageView"
|
||||
form = "passbook.stages.user_login.forms.UserLoginStageForm"
|
||||
def type(self) -> Type[View]:
|
||||
from passbook.stages.user_login.stage import UserLoginStageView
|
||||
|
||||
return UserLoginStageView
|
||||
|
||||
def form(self) -> Type[ModelForm]:
|
||||
from passbook.stages.user_login.forms import UserLoginStageForm
|
||||
|
||||
return UserLoginStageForm
|
||||
|
||||
def __str__(self):
|
||||
return f"User Login Stage {self.name}"
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
"""logout stage models"""
|
||||
from typing import Type
|
||||
|
||||
from django.forms import ModelForm
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views import View
|
||||
|
||||
from passbook.flows.models import Stage
|
||||
|
||||
|
@ -7,8 +11,15 @@ from passbook.flows.models import Stage
|
|||
class UserLogoutStage(Stage):
|
||||
"""Resets the users current session."""
|
||||
|
||||
type = "passbook.stages.user_logout.stage.UserLogoutStageView"
|
||||
form = "passbook.stages.user_logout.forms.UserLogoutStageForm"
|
||||
def type(self) -> Type[View]:
|
||||
from passbook.stages.user_logout.stage import UserLogoutStageView
|
||||
|
||||
return UserLogoutStageView
|
||||
|
||||
def form(self) -> Type[ModelForm]:
|
||||
from passbook.stages.user_logout.forms import UserLogoutStageForm
|
||||
|
||||
return UserLogoutStageForm
|
||||
|
||||
def __str__(self):
|
||||
return f"User Logout Stage {self.name}"
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
"""write stage models"""
|
||||
from typing import Type
|
||||
|
||||
from django.forms import ModelForm
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views import View
|
||||
|
||||
from passbook.flows.models import Stage
|
||||
|
||||
|
@ -8,8 +12,15 @@ class UserWriteStage(Stage):
|
|||
"""Writes currently pending data into the pending user, or if no user exists,
|
||||
creates a new user with the data."""
|
||||
|
||||
type = "passbook.stages.user_write.stage.UserWriteStageView"
|
||||
form = "passbook.stages.user_write.forms.UserWriteStageForm"
|
||||
def type(self) -> Type[View]:
|
||||
from passbook.stages.user_write.stage import UserWriteStageView
|
||||
|
||||
return UserWriteStageView
|
||||
|
||||
def form(self) -> Type[ModelForm]:
|
||||
from passbook.stages.user_write.forms import UserWriteStageForm
|
||||
|
||||
return UserWriteStageForm
|
||||
|
||||
def __str__(self):
|
||||
return f"User Write Stage {self.name}"
|
||||
|
|
Reference in a new issue