From ffd451a7003f94db48e546b1ddc68cc78d38f94c Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 14 Mar 2020 18:38:12 -0500 Subject: [PATCH] Add convenience function for `core_office_url()` config --- rattail_corepos/config.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/rattail_corepos/config.py b/rattail_corepos/config.py index 69fe00f..8001866 100644 --- a/rattail_corepos/config.py +++ b/rattail_corepos/config.py @@ -47,3 +47,18 @@ class RattailCOREPOSExtension(ConfigExtension): config.coretrans_engines = engines config.coretrans_engine = engines.get('default') CoreTransSession.configure(bind=config.coretrans_engine) + + +def core_office_url(config, require=False, **kwargs): + """ + Returns the base URL for the CORE Office web app. Note that this URL will + *not* have a trailing slash. + """ + args = ['corepos', 'office.url'] + if require: + url = config.require(*args, **kwargs) + return url.rstrip('/') + else: + url = config.get(*args, **kwargs) + if url: + return url.rstrip('/')