blob: 1ac3284f23f2e19ad7d6099d0fd5b3b8d5304f75 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
{% extends "sidebar_table_layout.html" %}
{% macro change_to_logging_preference(event) %}
{% if event.val_after == LoggingMode.DISABLED %}
{% if event.val_before == LoggingMode.ENABLED %}
{{ _("Disabled Project History") }}
{% else %}
{{ _("Disabled Project History & IP Address Recording") }}
{% endif %}
{% elif event.val_after == LoggingMode.ENABLED %}
{% if event.val_before == LoggingMode.DISABLED %}
{{ _("Enabled Project History") }}
{% elif event.val_before == LoggingMode.RECORD_IP %}
{{ _("Disabled IP Address Recording") }}
{% else %}
{{ _("Enabled Project History") }}
{% endif %}
{% elif event.val_after == LoggingMode.RECORD_IP %}
{% if event.val_before == LoggingMode.DISABLED %}
{{ _("Enabled Project History & IP Address Recording") }}
{% elif event.val_before == LoggingMode.ENABLED %}
{{ _("Enabled IP Address Recording") }}
{% else %}
{{ _("Enabled Project History & IP Address Recording") }}
{% endif %}
{% else %}
{# Should be unreachable #}
{{ _("History Settings Changed") }}
{% endif %}
{% endmacro %}
{% macro describe_object(event) %}{{ event.object_type }} <em class="font-italic">{{ event.object_desc }}</em>{% endmacro %}
{% macro simple_property_change(event, localized_property_name, from=True) %}
{{ describe_object(event) }}:
{{ localized_property_name }} {{ _("changed") }}
{% if from %}{{ _("from") }} <em class="font-italic">{{ event.val_before }}</em>{% endif %}
{{ _("to") }} <em class="font-italic">{{ event.val_after }}</em>
{% endmacro %}
{% macro clear_history_modals() %}
<!-- Modal -->
<div id="confirm-ip-delete" class="modal fade show" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">{{ _('Confirm Remove IP Adresses') }}</h3>
<a href="#" class="close" data-dismiss="modal">×</a>
</div>
<div class="modal-body">
<p>{{ _("Are you sure you want to delete all recorded IP addresses from this project?
The rest of the project history will be unaffected. This action cannot be undone.") }}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ _("Close") }}</button>
<form action="{{ url_for(".strip_ip_addresses") }}" method="post">
<input type="submit" class="btn btn-danger" value="{{ _("Confirm Delete") }}" name="{{ _("Confirm Delete") }}"/>
</form>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div id="confirm-erase" class="modal fade show" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">{{ _('Delete Confirmation') }}</h3>
<a href="#" class="close" data-dismiss="modal">×</a>
</div>
<div class="modal-body">
<p>{{ _("Are you sure you want to erase all history for this project? This action cannot be undone.") }}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ _("Close") }}</button>
<form action="{{ url_for(".erase_history") }}" method="post">
<input type="submit" class="btn btn-danger" value="{{ _("Confirm Delete") }}" name="{{ _("Confirm Delete") }}"/>
</form>
</div>
</div>
</div>
</div>
{% endmacro %}
{% macro owers_changed(event, add) %}
{{ describe_object(event) }}: {% if add %}{{ _("Added") }}{% else %}{{ _("Removed") }}{% endif %}
{% if event.val_after|length > 1 %}
{% for name in event.val_after %}
<em class="font-italic">{{ name }}</em>{% if event.val_after|length > 2 and loop.index != event.val_after|length %},{% endif %}
{% if loop.index == event.val_after|length - 1 %} {{ _("and") }} {% endif %}
{% endfor %}
{% else %}
<em class="font-italic">{{ event.val_after[0] }}</em>
{% endif %}
{% if add %}{{ _("to") }}{% else %}{{ _("from") }}{% endif %}
{{ _("owers list") }}
{% endmacro %}
{% block sidebar %}
<div id="table_overflow">
<table class="balance table">
<thead>
<tr class="d-none d-md-table-row">
<th>{{ _("Who?") }}</th>
<th class="balance-value">{{ _("Balance") }}</th>
</tr>
</thead>
{% set balance = g.project.balance %}
{% for member in g.project.members | sort(attribute='name') if member.activated or balance[member.id]|round(2) != 0 %}
<tr id="bal-member-{{ member.id }}" action={% if member.activated %}delete{% else %}reactivate{% endif %}>
<td class="balance-name">{{ member.name }}</td>
<td class="balance-value {% if balance[member.id]|round(2) > 0 %}positive{% elif balance[member.id]|round(2) < 0 %}negative{% endif %}">
{% if balance[member.id]|round(2) > 0 %}+{% endif %}{{ "%.2f" | format(balance[member.id]) }}
</td>
</tr>
{% endfor %}
</table>
</div>
{% endblock %}
{% block content %}
{% if current_log_pref == LoggingMode.DISABLED or (current_log_pref != LoggingMode.RECORD_IP and any_ip_addresses) %}
<div id="history_warnings" class="card card-body bg-light">
{% if current_log_pref == LoggingMode.DISABLED %}
<p>{% set url = url_for(".edit_project") %}
{% trans %}
<i>This project has history disabled. New actions won't appear below. You can enable history on the</i>
<a href="{{ url }}">settings page</a>
{% endtrans %}
</p>
{% if history %}
<p>
{% trans %}
<i>The table below reflects actions recorded prior to disabling project history. You can
<a href="#" data-toggle="modal" data-keyboard="false" data-target="#confirm-erase">clear project history</a> to remove them.</i></p>
{% endtrans %}
{% endif %}
{% endif %}
{% if current_log_pref != LoggingMode.RECORD_IP and any_ip_addresses %}
<p>
<i>{{ _("Some entries below contain IP addresses, even though this project has IP recording disabled. ") }}
<a href="#" data-toggle="modal" data-keyboard="false" data-target="#confirm-ip-delete">{{ _("Delete stored IP addresses") }}</a></i>
</p>
{% endif %}
</div>
{% endif %}
{{ clear_history_modals() }}
<span class="float-right mt-3" {% if not history %} data-toggle="tooltip" title="{{_('No history to erase')}}" {% endif %}>
<a href="#" class="btn btn-outline-danger float-right {% if not history %} disabled {% endif %}" data-toggle="modal" data-keyboard="false" data-target="#confirm-erase">
<i class="icon icon-red plus">{{ static_include("images/x.svg") | safe }}</i>
{{ _("Clear Project History") }}
</a>
</span>
<span class="float-right mt-3" {% if not any_ip_addresses %}data-placement="top" data-toggle="tooltip" title="{{_('No IP Addresses to erase')}}" {% endif %}>
<a href="#" class="btn btn-outline-danger float-right mr-2 {% if not any_ip_addresses %} disabled {% endif %}" data-toggle="modal" data-keyboard="false" data-target="#confirm-ip-delete">
<i class="icon icon-red plus">{{ static_include("images/x.svg") | safe }}</i>
{{ _("Delete Stored IP Addresses") }}
</a>
</span>
<div class="clearfix"></div>
{% if history %}
<table id="history_table" class="split_bills table table-striped">
<thead><tr>
<th style="width: 15%">{{ _("Time") }}</th>
<th style="width: 65%">{{ _("Event") }}</th>
<th style="width: 20%">
<span data-toggle="tooltip" title="{% if current_log_pref != LoggingMode.RECORD_IP %}
{{_('IP address recording can be enabled on the settings page') }}
{% else %}
{{_('IP address recording can be disabled on the settings page') }}
{% endif %}">
{{ _("From IP") }}</span></th>
</tr></thead>
<tbody>
{% for event in history %}
<tr>
<td><script>document.write(localizeTime("{{ event.time }}"));</script></td>
<td >
<div class="history_icon">
<i {% if event.operation_type == OperationType.INSERT %}
class="add"
{% elif event.operation_type == OperationType.UPDATE %}
class="edit"
{% elif event.operation_type == OperationType.DELETE %}
class="delete"
{% endif %}
></i>
</div>
<div class="history_text">
{% if event.operation_type == OperationType.INSERT %}
{{ event.object_type }} <em class="font-italic">{{ event.object_desc }}</em> {{ _("added") }}
{% elif event.operation_type == OperationType.UPDATE %}
{% if event.object_type == _("Project") %}
{% if event.prop_changed == "password" %}
{{ _("Project private code changed") }}
{% elif event.prop_changed == "logging_preference" %}
{{ change_to_logging_preference(event) }}
{% elif event.prop_changed == "name" %}
{{ _("Project renamed to") }} <em class="font-italic">{{ event.val_after }}</em>
{% elif event.prop_changed == "contact_email" %}
{{ _("Project contact email changed to") }} <em class="font-italic">{{ event.val_after }}</em>
{% else %}
{{ _("Project settings modified") }}
{% endif %}
{% elif event.prop_changed == "activated" %}
{{ event.object_type }} <em class="font-italic">{{ event.object_desc }}</em>
{% if event.val_after == False %}{{ _("deactivated") }}{% else %}{{ _("reactivated") }}{% endif %}
{% elif event.prop_changed == "name" or event.prop_changed == "what" %}
{{ describe_object(event) }} {{ _("renamed to") }} <em class="font-italic">{{ event.val_after }}</em>
{% elif event.prop_changed == "weight" %}
{{ simple_property_change(event, _("Weight")) }}
{% elif event.prop_changed == "external_link" %}
{{ describe_object(event) }}: {{ _("External link changed to") }}
<a href="{{ event.val_after }}" class="font-italic">{{ event.val_after }}</a>
{% elif event.prop_changed == "owers_added" %}
{{ owers_changed(event, True)}}
{% elif event.prop_changed == "owers_removed" %}
{{ owers_changed(event, False)}}
{% elif event.prop_changed == "payer" %}
{{ simple_property_change(event, _("Payer"))}}
{% elif event.prop_changed == "amount" %}
{{ simple_property_change(event, _("Amount")) }}
{% elif event.prop_changed == "date" %}
{{ simple_property_change(event, _("Date")) }}
{% else %}
{{ describe_object(event) }} {{ _("modified") }}
{% endif %}
{% elif event.operation_type == OperationType.DELETE %}
{{ event.object_type }} <em class="font-italic">{{ event.object_desc }}</em> {{ _("removed") }}
{% else %}
{# Should be unreachable #}
{{ describe_object(event) }} {{ _("changed in a unknown way") }}
{% endif %}
</div>
</td>
<td>{% if event.ip %}{{ event.ip }}{% else %} -- {% endif %}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="py-3 d-flex justify-content-center empty-bill">
<div class="card d-inline-flex p-2">
<div class="card-body text-center text-muted">
<i class="icon icon-white hand-holding-heart">{{ static_include("images/hand-holding-heart.svg") | safe }}</i>
<h3>{{ _('Nothing to list')}}</h3>
<p>
{{ _("Someone probably cleared the project history.") }}
</p>
</div>
</div></div>
{% endif %}
{% endblock %}
|