Change to filter from simple

This commit is contained in:
PCoder 2020-04-07 18:35:25 +05:30
parent 4435eef077
commit 4869fd51df
2 changed files with 12 additions and 6 deletions

View File

@ -63,8 +63,8 @@ def escaped_line_break(value):
return value.replace("\\n", "\n")
@register.simple_tag
def get_line_item_from_hosting_order_charge(hosting_order_id, receipt_url):
@register.filter('get_line_item_from_hosting_order_charge')
def get_line_item_from_hosting_order_charge(hosting_order_id):
"""
Returns ready-to-use "html" line item to be shown for a charge in the
invoice list page
@ -85,7 +85,7 @@ def get_line_item_from_hosting_order_charge(hosting_order_id, receipt_url):
product_name=hosting_order.generic_product.product_name.capitalize(),
created_at=hosting_order.created_at.strftime('%Y-%m-%d'),
total='%.2f' % (hosting_order.price),
receipt_url=receipt_url,
receipt_url="test",
see_invoice_text=_("See Invoice")
))
else:

View File

@ -1,5 +1,5 @@
{% extends "hosting/base_short.html" %}
{% load staticfiles bootstrap3 humanize i18n custom_tags get_line_item_from_hosting_order_charge %}
{% load staticfiles bootstrap3 humanize i18n custom_tags %}
{% block content %}
<div class="dashboard-container">
@ -84,9 +84,15 @@
</tr>
</thead>
<tbody>
{% for ho_id, stripe_charge_data in invs_charge %}
{% for ho, stripe_charge_data in invs_charge %}
<tr>
{{ get_line_item_from_hosting_order_charge ho_id stripe_charge_data.receipt_url }}
<td class="xs-td-inline">{ho.generic_product.product_name.capitalize()}</td>
<td class="xs-td-inline">{ho.created_at.strftime('%Y-%m-%d')}</td>
<td class="xs-td-inline">{ho.price}</td>
<td class="text-right last-td">
<a class="btn btn-order-detail" href="{stripe_charge_data.receipt_url}" target="_blank">{% trans "See Invoice" %}</a>
</td>
{{ get_line_item_from_hosting_order_charge ho_id }}
</tr>
{% endfor %}
</tbody>