Minor enhancements

* refactors eco account rest surface calculation into designated method get_available_rest()
* refactors placeholder setter for BaseForm
* adds automatic eco account identifier generating on saving
* fixes ServerMessageImportance template tag
This commit is contained in:
mipel
2021-08-11 14:17:43 +02:00
parent c95e451520
commit df70f99ca4
8 changed files with 77 additions and 15 deletions
+1 -4
View File
@@ -238,10 +238,7 @@ class EcoAccountTable(BaseTable):
Returns:
"""
withdraws = record.withdraws.all()
withdraw_surfaces = withdraws.aggregate(Sum("surface"))["surface__sum"] or 0
after_states_surfaces = record.after_states.all().aggregate(Sum("surface"))["surface__sum"] or withdraw_surfaces ## no division by zero
value = int(((after_states_surfaces - withdraw_surfaces) / after_states_surfaces) * 100)
value = record.get_available_rest(as_percentage=True)
html = render_to_string("konova/custom_widgets/progressbar.html", {"value": value})
return format_html(html)