diff options
author | Aurélien Bompard <aurelien@bompard.org> | 2017-07-21 09:05:04 +0000 |
---|---|---|
committer | Aurélien Bompard <aurelien@bompard.org> | 2017-07-21 09:06:09 +0000 |
commit | f40ce9d9697751b916abe7f1d38bc928b48612c5 (patch) | |
tree | eb645846ab93c95ec91a1b8a1b2c1e4d6fa2397c | |
parent | a7a67a72ef03dba780be867e04f1e96589f1a543 (diff) | |
download | ansible-f40ce9d9697751b916abe7f1d38bc928b48612c5.tar.gz ansible-f40ce9d9697751b916abe7f1d38bc928b48612c5.tar.xz ansible-f40ce9d9697751b916abe7f1d38bc928b48612c5.zip |
Mailman: split the django_fedora module
Some imports need to read the config file, which creates a import loop.
-rw-r--r-- | roles/mailman/files/django_fedora.py | 16 | ||||
-rw-r--r-- | roles/mailman/files/django_fedora_nosignup.py | 14 | ||||
-rw-r--r-- | roles/mailman/tasks/main.yml | 9 | ||||
-rw-r--r-- | roles/mailman/templates/settings.py.j2 | 8 |
4 files changed, 24 insertions, 23 deletions
diff --git a/roles/mailman/files/django_fedora.py b/roles/mailman/files/django_fedora.py index b1b88dfb4..b8cda8a07 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 000000000..22a2df04c --- /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 3a36a0e52..2f9844a1c 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 19b203999..ba896da70 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. |