mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-14 08:21:49 +02:00
-Added tooltip for bills involving deactivated members
-Made involves_deactivated_members() a property of the Bill class -Removed flashed messages
This commit is contained in:
parent
72320c19d7
commit
889576a114
3 changed files with 19 additions and 15 deletions
|
@ -752,7 +752,8 @@ class Bill(db.Model):
|
|||
else:
|
||||
return 0
|
||||
|
||||
def involves_deactivated_members(self, project):
|
||||
@property
|
||||
def involves_deactivated_members(self):
|
||||
"""Check whether the bill contains deactivated member.
|
||||
Return:
|
||||
True if it contains deactivated member,
|
||||
|
@ -762,8 +763,7 @@ class Bill(db.Model):
|
|||
bill_member_id_list = owers_id + [self.payer_id]
|
||||
deactivated_member_number = (
|
||||
Person.query.filter(Person.id.in_(bill_member_id_list))
|
||||
.filter(Person.project_id == project.id)
|
||||
.filter(Person.activated == False)
|
||||
.filter(Person.activated.is_(False))
|
||||
.count()
|
||||
)
|
||||
return deactivated_member_number != 0
|
||||
|
|
|
@ -148,10 +148,22 @@
|
|||
</span>
|
||||
</td>
|
||||
<td class="bill-actions d-flex align-items-center">
|
||||
<a class="edit" href="{{ url_for(".edit_bill", bill_id=bill.id) }}" title="{{ _("edit") }}">{{ _('edit') }}</a>
|
||||
<a class="edit" href="{{ url_for(".edit_bill", bill_id=bill.id) }}" data-toggle="tooltip"
|
||||
{% if bill.involves_deactivated_members %}
|
||||
title="Cannot be edited as deactivated members involved"
|
||||
{% else %}
|
||||
title="Click to edit this bill"
|
||||
{% endif %}
|
||||
>{{ _('edit') }}</a>
|
||||
<form class="delete-bill" action="{{ url_for(".delete_bill", bill_id=bill.id) }}" method="POST">
|
||||
{{ csrf_form.csrf_token }}
|
||||
<button class="action delete" type="submit" title="{{ _("delete") }}"></button>
|
||||
<button class="action delete" type="submit" data-toggle="tooltip"
|
||||
{% if bill.involves_deactivated_members %}
|
||||
title="Cannot be deleted as deactivated members involved"
|
||||
{% else %}
|
||||
title="Click to delete this bill"
|
||||
{% endif %}
|
||||
></button>
|
||||
</form>
|
||||
{% if bill.external_link %}
|
||||
<a class="show" href="{{ bill.external_link }}" ref="noopener" target="_blank" title="{{ _("show") }}">{{ _('show') }} </a>
|
||||
|
|
|
@ -801,11 +801,7 @@ def delete_bill(bill_id):
|
|||
return redirect(url_for(".list_bills"))
|
||||
|
||||
# Check if the bill contains deactivated member. If yes, stop deleting.
|
||||
if bill.involves_deactivated_members(g.project):
|
||||
flash(
|
||||
_("Deactivated users involved. This bill cannot be deleted."),
|
||||
category="warning",
|
||||
)
|
||||
if bill.involves_deactivated_members:
|
||||
return redirect(url_for(".list_bills"))
|
||||
|
||||
db.session.delete(bill)
|
||||
|
@ -823,11 +819,7 @@ def edit_bill(bill_id):
|
|||
raise NotFound()
|
||||
|
||||
# Check if the bill contains deactivated member. If yes, stop editing.
|
||||
if bill.involves_deactivated_members(g.project):
|
||||
flash(
|
||||
_("Deactivated users involved. This bill cannot be edited."),
|
||||
category="warning",
|
||||
)
|
||||
if bill.involves_deactivated_members:
|
||||
return redirect(url_for(".list_bills"))
|
||||
|
||||
form = get_billform_for(g.project, set_default=False)
|
||||
|
|
Loading…
Reference in a new issue