From 49286448ec179eafebec63e262979765d45a94e2 Mon Sep 17 00:00:00 2001 From: Tom Roussel <21120212+TomRoussel@users.noreply.github.com> Date: Sat, 2 Mar 2024 12:52:57 +0100 Subject: [PATCH] Fixed billtype displaying in all caps --- ihatemoney/forms.py | 2 +- ihatemoney/models.py | 7 ++++++- ihatemoney/templates/list_bills.html | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ihatemoney/forms.py b/ihatemoney/forms.py index 9f62688d..11ce57a9 100644 --- a/ihatemoney/forms.py +++ b/ihatemoney/forms.py @@ -364,7 +364,7 @@ class BillForm(FlaskForm): payed_for = SelectMultipleField( _("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")) submit2 = SubmitField(_("Submit and add a new one")) diff --git a/ihatemoney/models.py b/ihatemoney/models.py index a868772d..8638361c 100644 --- a/ihatemoney/models.py +++ b/ihatemoney/models.py @@ -1,4 +1,5 @@ from collections import defaultdict +from enum import Enum import datetime import itertools @@ -50,11 +51,15 @@ make_versioned( ], ) -class BillType(FormEnum): +class BillType(Enum): EXPENSE = "Expense" REIMBURSEMENT = "Reimbursement" TRANSFER = "Transfer" + @classmethod + def choices(cls): + return [(choice, choice.value) for choice in cls] + db = SQLAlchemy() diff --git a/ihatemoney/templates/list_bills.html b/ihatemoney/templates/list_bills.html index a43279d4..6f2fbbaa 100644 --- a/ihatemoney/templates/list_bills.html +++ b/ihatemoney/templates/list_bills.html @@ -133,7 +133,7 @@ {{ bill.date }} -