mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-28 17:32:38 +02:00
[History] Add details of bills in history
This commit is contained in:
parent
11929998eb
commit
2ee2e33b64
2 changed files with 34 additions and 0 deletions
|
@ -83,10 +83,26 @@ def get_history(project, human_readable_names=True):
|
|||
"time": version.transaction.issued_at,
|
||||
"operation_type": version.operation_type,
|
||||
"object_type": object_type,
|
||||
"bill_details": None,
|
||||
"object_desc": object_str,
|
||||
"ip": version.transaction.remote_addr,
|
||||
}
|
||||
|
||||
if object_type == "Bill":
|
||||
if version.operation_type == Operation.INSERT or not version.previous:
|
||||
detailed_version = version
|
||||
else:
|
||||
detailed_version = version.previous
|
||||
details = {
|
||||
"date": detailed_version.date,
|
||||
"payer": describe_version(detailed_version.payer),
|
||||
"amount": detailed_version.amount,
|
||||
"owers": [describe_version(o) for o in detailed_version.owers],
|
||||
"external_link": detailed_version.external_link,
|
||||
"original_currency": detailed_version.original_currency,
|
||||
}
|
||||
common_properties["bill_details"] = details
|
||||
|
||||
if version.operation_type == Operation.UPDATE:
|
||||
# Only iterate the changeset if the previous version
|
||||
# Was logged
|
||||
|
|
|
@ -91,6 +91,21 @@
|
|||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro bill_details(details, before=False) %}
|
||||
{% set owers_list_str=details.owers|localize_list|safe %}
|
||||
<details class="small">
|
||||
<summary>{% if before %} {{ _("Details of the bill (before the change)") }} {% else %} {{ _("Details of the bill") }} {% endif %}</summary>
|
||||
{{ _("Date:") }} {{ details.date|em_surround }}.
|
||||
{{ _("Payer:") }} {{ details.payer|em_surround }}.
|
||||
{{ _("Amount:") }} {{ details.amount|currency(details.original_currency)|em_surround }}.
|
||||
{{ _("Owers:") }} {{ owers_list_str }}.
|
||||
{% if details.external_link %}
|
||||
{{ _("External link:") }}
|
||||
<a class="truncated" href="{{ details.external_link }}">{{ details.external_link }}</a>
|
||||
{% endif %}
|
||||
</details>
|
||||
{% endmacro %}
|
||||
|
||||
{% block sidebar %}
|
||||
<div id="table_overflow">
|
||||
{{ balance_table(show_weight=False, show_header=True) }}
|
||||
|
@ -177,6 +192,7 @@
|
|||
{% trans %}Project {{ name }} added{% endtrans %}
|
||||
{% elif event.object_type == "Bill" %}
|
||||
{% trans %}Bill {{ name }} added{% endtrans %}
|
||||
{{ bill_details(event.bill_details) }}
|
||||
|
||||
{% elif event.object_type == "Person" %}
|
||||
{% trans %}Participant {{ name }} added{% endtrans %}
|
||||
|
@ -220,6 +236,7 @@
|
|||
{% else %}
|
||||
{% trans %}Bill {{ name }} modified{% endtrans %}
|
||||
{% endif %}
|
||||
{{ bill_details(event.bill_details, before=True) }}
|
||||
|
||||
{% elif event.object_type == "Person" %}
|
||||
{% if event.prop_changed == "activated" %}
|
||||
|
@ -243,6 +260,7 @@
|
|||
{% elif event.operation_type == OperationType.DELETE %}
|
||||
{% if event.object_type == "Bill" %}
|
||||
{% trans %}Bill {{ name }} removed{% endtrans %}
|
||||
{{ bill_details(event.bill_details) }}
|
||||
{% elif event.object_type == "Person" %}
|
||||
{% trans %}Participant {{ name }} removed{% endtrans %}
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in a new issue