mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-28 17:32:38 +02:00
bill_type is now an optional parameter in the BillForm
This commit is contained in:
parent
b602134772
commit
8acbf714f7
2 changed files with 31 additions and 2 deletions
|
@ -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(), coerce=BillType)
|
||||
bill_type = SelectField(_("Bill Type"), choices=BillType.choices(), coerce=BillType, default=BillType.EXPENSE)
|
||||
submit = SubmitField(_("Submit"))
|
||||
submit2 = SubmitField(_("Submit and add a new one"))
|
||||
|
||||
|
|
|
@ -1048,3 +1048,32 @@ class TestAPI(IhatemoneyTestCase):
|
|||
)
|
||||
|
||||
self.assertStatus(201, req)
|
||||
|
||||
def test_default_bill_type(self):
|
||||
self.api_create("raclette")
|
||||
self.api_add_member("raclette", "zorglub")
|
||||
|
||||
# Post a bill without adding a bill type
|
||||
req = self.client.post(
|
||||
"/api/projects/raclette/bills",
|
||||
data={
|
||||
"date": "2011-08-10",
|
||||
"what": "fromage",
|
||||
"payer": "1",
|
||||
"payed_for": ["1"],
|
||||
"amount": "50",
|
||||
},
|
||||
headers=self.get_auth("raclette")
|
||||
)
|
||||
|
||||
self.assertStatus(201, req)
|
||||
|
||||
req = self.client.get(
|
||||
"/api/projects/raclette/bills/1", headers=self.get_auth("raclette")
|
||||
)
|
||||
self.assertStatus(200, req)
|
||||
|
||||
# Bill type should now be "Expense"
|
||||
got = json.loads(req.data.decode("utf-8"))
|
||||
assert got["bill_type"] == "Expense"
|
||||
|
||||
|
|
Loading…
Reference in a new issue