From 5176f1950a136e0fa024758dfa49458f91cc9ee6 Mon Sep 17 00:00:00 2001 From: Glandos Date: Sun, 4 Jul 2021 15:57:22 +0200 Subject: [PATCH] more comments --- ihatemoney/forms.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ihatemoney/forms.py b/ihatemoney/forms.py index d701ac09..866e5e2e 100644 --- a/ihatemoney/forms.py +++ b/ihatemoney/forms.py @@ -112,8 +112,12 @@ class EditProjectForm(FlaskForm): def __init__(self, *args, **kwargs): if not hasattr(self, "id"): - # We must access the project to validate the default currency. - # Mimics a StringField. Defaut to empty string to ensure that query run smoothly. + # We must access the project to validate the default currency, using its id. + # In ProjectForm, 'id' is provided, but not in this base class, so it *must* + # be provided by callers. + # Since id can be defined as a WTForms.StringField, we mimics it, + # using an object that can have a 'data' attribute. + # It defaults to empty string to ensure that query run smoothly. self.id = SimpleNamespace(data=kwargs.pop("id", "")) super().__init__(*args, **kwargs) self.default_currency.choices = [