diff --git a/roles/mailman/files/django_fedora.py b/roles/mailman/files/django_fedora.py index b1b88dfb4c..b8cda8a077 100644 --- a/roles/mailman/files/django_fedora.py +++ b/roles/mailman/files/django_fedora.py @@ -13,19 +13,3 @@ def exclude_useless_errors(record): if isinstance(exc_value, excluded_class): return False return True - - -# Disable local signup - -from allauth.account.adapter import DefaultAccountAdapter -from allauth.socialaccount.adapter import DefaultSocialAccountAdapter - -class NoLocalSignUpAdapter(DefaultAccountAdapter): - - def is_open_for_signup(self, request): - return False - -class SignUpEnabledSocialAdapter(DefaultSocialAccountAdapter): - - def is_open_for_signup(self, request, sociallogin): - return True diff --git a/roles/mailman/files/django_fedora_nosignup.py b/roles/mailman/files/django_fedora_nosignup.py new file mode 100644 index 0000000000..22a2df04c4 --- /dev/null +++ b/roles/mailman/files/django_fedora_nosignup.py @@ -0,0 +1,14 @@ +# Disable local signup + +from allauth.account.adapter import DefaultAccountAdapter +from allauth.socialaccount.adapter import DefaultSocialAccountAdapter + +class NoLocalSignUpAdapter(DefaultAccountAdapter): + + def is_open_for_signup(self, request): + return False + +class SignUpEnabledSocialAdapter(DefaultSocialAccountAdapter): + + def is_open_for_signup(self, request, sociallogin): + return True diff --git a/roles/mailman/tasks/main.yml b/roles/mailman/tasks/main.yml index 3a36a0e52e..2f9844a1cf 100644 --- a/roles/mailman/tasks/main.yml +++ b/roles/mailman/tasks/main.yml @@ -267,10 +267,13 @@ - config - mailman -- name: install the django_fedora module - copy: src=django_fedora.py - dest="{{ mailman_webui_confdir }}/django_fedora.py" +- name: install the fedora-specific modules + copy: src={{ item }}.py + dest="{{ mailman_webui_confdir }}/{{ item }}.py" owner=root group=root mode=0644 + with_items: + - django_fedora + - django_fedora_nosignup tags: - config - mailman diff --git a/roles/mailman/templates/settings.py.j2 b/roles/mailman/templates/settings.py.j2 index 19b2039997..ba896da70b 100644 --- a/roles/mailman/templates/settings.py.j2 +++ b/roles/mailman/templates/settings.py.j2 @@ -6,6 +6,8 @@ Django settings for HyperKitty + Postorius import os BASE_DIR = os.path.dirname(os.path.abspath(__file__)) +import django_fedora + # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '{{ mailman_hyperkitty_cookie_key }}' @@ -240,8 +242,8 @@ ACCOUNT_EMAIL_VERIFICATION = "mandatory" ACCOUNT_DEFAULT_HTTP_PROTOCOL = "https" ACCOUNT_UNIQUE_EMAIL = True # Disable local signup -ACCOUNT_ADAPTER = "django_fedora.NoLocalSignUpAdapter" -SOCIALACCOUNT_ADAPTER = "django_fedora.SignUpEnabledSocialAdapter" +ACCOUNT_ADAPTER = "django_fedora_nosignup.NoLocalSignUpAdapter" +SOCIALACCOUNT_ADAPTER = "django_fedora_nosignup.SignUpEnabledSocialAdapter" SOCIALACCOUNT_PROVIDERS = { 'openid': { @@ -337,8 +339,6 @@ REST_FRAMEWORK = { } -import django_fedora - # A sample logging configuration. The only tangible logging # performed by this configuration is to send an email to # the site admins on every HTTP 500 error when DEBUG=False.