Fixed billtype displaying in all caps

This commit is contained in:
Tom Roussel 2024-03-02 12:52:57 +01:00
parent bf9601377d
commit 49286448ec
3 changed files with 8 additions and 3 deletions

View file

@ -364,7 +364,7 @@ class BillForm(FlaskForm):
payed_for = SelectMultipleField( payed_for = SelectMultipleField(
_("For whom?"), validators=[DataRequired()], coerce=int _("For whom?"), validators=[DataRequired()], coerce=int
) )
bill_type = SelectField(_("Bill Type"), validators=[DataRequired()], choices=BillType.choices()) bill_type = SelectField(_("Bill Type"), validators=[DataRequired()], choices=BillType.choices(), coerce=BillType)
submit = SubmitField(_("Submit")) submit = SubmitField(_("Submit"))
submit2 = SubmitField(_("Submit and add a new one")) submit2 = SubmitField(_("Submit and add a new one"))

View file

@ -1,4 +1,5 @@
from collections import defaultdict from collections import defaultdict
from enum import Enum
import datetime import datetime
import itertools import itertools
@ -50,11 +51,15 @@ make_versioned(
], ],
) )
class BillType(FormEnum): class BillType(Enum):
EXPENSE = "Expense" EXPENSE = "Expense"
REIMBURSEMENT = "Reimbursement" REIMBURSEMENT = "Reimbursement"
TRANSFER = "Transfer" TRANSFER = "Transfer"
@classmethod
def choices(cls):
return [(choice, choice.value) for choice in cls]
db = SQLAlchemy() db = SQLAlchemy()

View file

@ -133,7 +133,7 @@
{{ bill.date }} {{ bill.date }}
</span> </span>
</td> </td>
<td>{{ bill.bill_type }}</td> <td>{{ bill.bill_type.value }}</td>
<td>{{ bill.payer }}</td> <td>{{ bill.payer }}</td>
<td>{{ bill.what }}</td> <td>{{ bill.what }}</td>
<td>{% if bill.owers|length == g.project.members|length -%} <td>{% if bill.owers|length == g.project.members|length -%}