fix: add docs, tests; tweak some handler method signatures
This commit is contained in:
parent
e4a4e85cf6
commit
d11e186df9
16 changed files with 345 additions and 15 deletions
|
@ -36,6 +36,11 @@ class WuttaCoreposAppProvider(AppProvider):
|
|||
"""
|
||||
|
||||
def get_corepos_handler(self, **kwargs):
|
||||
"""
|
||||
Get the configured CORE-POS integration handler.
|
||||
|
||||
:rtype: :class:`~wutta_corepos.handler.CoreposHandler`
|
||||
"""
|
||||
if not hasattr(self, 'corepos_handler'):
|
||||
spec = self.config.get(f'{self.appname}.corepos_handler',
|
||||
default='wutta_corepos.handler:CoreposHandler')
|
||||
|
|
|
@ -40,7 +40,7 @@ class WuttaCoreposConfigExtension(WuttaConfigExtension):
|
|||
* ``office_trans`` (default name ``core_trans``)
|
||||
* ``office_arch`` (default name ``trans_archive``)
|
||||
|
||||
The config object will be given the following attributes:
|
||||
The :term:`config object` will be given the following attributes:
|
||||
|
||||
.. data:: core_office_op_engine
|
||||
|
||||
|
|
|
@ -38,6 +38,11 @@ class CoreposHandler(GenericHandler):
|
|||
Returns the base URL for the CORE Office web app.
|
||||
|
||||
Note that the return value is stripped of final slash.
|
||||
|
||||
:param require: If true, an error is raised when URL cannot be
|
||||
determined.
|
||||
|
||||
:returns: URL as string.
|
||||
"""
|
||||
url = self.config.get('corepos.office.url', require=require)
|
||||
if url:
|
||||
|
@ -45,40 +50,64 @@ class CoreposHandler(GenericHandler):
|
|||
|
||||
def get_office_department_url(
|
||||
self,
|
||||
number,
|
||||
dept_id,
|
||||
office_url=None,
|
||||
require=False,
|
||||
**kwargs):
|
||||
require=False):
|
||||
"""
|
||||
Returns the CORE Office URL for a Department.
|
||||
|
||||
:param dept_id: Department ID for the URL.
|
||||
|
||||
:param office_url: Root URL from :meth:`get_office_url()`.
|
||||
|
||||
:param require: If true, an error is raised when URL cannot be
|
||||
determined.
|
||||
|
||||
:returns: URL as string.
|
||||
"""
|
||||
if not office_url:
|
||||
office_url = self.get_office_url(require=require)
|
||||
if office_url:
|
||||
return f'{office_url}/item/departments/DepartmentEditor.php?did={number}'
|
||||
return f'{office_url}/item/departments/DepartmentEditor.php?did={dept_id}'
|
||||
|
||||
def get_office_likecode_url(
|
||||
self,
|
||||
id,
|
||||
likecode_id,
|
||||
office_url=None,
|
||||
require=False,
|
||||
**kwargs):
|
||||
require=False):
|
||||
"""
|
||||
Returns the CORE Office URL for a Like Code.
|
||||
|
||||
:param likecode_id: Like Code ID for the URL.
|
||||
|
||||
:param office_url: Root URL from :meth:`get_office_url()`.
|
||||
|
||||
:param require: If true, an error is raised when URL cannot be
|
||||
determined.
|
||||
|
||||
:returns: URL as string.
|
||||
"""
|
||||
if not office_url:
|
||||
office_url = self.get_office_url(require=require)
|
||||
if office_url:
|
||||
return f'{office_url}/item/likecodes/LikeCodeEditor.php?start={id}'
|
||||
return f'{office_url}/item/likecodes/LikeCodeEditor.php?start={likecode_id}'
|
||||
|
||||
def get_office_product_url(
|
||||
self,
|
||||
upc,
|
||||
office_url=None,
|
||||
require=False,
|
||||
**kwargs):
|
||||
require=False):
|
||||
"""
|
||||
Returns the CORE Office URL for a Product.
|
||||
|
||||
:param upc: UPC for the URL.
|
||||
|
||||
:param office_url: Root URL from :meth:`get_office_url()`.
|
||||
|
||||
:param require: If true, an error is raised when URL cannot be
|
||||
determined.
|
||||
|
||||
:returns: URL as string.
|
||||
"""
|
||||
if not office_url:
|
||||
office_url = self.get_office_url(require=require)
|
||||
|
@ -87,14 +116,22 @@ class CoreposHandler(GenericHandler):
|
|||
|
||||
def get_office_vendor_url(
|
||||
self,
|
||||
id,
|
||||
vend_id,
|
||||
office_url=None,
|
||||
require=False,
|
||||
**kwargs):
|
||||
require=False):
|
||||
"""
|
||||
Returns the CORE Office URL for a Vendor.
|
||||
|
||||
:param vend_id: Vendor ID for the URL.
|
||||
|
||||
:param office_url: Root URL from :meth:`get_office_url()`.
|
||||
|
||||
:param require: If true, an error is raised when URL cannot be
|
||||
determined.
|
||||
|
||||
:returns: URL as string.
|
||||
"""
|
||||
if not office_url:
|
||||
office_url = self.get_office_url(require=require)
|
||||
if office_url:
|
||||
return f'{office_url}/item/vendors/VendorIndexPage.php?vid={id}'
|
||||
return f'{office_url}/item/vendors/VendorIndexPage.php?vid={vend_id}'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue