mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-06 13:01:50 +02:00
use rendered currency list
This commit is contained in:
parent
ddf8007342
commit
08c4ea473f
2 changed files with 5 additions and 16 deletions
|
@ -23,7 +23,7 @@ from wtforms.validators import (
|
|||
|
||||
from ihatemoney.currency_convertor import CurrencyConverter
|
||||
from ihatemoney.models import LoggingMode, Person, Project
|
||||
from ihatemoney.utils import eval_arithmetic_expression, slugify
|
||||
from ihatemoney.utils import eval_arithmetic_expression, slugify, render_localized_currency
|
||||
|
||||
|
||||
def strip_filter(string):
|
||||
|
@ -33,18 +33,6 @@ def strip_filter(string):
|
|||
return string
|
||||
|
||||
|
||||
def get_editprojectform_for(project, **kwargs):
|
||||
"""Return an instance of EditProjectForm configured for a particular project.
|
||||
"""
|
||||
form = EditProjectForm(**kwargs)
|
||||
choices = copy.copy(form.default_currency.choices)
|
||||
choices.sort(
|
||||
key=lambda rates: "" if rates[0] == project.default_currency else rates[0]
|
||||
)
|
||||
form.default_currency.choices = choices
|
||||
return form
|
||||
|
||||
|
||||
def get_billform_for(project, set_default=True, **kwargs):
|
||||
"""Return an instance of BillForm configured for a particular project.
|
||||
|
||||
|
@ -124,7 +112,7 @@ class EditProjectForm(FlaskForm):
|
|||
default_currency = SelectField(
|
||||
_("Default Currency"),
|
||||
choices=[
|
||||
(currency_name, currency_name)
|
||||
(currency_name, render_localized_currency(currency_name))
|
||||
for currency_name in currency_helper.get_currencies()
|
||||
],
|
||||
validators=[DataRequired()],
|
||||
|
|
|
@ -48,7 +48,7 @@ from ihatemoney.forms import (
|
|||
ResetPasswordForm,
|
||||
UploadForm,
|
||||
get_billform_for,
|
||||
get_editprojectform_for,
|
||||
EditProjectForm,
|
||||
)
|
||||
from ihatemoney.history import get_history, get_history_queries
|
||||
from ihatemoney.models import Bill, LoggingMode, Person, Project, db
|
||||
|
@ -377,7 +377,7 @@ def reset_password():
|
|||
|
||||
@main.route("/<project_id>/edit", methods=["GET", "POST"])
|
||||
def edit_project():
|
||||
edit_form = get_editprojectform_for(g.project)
|
||||
edit_form = EditProjectForm()
|
||||
import_form = UploadForm()
|
||||
# Import form
|
||||
if import_form.validate_on_submit():
|
||||
|
@ -417,6 +417,7 @@ def edit_project():
|
|||
edit_form.ip_recording.data = True
|
||||
|
||||
edit_form.contact_email.data = g.project.contact_email
|
||||
edit_form.default_currency.data = g.project.default_currency
|
||||
|
||||
return render_template(
|
||||
"edit_project.html",
|
||||
|
|
Loading…
Reference in a new issue