Compare commits

...

6 commits

Author SHA1 Message Date
charlieezh
aa0d8b6840
Merge 9b514ca7c7 into 05742347c3 2025-01-05 15:49:25 +01:00
singeltary
05742347c3
UI/navigation changes to in "Edit this participant" (#1323)
Some checks are pending
CI / lint (push) Waiting to run
CI / test (mariadb, minimal, 3.11) (push) Blocked by required conditions
CI / test (mariadb, normal, 3.11) (push) Blocked by required conditions
CI / test (mariadb, normal, 3.9) (push) Blocked by required conditions
CI / test (postgresql, minimal, 3.11) (push) Blocked by required conditions
CI / test (postgresql, normal, 3.11) (push) Blocked by required conditions
CI / test (postgresql, normal, 3.9) (push) Blocked by required conditions
CI / test (sqlite, minimal, 3.10) (push) Blocked by required conditions
CI / test (sqlite, minimal, 3.11) (push) Blocked by required conditions
CI / test (sqlite, minimal, 3.12) (push) Blocked by required conditions
CI / test (sqlite, minimal, 3.9) (push) Blocked by required conditions
CI / test (sqlite, normal, 3.10) (push) Blocked by required conditions
CI / test (sqlite, normal, 3.11) (push) Blocked by required conditions
CI / test (sqlite, normal, 3.12) (push) Blocked by required conditions
CI / test (sqlite, normal, 3.9) (push) Blocked by required conditions
CI / docs (push) Waiting to run
Docker build / test (push) Waiting to run
Docker build / build_upload (push) Blocked by required conditions
* Update forms.html

Added navigation element in 'Edit Participants' window

* Update forms.html

Updated button on form for editing participants--"Save" for edits instead of "Add."
2025-01-05 15:49:20 +01:00
bd689f931a
Merge branch 'fix-1336' 2025-01-05 13:01:16 +01:00
67938eabbc
Do not display deactivated users when their balance is really small
Cases has been reported of rounding issues making deactivated users
reapparing. This is due to the fact we're using floats (see #528 for
details)

Fixes #1336
2025-01-05 13:00:54 +01:00
charlieezh
9b514ca7c7
Add files via upload
implemented the filter feature for bills based on start date and end date.
2024-04-26 17:07:39 -04:00
charlieezh
9433b7de92
Add files via upload
created a form in the html to filter the bills
2024-04-26 17:06:02 -04:00
5 changed files with 54 additions and 16 deletions

View file

@ -264,6 +264,12 @@ class Project(db.Model):
.order_by(Bill.id.desc())
)
@staticmethod
def filter(query, start_date, end_date):
return (
query.filter(Bill.date >= start_date, Bill.date <= end_date)
)
def get_bill_weights(self):
"""
Return all bills for this project, along with the sum of weight for each bill.
@ -285,6 +291,9 @@ class Project(db.Model):
"""Ordered version of get_bill_weights"""
return self.order_bills(self.get_bill_weights())
def get_filtered_bill_weights_ordered(self, start_date, end_date):
return self.filter(self.get_bill_weights_ordered(), start_date, end_date)
def get_member_bills(self, member_id):
"""Return the list of bills related to a specific member"""
return (

View file

@ -236,7 +236,8 @@
{{ input(form.weight) }}
</fieldset>
<div class="actions">
{{ form.submit(class="btn btn-primary") }}
<button class="btn btn-secondary input-group-addon" type="submit">{{ _("Save") }}</button>
<a href="{{ url_for(".list_bills") }}" class="btn btn-outline-secondary"> {{_("Cancel") }} </a>
</div>
{% endmacro %}

View file

@ -105,6 +105,16 @@
<li class="page-item {% if bills.page == bills.pages %}disabled{% endif %}"><a class="page-link" href="{{ url_for('main.list_bills', page=bills.next_num) }}">{{ _("Older bills") }} &raquo;</a></li>
</ul>
{% endif %}
<form action="{{ url_for(".list_bills") }}" method="post">
{{ csrf_form.csrf_token }}
<label for="start_date">Start Date:</label>
<input type="date" id="start_date" name="start_date" value="{{ start_date if start_date else '' }}">
<label for="end_date">End Date:</label>
<input type="date" id="end_date" name="end_date" value="{{ end_date if end_date else '' }}">
<input type="submit" value="Filter">
</form>
<span id="new-bill" class="ml-auto pb-2" {% if not g.project.members %} data-toggle="tooltip" title="{{_('You should start by adding participants')}}" {% endif %}>
<a href="{{ url_for('.add_bill') }}" class="btn btn-primary {% if not g.project.members %} disabled {% endif %}" data-toggle="modal" data-keyboard="true" data-target="#bill-form" autofocus>
<i class="icon icon-white before-text">{{ static_include("images/plus.svg") | safe }}</i>

View file

@ -11,7 +11,7 @@
</tr>
</thead>
{%- endif %}
{%- for member in g.project.members | sort(attribute='name') if member.activated or balance[member.id]|round(2) != 0 %}
{%- for member in g.project.members | sort(attribute='name') if member.activated or balance[member.id]|round(2)|abs > 0.01 %}
<tr id="bal-member-{{ member.id }}" action="{% if member.activated %}delete{% else %}reactivate{% endif %}">
<td class="balance-name">{{ member.name }}
{%- if show_weight -%}
@ -61,4 +61,4 @@
{% endblock %}
{# It must be set outside of the block definition #}
{% set messages_shown = True %}
{% set messages_shown = True %}

View file

@ -648,7 +648,7 @@ def invite():
return render_template("send_invites.html", form=form, qrcode=qrcode_svg)
@main.route("/<project_id>/")
@main.route("/<project_id>/", methods=["GET", "POST"])
def list_bills():
bill_form = get_billform_for(g.project)
# Used for CSRF validation
@ -672,19 +672,37 @@ def list_bills():
# Each item will be a (weight_sum, Bill) tuple.
# TODO: improve this awkward result using column_property:
# https://docs.sqlalchemy.org/en/14/orm/mapped_sql_expr.html.
weighted_bills = g.project.get_bill_weights_ordered().paginate(
per_page=100, error_out=True
)
if request.method == "GET":
weighted_bills = g.project.get_bill_weights_ordered().paginate(
per_page=100, error_out=True
)
return render_template(
"list_bills.html",
bills=weighted_bills,
member_form=MemberForm(g.project),
bill_form=bill_form,
csrf_form=csrf_form,
add_bill=request.values.get("add_bill", False),
current_view="list_bills",
)
if request.method == "POST":
start_date = request.form['start_date']
end_date = request.form['end_date']
weighted_bills = g.project.get_filtered_bill_weights_ordered(start_date, end_date).paginate(
per_page=100, error_out=True
)
return render_template(
"list_bills.html",
bills=weighted_bills,
member_form=MemberForm(g.project),
bill_form=bill_form,
csrf_form=csrf_form,
add_bill=request.values.get("add_bill", False),
current_view="list_bills",
start_date=start_date,
end_date=end_date,
)
return render_template(
"list_bills.html",
bills=weighted_bills,
member_form=MemberForm(g.project),
bill_form=bill_form,
csrf_form=csrf_form,
add_bill=request.values.get("add_bill", False),
current_view="list_bills",
)
@main.route("/<project_id>/members/add", methods=["GET", "POST"])