Implement basic filtering of claims/budgets
This commit is contained in:
parent
8a3a09d8ab
commit
1217770900
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
{#
|
{#
|
||||||
Society Self-Service
|
Society Self-Service
|
||||||
Copyright © 2018–2020 Yingtong Li (RunasSudo)
|
Copyright © 2018–2023 Yingtong Li (RunasSudo)
|
||||||
|
Copyright © 2023 MUMUS Inc.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -28,7 +29,7 @@
|
|||||||
<th class="four wide">Status</th>
|
<th class="four wide">Status</th>
|
||||||
<th class="one wide">View</th>
|
<th class="one wide">View</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thea d>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for revision in budgets %}
|
{% for revision in budgets %}
|
||||||
<tr>
|
<tr>
|
||||||
@ -46,8 +47,30 @@
|
|||||||
{% block maincontent %}
|
{% block maincontent %}
|
||||||
<h1>Your budgets</h1>
|
<h1>Your budgets</h1>
|
||||||
|
|
||||||
|
<form class="ui form" method="GET">
|
||||||
|
<div class="fields">
|
||||||
|
<div class="eight wide field">
|
||||||
|
<label>State</label>
|
||||||
|
<select class="ui dropdown" name="state">
|
||||||
|
<option value="all"{% if request.GET.get('state', 'all') == 'all' %} selected{% endif %}>All states</option>
|
||||||
|
{% for state in import('sstreasury.models').BudgetState %}
|
||||||
|
<option value="{{ state._value_ }}"{% if request.GET.get('state', 'all') == state._value_|string %} selected{% endif %}>{{ state.description }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="five wide field">
|
||||||
|
<label>Year</label>
|
||||||
|
<input name="year" value="{{ request.GET.get('year', '') }}">
|
||||||
|
</div>
|
||||||
|
<div class="three wide field">
|
||||||
|
<label> </label>
|
||||||
|
<button type="submit" class="ui primary labeled icon button" style="width:100%"><i class="filter icon"></i>Filter</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
{% if not budgets_action and not budgets_open and not budgets_closed %}
|
{% if not budgets_action and not budgets_open and not budgets_closed %}
|
||||||
<p>You have no budgets to view. To create a budget, click <a href="{{ url('budget_new') }}">Create new budget</a>.</p>
|
<p>There are no budgets matching the selected criteria. To create a budget, click <a href="{{ url('budget_new') }}">Create new budget</a>.</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if budgets_action %}
|
{% if budgets_action %}
|
||||||
@ -72,3 +95,11 @@
|
|||||||
{% block head %}
|
{% block head %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block script %}
|
||||||
|
{{ super() }}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$('.ui.dropdown').dropdown();
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
{#
|
{#
|
||||||
Society Self-Service
|
Society Self-Service
|
||||||
Copyright © 2018–2020 Yingtong Li (RunasSudo)
|
Copyright © 2018–2023 Yingtong Li (RunasSudo)
|
||||||
|
Copyright © 2023 MUMUS Inc.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -46,8 +47,30 @@
|
|||||||
{% block maincontent %}
|
{% block maincontent %}
|
||||||
<h1>Your reimbursement claims</h1>
|
<h1>Your reimbursement claims</h1>
|
||||||
|
|
||||||
|
<form class="ui form" method="GET">
|
||||||
|
<div class="fields">
|
||||||
|
<div class="eight wide field">
|
||||||
|
<label>State</label>
|
||||||
|
<select class="ui dropdown" name="state">
|
||||||
|
<option value="all"{% if request.GET.get('state', 'all') == 'all' %} selected{% endif %}>All states</option>
|
||||||
|
{% for state in import('sstreasury.models').ClaimState %}
|
||||||
|
<option value="{{ state._value_ }}"{% if request.GET.get('state', 'all') == state._value_|string %} selected{% endif %}>{{ state.description }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="five wide field">
|
||||||
|
<label>Year</label>
|
||||||
|
<input name="year" value="{{ request.GET.get('year', '') }}">
|
||||||
|
</div>
|
||||||
|
<div class="three wide field">
|
||||||
|
<label> </label>
|
||||||
|
<button type="submit" class="ui primary labeled icon button" style="width:100%"><i class="filter icon"></i>Filter</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
{% if not claims_action and not claims_open and not claims_closed %}
|
{% if not claims_action and not claims_open and not claims_closed %}
|
||||||
<p>You have no reimbursement claims to view. To create a claim, click <a href="{{ url('claim_new') }}">Create new claim</a>.</p>
|
<p>There are no reimbursement claims matching the selected criteria. To create a claim, click <a href="{{ url('claim_new') }}">Create new claim</a>.</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if claims_action %}
|
{% if claims_action %}
|
||||||
@ -72,3 +95,11 @@
|
|||||||
{% block head %}
|
{% block head %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block script %}
|
||||||
|
{{ super() }}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$('.ui.dropdown').dropdown();
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
@ -209,17 +209,29 @@ def index(request):
|
|||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def budget_list(request):
|
def budget_list(request):
|
||||||
|
# Filter budgets
|
||||||
|
budgets_filtered = []
|
||||||
|
for budget in models.Budget.objects.all():
|
||||||
|
revision = budget.budgetrevision_set.reverse()[0]
|
||||||
|
|
||||||
|
if not revision.can_view(request.user):
|
||||||
|
continue
|
||||||
|
|
||||||
|
if request.GET.get('state', 'all') != 'all' and str(revision.state) != request.GET.get('state', 'all'):
|
||||||
|
continue
|
||||||
|
if request.GET.get('year', '') != '' and str(revision.time.year) != request.GET.get('year', ''):
|
||||||
|
continue
|
||||||
|
|
||||||
|
budgets_filtered.append(revision)
|
||||||
|
|
||||||
|
# Categorise budgets
|
||||||
budgets_action = []
|
budgets_action = []
|
||||||
budgets_open = []
|
budgets_open = []
|
||||||
budgets_closed = []
|
budgets_closed = []
|
||||||
|
|
||||||
for budget in models.Budget.objects.all():
|
for revision in budgets_filtered:
|
||||||
revision = budget.budgetrevision_set.reverse()[0]
|
|
||||||
state = models.BudgetState(revision.state)
|
state = models.BudgetState(revision.state)
|
||||||
|
|
||||||
if not revision.can_view(request.user):
|
|
||||||
continue
|
|
||||||
|
|
||||||
group = None
|
group = None
|
||||||
|
|
||||||
if request.user.groups.filter(name='Treasury').exists() and state == models.BudgetState.AWAIT_REVIEW:
|
if request.user.groups.filter(name='Treasury').exists() and state == models.BudgetState.AWAIT_REVIEW:
|
||||||
@ -548,16 +560,27 @@ def budget_action(request, budget, revision):
|
|||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def claim_list(request):
|
def claim_list(request):
|
||||||
|
# Filter claims
|
||||||
|
claims_filter = []
|
||||||
|
for claim in models.ReimbursementClaim.objects.all():
|
||||||
|
if not claim.can_view(request.user):
|
||||||
|
continue
|
||||||
|
|
||||||
|
if request.GET.get('state', 'all') != 'all' and str(claim.state) != request.GET.get('state', 'all'):
|
||||||
|
continue
|
||||||
|
if request.GET.get('year', '') != '' and str(claim.time.year) != request.GET.get('year', ''):
|
||||||
|
continue
|
||||||
|
|
||||||
|
claims_filter.append(claim)
|
||||||
|
|
||||||
|
# Categorise claims
|
||||||
claims_action = []
|
claims_action = []
|
||||||
claims_open = []
|
claims_open = []
|
||||||
claims_closed = []
|
claims_closed = []
|
||||||
|
|
||||||
for claim in models.ReimbursementClaim.objects.all():
|
for claim in claims_filter:
|
||||||
state = models.ClaimState(claim.state)
|
state = models.ClaimState(claim.state)
|
||||||
|
|
||||||
if not claim.can_view(request.user):
|
|
||||||
continue
|
|
||||||
|
|
||||||
group = None
|
group = None
|
||||||
|
|
||||||
if request.user.groups.filter(name='Treasury').exists() and state in [models.ClaimState.AWAIT_REVIEW, models.ClaimState.APPROVED]:
|
if request.user.groups.filter(name='Treasury').exists() and state in [models.ClaimState.AWAIT_REVIEW, models.ClaimState.APPROVED]:
|
||||||
|
Loading…
Reference in New Issue
Block a user