2018-06-26 20:14:16 +10:00
{% extends 'sstreasury/base.html' %}
{#
Society Self-Service
2020-02-27 19:27:05 +11:00
Copyright © 2018–2020 Yingtong Li (RunasSudo)
2018-06-26 20:14:16 +10:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see < https: / / www . gnu . org / licenses / > .
#}
{% block title %}{{ revision.name }}{% endblock %}
{% block maincontent %}
< h1 > {{ revision.name }}< / h1 >
2019-06-20 15:29:57 +10:00
< form class = "ui form" action = "{{ url('budget_action', kwargs={'id': revision.budget.id}) }}" method = "POST" >
< span class = "ui header" > Status: {{ revision.get_state_display() }}< / span >
{% if is_latest %}
2019-12-29 00:30:30 +11:00
{% if revision.can_submit(request.user) %}
2020-01-04 21:41:36 +11:00
< 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 >
2019-12-29 00:30:30 +11:00
{% endif %}
{% if revision.can_endorse(request.user) %}
2020-01-04 21:41:36 +11:00
< 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 >
2019-06-20 01:06:24 +10:00
2020-01-04 21:41:36 +11:00
< 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 >
2019-12-29 00:30:30 +11:00
{% endif %}
{% if revision.can_approve(request.user) %}
2020-01-04 21:41:36 +11:00
< 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 >
2019-06-20 01:39:29 +10:00
2020-01-04 21:41:36 +11:00
< 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 >
2019-12-29 00:30:30 +11:00
{% endif %}
{% if revision.can_withdraw(request.user) %}
2020-01-04 21:41:36 +11:00
< 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 >
2019-06-20 01:06:24 +10:00
{% endif %}
2019-12-29 00:30:30 +11:00
{% if revision.can_edit(request.user) %}
2019-06-19 19:46:24 +10:00
< 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 >
2019-12-29 00:30:30 +11:00
{% endif %}
< 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 >
{% if not revision.can_edit(request.user) and revision.can_withdraw(request.user) %}
2019-06-20 01:06:24 +10:00
< div class = "ui message" >
< 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 >
< / div >
2019-06-19 19:46:24 +10:00
{% endif %}
2020-01-04 21:41:36 +11:00
< input type = "hidden" name = "action" value = "" >
2019-06-19 19:46:24 +10:00
< input type = "hidden" name = "csrfmiddlewaretoken" value = "{{ csrf_token }}" >
2019-06-20 15:29:57 +10:00
{% else %}
< 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 >
< div class = "ui visible warning message" >
< 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 >
< / div >
{% endif %}
< / form >
2018-06-26 20:14:16 +10:00
2018-06-26 23:06:14 +10:00
< table class = "ui mydefinition table" >
2018-06-26 20:14:16 +10:00
< tbody >
< tr >
2018-06-26 23:06:14 +10:00
< td class = "two wide" > ID< / td >
2019-12-28 23:23:56 +11:00
< td class = "fourteen wide" > BU-{{ revision.budget.id }}< / td >
2018-06-26 20:14:16 +10:00
< / tr >
< tr >
2020-01-17 21:11:48 +11:00
< td > Title< / td >
2018-06-26 20:14:16 +10:00
< td > {{ revision.name }}< / td >
< / tr >
< tr >
< td > Due date< / td >
< td > {{ revision.date or '' }}< / td >
< / tr >
2020-01-17 21:12:07 +11:00
< tr >
< td > Event details< / td >
< td >
{% if revision.event_dt %}{{ localtime(revision.event_dt) }}.{% endif %}
{% if revision.event_attendees %}{{ revision.event_attendees }} attendees.{% endif %}
{% if not revision.event_dt and not revision.event_attendees %}N/A{% endif %}
< / td >
< / tr >
2018-06-26 20:14:16 +10:00
< tr >
< td > Contributors< / td >
< td >
< div class = "ui list" >
{% for contributor in revision.contributors.all() %}
< div class = "item" >
< i class = "user circle icon" > < / i >
< div class = "content" > < a href = "mailto:{{ contributor.email }}" >
{% if contributor.first_name %}
{{ contributor.first_name }} {{ contributor.last_name }}
{% else %}
{{ contributor.email }}
{% endif %}
< / a > < / div >
< / div >
{% endfor %}
< / div >
< / td >
< / tr >
< tr >
< td > Comments< / td >
2020-02-27 19:27:05 +11:00
< td > {{ revision.comments|markdown }}< / td >
2018-06-26 20:14:16 +10:00
< / tr >
< tr >
< td > Revenue< / td >
< td >
2018-06-26 23:06:14 +10:00
< div id = "revenue_grid" > < / div >
2018-06-26 20:14:16 +10:00
{% if revision.revenue_comments %}
< div class = "ui accordion" >
< div class = "active title" >
< i class = "dropdown icon" > < / i >
Revenue comments
< / div >
2018-12-07 10:51:43 +11:00
< div class = "active content" >
2020-02-27 19:27:05 +11:00
{{ revision.revenue_comments|markdown }}
2018-06-26 20:14:16 +10:00
< / div >
< / div >
{% endif %}
< / td >
< / tr >
< tr >
< td > Expenses< / td >
< td >
2019-06-19 17:38:20 +10:00
{% if revision.expense_no_emergency_fund %}
< p > < input type = "checkbox" id = "expense_no_emergency_fund" disabled checked > No emergency fund required (please add a comment explaining why)< / p >
{% endif %}
2018-06-26 23:06:14 +10:00
< div id = "expense_grid" > < / div >
2018-06-26 20:14:16 +10:00
{% if revision.expense_comments %}
< div class = "ui accordion" >
< div class = "active title" >
< i class = "dropdown icon" > < / i >
Expense comments
< / div >
2018-12-07 10:51:43 +11:00
< div class = "active content" >
2020-02-27 19:27:05 +11:00
{{ revision.expense_comments|markdown }}
2018-06-26 20:14:16 +10:00
< / div >
< / div >
{% endif %}
< / td >
< / tr >
2020-01-17 21:30:52 +11:00
< tr >
< td > Total Profit (Loss)< / td >
< 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 >
< / tr >
2018-06-26 20:14:16 +10:00
< / tbody >
< / table >
{% if is_latest %}
< form class = "ui form" action = "{{ url('budget_action', kwargs={'id': revision.budget.id}) }}" method = "POST" >
< div class = "required field" >
< textarea rows = "4" name = "comment" > < / textarea >
< / div >
2020-01-04 21:41:36 +11:00
< input type = "hidden" name = "action" >
2018-06-26 20:14:16 +10:00
< input type = "hidden" name = "csrfmiddlewaretoken" value = "{{ csrf_token }}" >
2020-01-04 21:41:36 +11:00
< button class = "ui primary button" data-action = "Comment" onclick = "return uiSubmit(this);" > Comment< / button >
2019-06-20 01:06:24 +10:00
{% if revision.state == import('sstreasury.models').BudgetState.AWAIT_REVIEW.value and request.user.groups.filter(name='Treasury').exists() %}
2020-01-04 21:41:36 +11:00
< 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 >
2019-06-20 01:39:29 +10:00
2020-01-04 21:41:36 +11:00
< 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 >
2019-06-20 01:39:29 +10:00
{% elif revision.state != import('sstreasury.models').BudgetState.APPROVED.value and request.user.groups.filter(name='Secretary').exists() %}
2020-01-04 21:41:36 +11:00
< 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 >
2019-06-20 01:06:24 +10:00
2020-01-04 21:41:36 +11:00
< 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 >
2019-06-20 01:06:24 +10:00
{% endif %}
2018-06-26 20:14:16 +10:00
< / form >
< div class = "ui feed" >
{% for item in history %}
{% if item.__class__.__name__ == 'BudgetComment' %}
< div class = "event" >
< div class = "label" >
< i class = "comment alternate outline icon" > < / i >
< / div >
< div class = "content" >
< div class = "summary" >
< i class = "user circle icon" > < / i >
2019-06-19 19:46:24 +10:00
< a href = "mailto:{{ item.author.email }}" > {{ item.author.first_name }} {{ item.author.last_name }}< / a > commented
2018-06-26 20:14:16 +10:00
< div class = "date" >
{{ localtime(item.time) }}
< / div >
< / div >
< div class = "extra text" >
2019-06-19 19:46:24 +10:00
{{ item.content|markdown }}
2018-06-26 20:14:16 +10:00
< / div >
< / div >
< / div >
{% elif item.__class__.__name__ == 'BudgetRevision' %}
< div class = "event" >
< div class = "label" >
< i class = "edit icon" > < / i >
< / div >
< div class = "content" >
< div class = "summary" >
< i class = "user circle icon" > < / i >
2019-06-19 19:46:24 +10:00
{% if item.action == import('sstreasury.models').BudgetAction.CREATE.value %}
< 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 >
{% elif item.action == import('sstreasury.models').BudgetAction.EDIT.value %}
< 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 >
{% elif item.action == import('sstreasury.models').BudgetAction.UPDATE_STATE.value %}
< a href = "mailto:{{ item.author.email }}" > {{ item.author.first_name }} {{ item.author.last_name }}< / a > changed the state to: {{ item.get_state_display() }}
{% else %}
< 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 >
{% endif %}
2018-06-26 20:14:16 +10:00
< div class = "date" >
{{ localtime(item.time) }}
< / div >
< / div >
< / div >
< / div >
{% endif %}
{% endfor %}
< / div >
{% endif %}
2020-01-04 21:41:36 +11:00
< div class = "ui modal" >
< div class = "content" data-action = "Submit" >
< 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 >
< / div >
< div class = "content" data-action = "Endorse" >
< p > Are you sure you want to give this budget Treasury endorsement?< / p >
< / div >
< div class = "content" data-action = "Comment,Endorse" >
< p > Are you sure you want to give this budget Treasury endorsement?< / p >
< / div >
< div class = "content" data-action = "Return" >
< p > Are you sure you want to refuse this budget Treasury endorsement and return it for re-drafting?< / p >
< / div >
< div class = "content" data-action = "Comment,Return" >
< p > Are you sure you want to refuse this budget Treasury endorsement and return it for re-drafting?< / p >
< / div >
< div class = "content" data-action = "Approve" >
< p > Are you sure you want to mark this budget as committee-approved?< / p >
< / div >
< div class = "content" data-action = "Comment,Approve" >
< p > Are you sure you want to mark this budget as committee-approved?< / p >
< / div >
< div class = "content" data-action = "CmteReturn" >
< p > Are you sure you want to refuse this budget committee approval and return it for re-drafting?< / p >
< / div >
< div class = "content" data-action = "Comment,CmteReturn" >
< p > Are you sure you want to refuse this budget committee approval and return it for re-drafting?< / p >
< / div >
< div class = "content" data-action = "Withdraw" >
< p > Are you sure you want to withdraw this budget from being considered for approval? The budget will be reverted to a draft.< / p >
< / div >
< div class = "actions" >
< div class = "ui primary approve button" > Continue< / div >
< div class = "ui cancel button" > Cancel< / div >
< / div >
< / div >
2018-06-26 20:14:16 +10:00
{% endblock %}
2018-06-26 23:06:14 +10:00
{% block head %}
{{ super() }}
< link rel = "stylesheet" href = "https://cdn.jsdelivr.net/npm/jsgrid@1.5.3/dist/jsgrid.min.css" integrity = "sha256-a/jNbtm7jpeKiXCShJ8YC+eNL9Abh7CBiYXHgaofUVs=" crossorigin = "anonymous" >
< link rel = "stylesheet" href = "https://cdn.jsdelivr.net/npm/jsgrid@1.5.3/dist/jsgrid-theme.min.css" integrity = "sha256-0rD7ZUV4NLK6VtGhEim14ZUZGC45Kcikjdcr4N03ddA=" crossorigin = "anonymous" >
< style >
2018-12-07 10:51:43 +11:00
/* Fix the CSS */
2018-06-26 23:06:14 +10:00
.ui.mydefinition.table > tbody > tr > td:first-child:not(.ignored) {
background: rgba(0,0,0,.03);
font-weight: 700;
color: rgba(0,0,0,.95);
}
2018-12-07 10:51:43 +11:00
.jsgrid-align-right, .jsgrid-align-right input, .jsgrid-align-right select, .jsgrid-align-right textarea {
text-align: right !important;
}
.jsgrid-cell {
padding: .5em !important;
}
.jsgrid-header-row .jsgrid-header-cell {
text-align: center !important;
}
2018-06-26 23:06:14 +10:00
< / style >
{% endblock %}
{% block script %}
{{ super() }}
2020-01-04 21:41:36 +11:00
< script >
function uiSubmit(button) {
button.form.elements['action'].value = button.dataset['action'];
button.form.submit();
return false;
}
function uiConfirm(button) {
$('.ui.modal .content').hide();
$('.ui.modal .content').filter('[data-action="' + button.dataset['action'] + '"]').show();
$('.ui.modal').modal({
closable: false,
onApprove: function() {
uiSubmit(button);
}
}).modal('show');
return false;
}
< / script >
2018-06-26 23:06:14 +10:00
< script src = "https://cdn.jsdelivr.net/npm/jsgrid@1.5.3/dist/jsgrid.min.js" integrity = "sha256-lzjMTpg04xOdI+MJdjBst98bVI6qHToLyVodu3EywFU=" crossorigin = "anonymous" > < / script >
2019-06-19 17:38:20 +10:00
< script src = "{{ static('sstreasury/budget.js') }}" > < / script >
2018-06-26 23:06:14 +10:00
< script >
var revenue_data = JSON.parse({{ import('json').dumps(import('json').dumps(revision.revenue))|safe }});
var expense_data = JSON.parse({{ import('json').dumps(import('json').dumps(revision.expense))|safe }});
2019-06-19 17:38:20 +10:00
var editing = false;
makeGrid();
2020-01-19 00:02:11 +11:00
$('.jsgrid-filter-row, .jsgrid-insert-row').attr('style', 'display: none !important;'); /* Override Semantic UI */
2018-06-26 23:06:14 +10:00
< / script >
{% endblock %}