providers/*: remove path-based import from all providers

This commit is contained in:
Jens Langhammer 2020-07-20 16:03:55 +02:00
parent 6aefd072c8
commit 6fa825e372
5 changed files with 28 additions and 8 deletions

View file

@ -93,6 +93,10 @@ class Provider(models.Model):
objects = InheritanceManager()
def form(self) -> Type[ModelForm]:
"""Return Form class used to edit this object"""
raise NotImplementedError
# This class defines no field for easier inheritance
def __str__(self):
if hasattr(self, "name"):

View file

@ -1,9 +1,10 @@
"""passbook app_gw models"""
import string
from random import SystemRandom
from typing import Optional
from typing import Optional, Type
from django.db import models
from django.forms import ModelForm
from django.http import HttpRequest
from django.utils.translation import gettext as _
from oidc_provider.models import Client
@ -23,7 +24,10 @@ class ApplicationGatewayProvider(Provider):
client = models.ForeignKey(Client, on_delete=models.CASCADE)
form = "passbook.providers.app_gw.forms.ApplicationGatewayProviderForm"
def form(self) -> Type[ModelForm]:
from passbook.providers.app_gw.forms import ApplicationGatewayProviderForm
return ApplicationGatewayProviderForm
def html_setup_urls(self, request: HttpRequest) -> Optional[str]:
"""return template and context modal with URLs for authorize, token, openid-config, etc"""

View file

@ -1,7 +1,8 @@
"""Oauth2 provider product extension"""
from typing import Optional
from typing import Optional, Type
from django.forms import ModelForm
from django.http import HttpRequest
from django.shortcuts import reverse
from django.utils.translation import gettext as _
@ -16,7 +17,10 @@ class OAuth2Provider(Provider, AbstractApplication):
This Provider also supports the GitHub-pretend mode for Applications that don't support
generic OAuth."""
form = "passbook.providers.oauth.forms.OAuth2ProviderForm"
def form(self) -> Type[ModelForm]:
from passbook.providers.oauth.forms import OAuth2ProviderForm
return OAuth2ProviderForm
def __str__(self):
return self.name

View file

@ -1,7 +1,8 @@
"""oidc models"""
from typing import Optional
from typing import Optional, Type
from django.db import models
from django.forms import ModelForm
from django.http import HttpRequest
from django.shortcuts import reverse
from django.utils.translation import gettext as _
@ -20,7 +21,10 @@ class OpenIDProvider(Provider):
oidc_client = models.OneToOneField(Client, on_delete=models.CASCADE)
form = "passbook.providers.oidc.forms.OIDCProviderForm"
def form(self) -> Type[ModelForm]:
from passbook.providers.oidc.forms import OIDCProviderForm
return OIDCProviderForm
@property
def name(self):

View file

@ -1,7 +1,8 @@
"""passbook saml_idp Models"""
from typing import Optional
from typing import Optional, Type
from django.db import models
from django.forms import ModelForm
from django.http import HttpRequest
from django.shortcuts import reverse
from django.utils.translation import ugettext_lazy as _
@ -101,7 +102,10 @@ class SAMLProvider(Provider):
),
)
form = "passbook.providers.saml.forms.SAMLProviderForm"
def form(self) -> Type[ModelForm]:
from passbook.providers.saml.forms import SAMLProviderForm
return SAMLProviderForm
def __str__(self):
return self.name