mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
check if registration should be open in python
This commit is contained in:
parent
c872412d04
commit
a6c6b5c248
@ -14,6 +14,7 @@ from crispy_forms.layout import Layout, Field
|
|||||||
from crispy_forms.bootstrap import PrependedText, AppendedText, PrependedAppendedText, StrictButton, Div
|
from crispy_forms.bootstrap import PrependedText, AppendedText, PrependedAppendedText, StrictButton, Div
|
||||||
|
|
||||||
from allauth.account.forms import SignupForm, set_form_field_order
|
from allauth.account.forms import SignupForm, set_form_field_order
|
||||||
|
from allauth.account.adapter import DefaultAccountAdapter
|
||||||
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
|
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
|
||||||
|
|
||||||
from part.models import PartCategory
|
from part.models import PartCategory
|
||||||
@ -251,7 +252,23 @@ class CustomSignupForm(SignupForm):
|
|||||||
return cleaned_data
|
return cleaned_data
|
||||||
|
|
||||||
|
|
||||||
class CustomSocialAccountAdapter(DefaultSocialAccountAdapter):
|
class RegistratonMixin:
|
||||||
|
"""
|
||||||
|
Mixin to check if registration should be enabled
|
||||||
|
"""
|
||||||
|
def is_open_for_signup(self, request):
|
||||||
|
if InvenTreeSetting.get_setting('LOGIN_ENABLE_REG', True):
|
||||||
|
return super().is_open_for_signup(request)
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
class CustomAccountAdapter(RegistratonMixin, DefaultAccountAdapter):
|
||||||
|
"""
|
||||||
|
Override of adapter to use dynamic settings
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class CustomSocialAccountAdapter(RegistratonMixin, DefaultSocialAccountAdapter):
|
||||||
"""
|
"""
|
||||||
Override of adapter to use dynamic settings
|
Override of adapter to use dynamic settings
|
||||||
"""
|
"""
|
||||||
|
@ -682,3 +682,4 @@ ACCOUNT_FORMS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SOCIALACCOUNT_ADAPTER = 'InvenTree.forms.CustomSocialAccountAdapter'
|
SOCIALACCOUNT_ADAPTER = 'InvenTree.forms.CustomSocialAccountAdapter'
|
||||||
|
ACCOUNT_ADAPTER = 'InvenTree.forms.CustomAccountAdapter'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user