diff --git a/ihatemoney/forms.py b/ihatemoney/forms.py index 7a6a57e4..dc4daea7 100644 --- a/ihatemoney/forms.py +++ b/ihatemoney/forms.py @@ -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()], diff --git a/ihatemoney/web.py b/ihatemoney/web.py index bbc98c4d..d2094d8c 100644 --- a/ihatemoney/web.py +++ b/ihatemoney/web.py @@ -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("//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",