mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-06 05:01:48 +02:00
Show currency dropdown in BillForm
This commit is contained in:
parent
7526e96022
commit
cda60ee55d
2 changed files with 7 additions and 3 deletions
|
@ -2,6 +2,7 @@ from flask_wtf.form import FlaskForm
|
|||
from wtforms.fields.core import SelectField, SelectMultipleField
|
||||
from wtforms.fields.html5 import DateField, DecimalField, URLField
|
||||
from wtforms.fields.simple import PasswordField, SubmitField, StringField
|
||||
from wtforms.fields.core import Label
|
||||
from wtforms.validators import (
|
||||
Email,
|
||||
DataRequired,
|
||||
|
@ -37,7 +38,8 @@ def get_billform_for(project, set_default=True, **kwargs):
|
|||
display the default form, it will call set_default on it.
|
||||
|
||||
"""
|
||||
form = BillForm(**kwargs, project)
|
||||
form = BillForm(project=project, **kwargs)
|
||||
form.original_currency.label = Label("original_currency", "Currency (Default: %s)" % (project.default_currency))
|
||||
active_members = [(m.id, m.name) for m in project.active_members]
|
||||
|
||||
form.payed_for.choices = form.payer.choices = active_members
|
||||
|
@ -163,14 +165,14 @@ class ResetPasswordForm(FlaskForm):
|
|||
submit = SubmitField(_("Reset password"))
|
||||
|
||||
|
||||
class BillForm(FlaskForm, project):
|
||||
class BillForm(FlaskForm):
|
||||
date = DateField(_("Date"), validators=[DataRequired()], default=datetime.now)
|
||||
what = StringField(_("What?"), validators=[DataRequired()])
|
||||
payer = SelectField(_("Payer"), validators=[DataRequired()], coerce=int)
|
||||
amount = CalculatorStringField(_("Amount paid"), validators=[DataRequired()])
|
||||
currency_helper = CurrencyConverter()
|
||||
original_currency = SelectField(
|
||||
_("Currency (Default: %s)" % (project.default_currency)), choices=currency_helper.get_currencies(), validators=[DataRequired()]
|
||||
_("Currency"), choices=currency_helper.get_currencies(), validators=[DataRequired()]
|
||||
)
|
||||
external_link = URLField(
|
||||
_("External link"),
|
||||
|
@ -200,6 +202,7 @@ class BillForm(FlaskForm, project):
|
|||
self.amount.data = bill.amount
|
||||
self.what.data = bill.what
|
||||
self.external_link.data = bill.external_link
|
||||
self.original_currency.data = bill.original_currency
|
||||
self.date.data = bill.date
|
||||
self.payed_for.data = [int(ower.id) for ower in bill.owers]
|
||||
|
||||
|
|
|
@ -98,6 +98,7 @@
|
|||
{{ input(form.payer, inline=True, class="form-control custom-select") }}
|
||||
{{ input(form.amount, inline=True) }}
|
||||
{{ input(form.external_link, inline=True) }}
|
||||
{{ input(form.original_currency, inline=True) }}
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-3" for="payed_for">{{ _("For whom?") }}</label>
|
||||
|
|
Loading…
Reference in a new issue