Skip to content

Commit

Permalink
[IMP] improve portal templates
Browse files Browse the repository at this point in the history
* use a common template for certificate print buttons.
* rename "query_string" query string parameter to "certificate_type".
  • Loading branch information
huguesdk committed Jan 29, 2024
1 parent 1c9dbe2 commit afb2ae1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 33 deletions.
6 changes: 3 additions & 3 deletions l10n_be_cooperator_portal/controllers/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def portal_my_tax_shelter_certificate_detail(
access_token=None,
report_type=None,
download=False,
query_string=None,
certificate_type=None,
**kw
):
partner = request.env.user.partner_id
Expand All @@ -134,12 +134,12 @@ def portal_my_tax_shelter_certificate_detail(
except (AccessError, MissingError):
return request.redirect("/my")

if report_type in ("html", "pdf", "text") and query_string in (
if report_type in ("html", "pdf", "text") and certificate_type in (
"subscription",
"shares",
):
report_ref = "l10n_be_cooperator.action_tax_shelter_%s_report" % (
query_string
certificate_type
)
return self._show_report(
model=tax_shelter_certificate_sudo,
Expand Down
65 changes: 35 additions & 30 deletions l10n_be_cooperator_portal/views/portal_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,29 @@ SPDX-License-Identifier: AGPL-3.0-or-later
</xpath>
</template>

<template id="print_certificate_button">
<a
id="print_tax_shelter_subscription"
class="btn btn-secondary btn-block o_print_btn"
t-att-href="tax_shelter_certificate.get_portal_url(report_type='pdf', query_string='&amp;certificate_type=' + certificate_type)"
t-attf-title="Print {{ certificate_name }}"
target="_blank"
><i class="fa fa-print" /> <t t-out="certificate_name" /></a>
</template>

<template id="print_subscription_certificate_button">
<t t-call="l10n_be_cooperator_portal.print_certificate_button">
<t t-set="certificate_type" t-value="'subscription'" />
<t t-set="certificate_name">Subscription Certificate</t>
</t>
</template>

<template id="print_shares_certificate_button">
<t t-call="l10n_be_cooperator_portal.print_certificate_button">
<t t-set="certificate_type" t-value="'shares'" />
<t t-set="certificate_name">Shares Certificate</t>
</t>
</template>

<!-- Tax Shelter Certificate page -->
<template id="portal_my_tax_shelter_certificate" name="My Tax Shelter Certificates">
Expand Down Expand Up @@ -90,18 +113,12 @@ SPDX-License-Identifier: AGPL-3.0-or-later
/>
</td>
<td class="text-end">
<a
class="btn btn-secondary btn-block o_print_btn"
t-att-href="tax_shelter_certificate.get_portal_url(report_type='pdf', query_string='&amp;query_string=subscription')"
title="Print Subscription"
target="_blank"
><i class="fa fa-print" /> Subscription Certificate</a>
<a
class="btn btn-secondary btn-block o_print_btn"
t-att-href="tax_shelter_certificate.get_portal_url(report_type='pdf', query_string='&amp;query_string=shares')"
title="Print Shares"
target="_blank"
><i class="fa fa-print" /> Shares Certificate</a>
<t
t-call="l10n_be_cooperator_portal.print_subscription_certificate_button"
/>
<t
t-call="l10n_be_cooperator_portal.print_shares_certificate_button"
/>
</td>
</tr>
</t>
Expand Down Expand Up @@ -136,28 +153,16 @@ SPDX-License-Identifier: AGPL-3.0-or-later
<li class="list-group-item flex-grow-1">
<div class="o_download_pdf btn-toolbar flex-sm-nowrap">
<div class="btn-group flex-grow-1 mb-1">
<a
id="print_tax_shelter_subscription"
class="btn btn-secondary btn-block o_print_btn"
t-att-href="tax_shelter_certificate.get_portal_url(report_type='pdf', query_string='&amp;query_string=subscription')"
title="Print Subscription"
target="_blank"
><i
class="fa fa-print"
/> Subscription Certificate</a>
<t
t-call="l10n_be_cooperator_portal.print_subscription_certificate_button"
/>
</div>
</div>
<div class="o_download_pdf btn-toolbar flex-sm-nowrap">
<div class="btn-group flex-grow-1 mb-1">
<a
id="print_tax_shelter_shares"
class="btn btn-secondary btn-block o_print_btn"
t-att-href="tax_shelter_certificate.get_portal_url(report_type='pdf', query_string='&amp;query_string=shares')"
title="Print Shares"
target="_blank"
><i
class="fa fa-print"
/> Shares Certificate</a>
<t
t-call="l10n_be_cooperator_portal.print_shares_certificate_button"
/>
</div>
</div>
</li>
Expand Down

0 comments on commit afb2ae1

Please sign in to comment.