Skip to content

Commit

Permalink
ledger.settings_base: add VALID_SYSTEMS parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Percival committed Feb 27, 2018
1 parent d22e37a commit 0c5bf47
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ledger/payments/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ def validSystem(system_id):
''' Check if the system is in the itsystems register.
:return: Boolean
'''
if settings.CMS_URL:
if settings.VALID_SYSTEMS:
return system_id in settings.VALID_SYSTEMS
elif settings.CMS_URL:
# TODO: prefetch whole systems register list, store in django cache, use that instead of doing a GET request every time
res = requests.get('{}?system_id={}'.format(settings.CMS_URL,system_id), auth=(settings.LEDGER_USER,settings.LEDGER_PASS))
try:
Expand All @@ -72,7 +74,7 @@ def validSystem(system_id):
except:
raise
else:
logger.warn('CMS_URL not set, ledger.payments.utils.validSystem will always return true')
logger.warn('VALID_SYSTEMS or CMS_URL not set, ledger.payments.utils.validSystem will always return true')
return True

def calculate_excl_gst(amount):
Expand Down
2 changes: 2 additions & 0 deletions ledger/settings_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@

# Ledger settings
CMS_URL=env('CMS_URL',None)
VALID_SYSTEMS=env('VALID_SYSTEMS', '')
VALID_SYSTEMS=VALID_SYSTEMS.split(',') if VALID_SYSTEMS else []
LEDGER_USER=env('LEDGER_USER',None)
LEDGER_PASS=env('LEDGER_PASS')
NOTIFICATION_EMAIL=env('NOTIFICATION_EMAIL')
Expand Down

0 comments on commit 0c5bf47

Please sign in to comment.