From 744f12dccfccb8cf54392573f64c06e4e4b4cfbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sat, 20 Jun 2020 17:19:42 +0200 Subject: [PATCH] More idiomatic default settings --- authens/conf.py | 6 ++---- authens/shortcuts.py | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/authens/conf.py b/authens/conf.py index 6f542d2..04b5cb0 100644 --- a/authens/conf.py +++ b/authens/conf.py @@ -1,4 +1,2 @@ -default_settings = { - "LDAP_SERVER_URL": "ldaps://ldap.spi.ens.fr:636", - # TODO: CAS_SERVER_URL -} +LDAP_SERVER_URL = "ldaps://ldap.spi.ens.fr:636" +# TODO: CAS_SERVER_URL diff --git a/authens/shortcuts.py b/authens/shortcuts.py index 1707fca..580f57e 100644 --- a/authens/shortcuts.py +++ b/authens/shortcuts.py @@ -6,7 +6,7 @@ import ldap from django.conf import settings from django.contrib.auth import get_user_model -from authens.conf import default_settings +from authens import conf as default_conf from authens.models import CASAccount, OldCASAccount from authens.utils import parse_entrance_year @@ -25,7 +25,7 @@ def fetch_cas_account(cas_login): if not cas_login.isalnum(): raise ValueError("Illegal CAS login: {}".format(cas_login)) - ldap_url = getattr(settings, "LDAP_SERVER_URL", default_settings["LDAP_SERVER_URL"]) + ldap_url = getattr(settings, "LDAP_SERVER_URL", default_conf.LDAP_SERVER_URL) ldap_obj = ldap.initialize(ldap_url) res = ldap_obj.search_s( "dc=spi,dc=ens,dc=fr",