summaryrefslogtreecommitdiff
path: root/sstreasury/jinja2/sstreasury/budget_view.html
blob: 707f834410c3218c47b0ae1f5fd37581dc4a4391 (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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
1{% extends 'sstreasury/base.html' %}
2
3{#
4    Society Self-Service
5    Copyright © 2018–2020  Yingtong Li (RunasSudo)
6
7    This program is free software: you can redistribute it and/or modify
8    it under the terms of the GNU Affero General Public License as published by
9    the Free Software Foundation, either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU Affero General Public License for more details.
16
17    You should have received a copy of the GNU Affero General Public License
18    along with this program.  If not, see <https://www.gnu.org/licenses/>.
19#}
20
21{% block title %}{{ revision.name }}{% endblock %}
22
23{% block maincontent %}
24	<h1>{{ revision.name }}</h1>
25	
26	<form class="ui form" action="{{ url('budget_action', kwargs={'id': revision.budget.id}) }}" method="POST">
27		<span class="ui header">Status: {{ revision.get_state_display() }}</span>
28		
29		{% if is_latest %}
30			{% if revision.can_submit(request.user) %}
31				<button class="ui mini labeled primary icon button" data-action="Submit" style="margin-left: 1em;" onclick="return uiConfirm(this);"><i class="paper plane icon"></i> Submit</button>
32			{% endif %}
33			{% if revision.can_endorse(request.user) %}
34				<button class="ui mini labeled positive icon button" data-action="Endorse" style="margin-left: 1em;" onclick="return uiConfirm(this);"><i class="check icon"></i> Endorse</button>
35				
36				<button class="ui mini labeled basic negative icon button" data-action="Return" onclick="return uiConfirm(this);"><i class="undo icon"></i> Return for re-drafting</button>
37			{% endif %}
38			{% if revision.can_approve(request.user) %}
39				<button class="ui mini labeled positive icon button" data-action="Approve" style="margin-left: 1em;" onclick="return uiConfirm(this);"><i class="check icon"></i> Approve</button>
40				
41				<button class="ui mini labeled basic negative icon button" data-action="CmteReturn" onclick="return uiConfirm(this);"><i class="undo icon"></i> Return for re-drafting</button>
42			{% endif %}
43			{% if revision.can_withdraw(request.user) %}
44				<button class="ui mini labeled basic negative icon button" data-action="Withdraw" style="margin-left: 1em;" onclick="return uiConfirm(this);"><i class="undo icon"></i> Withdraw</button>
45			{% endif %}
46			
47			{% if revision.can_edit(request.user) %}
48				<a class="ui mini labeled right floated icon button" href="{{ url('budget_edit', kwargs={'id': revision.budget.id}) }}"><i class="edit icon"></i> Edit</a>
49			{% endif %}
50			
51			<a class="ui mini labeled right floated icon button" href="{{ url('budget_print', kwargs={'id': revision.budget.id}) }}" target="_blank"><i class="print icon"></i> Print</a>
52			
53			{% if not revision.can_edit(request.user) and revision.can_withdraw(request.user) %}
54				<div class="ui message">
55					<p>This budget has been submitted and is now awaiting approval. If you wish to edit this budget, you must first withdraw it. This will revert the budget to a draft.</p>
56				</div>
57			{% endif %}
58			
59			<input type="hidden" name="action" value="">
60			<input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
61		{% else %}
62			<a class="ui mini labeled right floated icon button" href="{{ url('budget_print', kwargs={'id': revision.budget.id}) }}?revision={{ revision.id }}" target="_blank"><i class="print icon"></i> Print</a>
63			
64			<div class="ui visible warning message">
65				<p>You are viewing an older version of this budget. To make any changes, <a href="{{ url('budget_view', kwargs={'id': revision.budget.id}) }}">click here</a> to return to the current version.</p>
66			</div>
67		{% endif %}
68	</form>
69	
70	<table class="ui mydefinition table">
71		<tbody>
72			<tr>
73				<td class="two wide">ID</td>
74				<td class="fourteen wide">BU-{{ revision.budget.id }}</td>
75			</tr>
76			<tr>
77				<td>Title</td>
78				<td>{{ revision.name }}</td>
79			</tr>
80			<tr>
81				<td>Due date</td>
82				<td>{{ revision.date or '' }}</td>
83			</tr>
84			<tr>
85				<td>Event details</td>
86				<td>
87					{% if revision.event_dt %}{{ localtime(revision.event_dt) }}.{% endif %}
88					{% if revision.event_attendees %}{{ revision.event_attendees }} attendees.{% endif %}
89					{% if not revision.event_dt and not revision.event_attendees %}N/A{% endif %}
90				</td>
91			</tr>
92			<tr>
93				<td>Contributors</td>
94				<td>
95					<div class="ui list">
96						{% for contributor in revision.contributors.all() %}
97							<div class="item">
98								<i class="user circle icon"></i>
99								<div class="content"><a href="mailto:{{ contributor.email }}">
100									{% if contributor.first_name %}
101										{{ contributor.first_name }} {{ contributor.last_name }}
102									{% else %}
103										{{ contributor.email }}
104									{% endif %}
105								</a></div>
106							</div>
107						{% endfor %}
108					</div>
109				</td>
110			</tr>
111			<tr>
112				<td>Comments</td>
113				<td>{{ revision.comments|markdown }}</td>
114			</tr>
115			<tr>
116				<td>Revenue</td>
117				<td>
118					<div id="revenue_grid"></div>
119					{% if revision.revenue_comments %}
120						<div class="ui accordion">
121							<div class="active title">
122								<i class="dropdown icon"></i>
123								Revenue comments
124							</div>
125							<div class="active content">
126								{{ revision.revenue_comments|markdown }}
127							</div>
128						</div>
129					{% endif %}
130				</td>
131			</tr>
132			<tr>
133				<td>Expenses</td>
134				<td>
135					{% if revision.expense_no_emergency_fund %}
136						<p><input type="checkbox" id="expense_no_emergency_fund" disabled checked> No emergency fund required (please add a comment explaining why)</p>
137					{% endif %}
138					<div id="expense_grid"></div>
139					{% if revision.expense_comments %}
140						<div class="ui accordion">
141							<div class="active title">
142								<i class="dropdown icon"></i>
143								Expense comments
144							</div>
145							<div class="active content">
146								{{ revision.expense_comments|markdown }}
147							</div>
148						</div>
149					{% endif %}
150				</td>
151			</tr>
152			<tr>
153				<td>Total Profit (Loss)</td>
154				<td style="text-align: right; font-weight: bold; padding-right: 2.3em;">{{ '${:.2f}'.format(revision.get_revenue_total() - revision.get_expense_total()) if revision.get_revenue_total() >= revision.get_expense_total() else '(${:.2f})'.format(revision.get_expense_total() - revision.get_revenue_total()) }}</td>
155			</tr>
156		</tbody>
157	</table>
158	
159	{% if is_latest %}
160		<form class="ui form" action="{{ url('budget_action', kwargs={'id': revision.budget.id}) }}" method="POST">
161			<div class="required field">
162				<textarea rows="4" name="comment"></textarea>
163			</div>
164			<input type="hidden" name="action">
165			<input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
166			<button class="ui primary button" data-action="Comment" onclick="return uiSubmit(this);">Comment</button>
167			
168			{% if revision.state == import('sstreasury.models').BudgetState.AWAIT_REVIEW.value and request.user.groups.filter(name='Treasury').exists() %}
169				<button class="ui right floated labeled basic negative icon button" data-action="Comment,Return" onclick="return uiConfirm(this);"><i class="undo icon"></i> Comment and return for re-drafting</button>
170				
171				<button class="ui right floated labeled positive icon button" data-action="Comment,Endorse" onclick="return uiConfirm(this);"><i class="check icon"></i> Comment and endorse</button>
172			{% elif revision.state != import('sstreasury.models').BudgetState.APPROVED.value and request.user.groups.filter(name='Secretary').exists() %}
173				<button class="ui right floated labeled basic negative icon button" data-action="Comment,CmteReturn" onclick="return uiConfirm(this);"><i class="undo icon"></i> Comment and return for re-drafting</button>
174				
175				<button class="ui right floated labeled positive icon button" data-action="Comment,Approve" onclick="return uiConfirm(this);"><i class="check icon"></i> Comment and approve</button>
176			{% endif %}
177		</form>
178		
179		<div class="ui feed">
180			{% for item in history %}
181				{% if item.__class__.__name__ == 'BudgetComment' %}
182					<div class="event">
183						<div class="label">
184							<i class="comment alternate outline icon"></i>
185						</div>
186						<div class="content">
187							<div class="summary">
188								<i class="user circle icon"></i>
189								<a href="mailto:{{ item.author.email }}">{{ item.author.first_name }} {{ item.author.last_name }}</a> commented
190								<div class="date">
191									{{ localtime(item.time) }}
192								</div>
193							</div>
194							<div class="extra text">
195								{{ item.content|markdown }}
196							</div>
197						</div>
198					</div>
199				{% elif item.__class__.__name__ == 'BudgetRevision' %}
200					<div class="event">
201						<div class="label">
202							<i class="edit icon"></i>
203						</div>
204						<div class="content">
205							<div class="summary">
206								<i class="user circle icon"></i>
207								{% if item.action == import('sstreasury.models').BudgetAction.CREATE.value %}
208									<a href="mailto:{{ item.author.email }}">{{ item.author.first_name }} {{ item.author.last_name }}</a> created the budget <a href="{{ url('budget_view', kwargs={'id': revision.budget.id}) }}?revision={{ item.id }}">(view)</a>
209								{% elif item.action == import('sstreasury.models').BudgetAction.EDIT.value %}
210									<a href="mailto:{{ item.author.email }}">{{ item.author.first_name }} {{ item.author.last_name }}</a> edited the budget <a href="{{ url('budget_view', kwargs={'id': revision.budget.id}) }}?revision={{ item.id }}">(view)</a>
211								{% elif item.action == import('sstreasury.models').BudgetAction.UPDATE_STATE.value %}
212									<a href="mailto:{{ item.author.email }}">{{ item.author.first_name }} {{ item.author.last_name }}</a> changed the state to: {{ item.get_state_display() }}
213								{% else %}
214									<a href="mailto:{{ item.author.email }}">{{ item.author.first_name }} {{ item.author.last_name }}</a> modified the budget <a href="{{ url('budget_view', kwargs={'id': revision.budget.id}) }}?revision={{ item.id }}">(view)</a>
215								{% endif %}
216								<div class="date">
217									{{ localtime(item.time) }}
218								</div>
219							</div>
220						</div>
221					</div>
222				{% endif %}
223			{% endfor %}
224		</div>
225	{% endif %}
226	
227	<div class="ui modal">
228		<div class="content" data-action="Submit">
229			<p>Are you sure you want to submit this budget for Treasury review? You will not be able to make any additional changes without withdrawing the budget.</p>
230		</div>
231		<div class="content" data-action="Endorse">
232			<p>Are you sure you want to give this budget Treasury endorsement?</p>
233		</div>
234		<div class="content" data-action="Comment,Endorse">
235			<p>Are you sure you want to give this budget Treasury endorsement?</p>
236		</div>
237		<div class="content" data-action="Return">
238			<p>Are you sure you want to refuse this budget Treasury endorsement and return it for re-drafting?</p>
239		</div>
240		<div class="content" data-action="Comment,Return">
241			<p>Are you sure you want to refuse this budget Treasury endorsement and return it for re-drafting?</p>
242		</div>
243		<div class="content" data-action="Approve">
244			<p>Are you sure you want to mark this budget as committee-approved?</p>
245		</div>
246		<div class="content" data-action="Comment,Approve">
247			<p>Are you sure you want to mark this budget as committee-approved?</p>
248		</div>
249		<div class="content" data-action="CmteReturn">
250			<p>Are you sure you want to refuse this budget committee approval and return it for re-drafting?</p>
251		</div>
252		<div class="content" data-action="Comment,CmteReturn">
253			<p>Are you sure you want to refuse this budget committee approval and return it for re-drafting?</p>
254		</div>
255		<div class="content" data-action="Withdraw">
256			<p>Are you sure you want to withdraw this budget from being considered for approval? The budget will be reverted to a draft.</p>
257		</div>
258		<div class="actions">
259			<div class="ui primary approve button">Continue</div>
260			<div class="ui cancel button">Cancel</div>
261		</div>
262	</div>
263{% endblock %}
264
265{% block head %}
266	{{ super() }}
267	
268	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jsgrid@1.5.3/dist/jsgrid.min.css" integrity="sha256-a/jNbtm7jpeKiXCShJ8YC+eNL9Abh7CBiYXHgaofUVs=" crossorigin="anonymous">
269	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jsgrid@1.5.3/dist/jsgrid-theme.min.css" integrity="sha256-0rD7ZUV4NLK6VtGhEim14ZUZGC45Kcikjdcr4N03ddA=" crossorigin="anonymous">
270	
271	<style>
272		/* Fix the CSS */
273		
274		.ui.mydefinition.table > tbody > tr > td:first-child:not(.ignored) {
275			background: rgba(0,0,0,.03);
276			font-weight: 700;
277			color: rgba(0,0,0,.95);
278		}
279		
280		.jsgrid-align-right, .jsgrid-align-right input, .jsgrid-align-right select, .jsgrid-align-right textarea {
281			text-align: right !important;
282		}
283		.jsgrid-cell {
284			padding: .5em !important;
285		}
286		.jsgrid-header-row .jsgrid-header-cell {
287			text-align: center !important;
288		}
289	</style>
290{% endblock %}
291
292{% block script %}
293	{{ super() }}
294	
295	<script>
296		function uiSubmit(button) {
297			button.form.elements['action'].value = button.dataset['action'];
298			button.form.submit();
299			return false;
300		}
301		
302		function uiConfirm(button) {
303			$('.ui.modal .content').hide();
304			$('.ui.modal .content').filter('[data-action="' + button.dataset['action'] + '"]').show();
305			$('.ui.modal').modal({
306				closable: false,
307				onApprove: function() {
308					uiSubmit(button);
309				}
310			}).modal('show');
311			
312			return false;
313		}
314	</script>
315	
316	<script src="https://cdn.jsdelivr.net/npm/jsgrid@1.5.3/dist/jsgrid.min.js" integrity="sha256-lzjMTpg04xOdI+MJdjBst98bVI6qHToLyVodu3EywFU=" crossorigin="anonymous"></script>
317	
318	<script src="{{ static('sstreasury/budget.js') }}"></script>
319	
320	<script>
321		var revenue_data = JSON.parse({{ import('json').dumps(import('json').dumps(revision.revenue))|safe }});
322		var expense_data = JSON.parse({{ import('json').dumps(import('json').dumps(revision.expense))|safe }});
323		var editing = false;
324		makeGrid();
325		
326		$('.jsgrid-filter-row, .jsgrid-insert-row').attr('style', 'display: none !important;'); /* Override Semantic UI */
327	</script>
328{% endblock %}
Contact (issues, pull requests, etc.) at git@yingtongli.me. Generated by cgit.