Add rattail provider for CORE-POS Integration

and use it to generate CORE Office URLs
This commit is contained in:
Lance Edgar 2023-09-14 12:57:14 -05:00
parent 4bff0832e8
commit 271895fa83
4 changed files with 125 additions and 21 deletions

View file

@ -183,26 +183,22 @@ class RattailCOREPOSExtension(ConfigExtension):
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('/')
""" DEPRECATED """
warnings.warn("core_office_url() function is deprecated; please use "
"corepos_handler.get_office_url() instead",
DeprecationWarning, stacklevel=2)
app = config.get_app()
corepos = app.get_corepos_handler()
return corepos.get_office_url(require=require, **kwargs)
def core_office_customer_account_url(config, card_number, office_url=None):
"""
Returns the CORE Office URL for the customer account with the given card
number.
"""
if not office_url:
office_url = core_office_url(config, require=True)
return '{}/mem/MemberEditor.php?memNum={}'.format(
office_url, card_number)
""" DEPRECATED """
warnings.warn("core_office_customer_account_url() function is deprecated; please use "
"corepos_handler.get_office_customer_account_url() instead",
DeprecationWarning, stacklevel=2)
app = config.get_app()
corepos = app.get_corepos_handler()
return corepos.get_office_member_url(card_number, office_url=office_url, **kwargs)