diff --git a/tailbone_corepos/templates/core-pos/members/view.mako b/tailbone_corepos/templates/core-pos/members/view.mako deleted file mode 100644 index 848510a..0000000 --- a/tailbone_corepos/templates/core-pos/members/view.mako +++ /dev/null @@ -1,3 +0,0 @@ -## -*- coding: utf-8; -*- -<%inherit file="/core-pos/master/view.mako" /> -${parent.body()} diff --git a/tailbone_corepos/views/corepos/customers.py b/tailbone_corepos/views/corepos/customers.py index 3febc35..42ee7f9 100644 --- a/tailbone_corepos/views/corepos/customers.py +++ b/tailbone_corepos/views/corepos/customers.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2022 Lance Edgar +# Copyright © 2010-2023 Lance Edgar # # This file is part of Rattail. # @@ -48,6 +48,7 @@ class CustomerView(CoreOfficeMasterView): Base class for customer views. """ model_class = corepos.CustData + model_key = ('card_number', 'person_number') model_title = "CORE-POS Customer (Legacy)" model_title_plural = "CORE-POS Customers (Legacy)" url_prefix = '/core-pos/customers' diff --git a/tailbone_corepos/views/corepos/master.py b/tailbone_corepos/views/corepos/master.py index 48f00c0..1e7aaa5 100644 --- a/tailbone_corepos/views/corepos/master.py +++ b/tailbone_corepos/views/corepos/master.py @@ -92,6 +92,7 @@ class CoreMasterView(MasterView): Adds the URL for viewing the record/object within CORE Office, or else the reason for lack of such a URL. """ + kwargs = super().template_kwargs_view(**kwargs) obj = kwargs['instance'] # CORE Office URL diff --git a/tailbone_corepos/views/corepos/members.py b/tailbone_corepos/views/corepos/members.py index b526273..3395c5b 100644 --- a/tailbone_corepos/views/corepos/members.py +++ b/tailbone_corepos/views/corepos/members.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2022 Lance Edgar +# Copyright © 2010-2023 Lance Edgar # # This file is part of Rattail. # @@ -26,7 +26,7 @@ CORE-POS member views from corepos.db.office_op import model as corepos -from rattail_corepos.config import core_office_customer_account_url +from rattail_corepos.config import core_office_url, core_office_customer_account_url from webhelpers2.html import HTML, tags @@ -159,7 +159,9 @@ class MemberView(CoreOfficeMasterView): items = [] for customer in customers: text = str(customer) - url = self.request.route_url('corepos.customers.view', id=customer.id) + url = self.request.route_url('corepos.customers.view', + card_number=customer.card_number, + person_number=customer.person_number) link = tags.link_to(text, url) items.append(HTML.tag('li', c=[link])) return HTML.tag('ul', c=items) @@ -174,10 +176,14 @@ class MemberView(CoreOfficeMasterView): card_number=suspension.card_number) return tags.link_to(text, url) - def core_office_object_url(self, office_url, member): - return core_office_customer_account_url(self.rattail_config, - member.card_number, - office_url=office_url) + def get_xref_buttons(self, member): + url = core_office_url(self.rattail_config) + if url: + url = core_office_customer_account_url(self.rattail_config, + member.card_number, + office_url=url) + return [self.make_xref_button(url=url, + text="View in CORE Office")] def defaults(config, **kwargs): diff --git a/tailbone_corepos/views/customers.py b/tailbone_corepos/views/customers.py index e98de5d..d5d2763 100644 --- a/tailbone_corepos/views/customers.py +++ b/tailbone_corepos/views/customers.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2022 Lance Edgar +# Copyright © 2010-2023 Lance Edgar # # This file is part of Rattail. # @@ -24,6 +24,10 @@ Customer Views """ +from rattail_corepos.config import core_office_url, core_office_customer_account_url + +from webhelpers2.html import tags + from tailbone.views import ViewSupplement @@ -35,6 +39,7 @@ class CustomerViewSupplement(ViewSupplement): labels = { 'corepos_account_id': "CORE-POS Account ID", + 'corepos_card_number': "CORE-POS Card Number", } def get_grid_query(self, query): @@ -44,15 +49,31 @@ class CustomerViewSupplement(ViewSupplement): def configure_grid(self, g): model = self.model g.set_filter('corepos_account_id', model.CoreCustomer.corepos_account_id) + g.set_filter('corepos_card_number', model.CoreCustomer.corepos_card_number) def configure_form(self, f): if not self.master.creating: f.append('corepos_account_id') + f.append('corepos_card_number') def get_version_child_classes(self): model = self.model return [model.CoreCustomer] + def get_xref_buttons(self, customer): + url = core_office_url(self.rattail_config) + if url: + url = core_office_customer_account_url(self.rattail_config, + customer.number, + office_url=url) + return [{'url': url, 'text': "View in CORE Office"}] + + def get_xref_links(self, customer): + if customer.corepos_card_number: + url = self.request.route_url('corepos.members.view', + card_number=customer.corepos_card_number) + return [tags.link_to("View CORE-POS Member", url)] + def includeme(config): CustomerViewSupplement.defaults(config) diff --git a/tailbone_corepos/views/members.py b/tailbone_corepos/views/members.py index eec249e..f9d4841 100644 --- a/tailbone_corepos/views/members.py +++ b/tailbone_corepos/views/members.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2022 Lance Edgar +# Copyright © 2010-2023 Lance Edgar # # This file is part of Rattail. # @@ -24,9 +24,26 @@ Member Views """ +from rattail_corepos.config import core_office_url, core_office_customer_account_url + +from webhelpers2.html import tags + from tailbone.views import ViewSupplement +class MembershipTypeViewSupplement(ViewSupplement): + """ + MembershipType view supplement for CORE integration + """ + route_prefix = 'membership_types' + + def get_xref_buttons(self, memtype): + url = core_office_url(self.rattail_config) + if url: + url = f'{url}/mem/MemberTypeEditor.php' + return [{'url': url, 'text': "View in CORE Office"}] + + class MemberViewSupplement(ViewSupplement): """ Member view supplement for CORE integration @@ -52,6 +69,22 @@ class MemberViewSupplement(ViewSupplement): model = self.model return [model.CoreMember] + def get_xref_buttons(self, member): + if member.customer and member.customer.corepos_card_number: + url = core_office_url(self.rattail_config) + if url: + url = core_office_customer_account_url(self.rattail_config, + member.customer.corepos_card_number, + office_url=url) + return [{'url': url, 'text': "View in CORE Office"}] + + def get_xref_links(self, member): + if member.customer and member.customer.corepos_card_number: + url = self.request.route_url('corepos.members.view', + card_number=member.customer.corepos_card_number) + return [tags.link_to("View CORE-POS Member", url)] + def includeme(config): + MembershipTypeViewSupplement.defaults(config) MemberViewSupplement.defaults(config)