Make secret settings actually work.
authorMikael Frykholm <mikael@frykholm.com>
Mon, 14 May 2018 11:22:04 +0000 (13:22 +0200)
committerMikael Frykholm <mikael@frykholm.com>
Mon, 14 May 2018 11:22:04 +0000 (13:22 +0200)
tranquillity/auth_backend.py
tranquillity/settings.py

index bd410d1..e8c682a 100644 (file)
@@ -2,14 +2,15 @@ from django.contrib.auth import get_user_model
 from django.contrib.auth.models import User
 from django.contrib.auth.backends import ModelBackend
 import requests
+from django.conf import settings
 
 class EmailBackend(ModelBackend):
     def fetch_fortnox(self):
         """ Fetch all active customers from Fortnox API. Return as dict keyed on email."""
         res = None
         customers = {}
-        headers = {"Access-Token":FORTNOX_Access_Token,
-           "Client-Secret":FORTNOX_Client_Secret,
+        headers = {"Access-Token":settings.FORTNOX_ACCESS_TOKEN,
+           "Client-Secret":settings.FORTNOX_CLIENT_SECRET,
            "Content-Type":"application/json",
            "Accept":"application/json" }
 
index 74d30b0..b01cf5a 100644 (file)
@@ -11,7 +11,10 @@ https://docs.djangoproject.com/en/2.0/ref/settings/
 """
 
 import os
-from settings_secret import *
+try:
+    from .settings_secret import *
+except ImportError:
+    pass
 
 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))