diff options
| author | Marius Peter <marius.peter@tutanota.com> | 2022-05-16 21:11:52 +0200 | 
|---|---|---|
| committer | Marius Peter <marius.peter@tutanota.com> | 2022-05-16 21:11:52 +0200 | 
| commit | eac5bb765c8d609d3b7eb31316228f8058581796 (patch) | |
| tree | 71858ed6cef43bb5dea24de1222b3c828d93b821 /app/modules | |
| parent | 196c3bbf8a140f962845c51e22f409aa6b4d7473 (diff) | |
Lil fixes.
Diffstat (limited to 'app/modules')
| -rw-r--r-- | app/modules/auth/routes.py | 2 | ||||
| -rw-r--r-- | app/modules/common.py | 2 | ||||
| -rw-r--r-- | app/modules/forms.py | 5 | ||||
| -rw-r--r-- | app/modules/invoices/forms.py | 2 | 
4 files changed, 8 insertions, 3 deletions
| diff --git a/app/modules/auth/routes.py b/app/modules/auth/routes.py index dd9e396..d0aee0c 100644 --- a/app/modules/auth/routes.py +++ b/app/modules/auth/routes.py @@ -62,7 +62,7 @@ def register():          db.session.commit()          flash(f"Created user {req['name_first']} {req['name_last']} successfully.")          return redirect(url_for("main.home")) -    return render_template("register.html", form=form) +    return render_template("modules/register.html", form=form)  @auth.route("/logout") diff --git a/app/modules/common.py b/app/modules/common.py index 9e96f41..f9ccba6 100644 --- a/app/modules/common.py +++ b/app/modules/common.py @@ -48,7 +48,7 @@ def edit_item(module, table, pk):      form = getattr(forms, f"Add{table}")(**item.__dict__)      if form.validate_on_submit():          table_fields = inspect.signature(model).parameters -        form_values = {key: request.form[key] for key in table_fields} +        form_values = {key: request.form.get(key) for key in table_fields}          print(f"Ready to update {form_values}")          model.query.filter_by(primary_key=pk).update(form_values)          db.session.commit() diff --git a/app/modules/forms.py b/app/modules/forms.py index f98995d..7e4acde 100644 --- a/app/modules/forms.py +++ b/app/modules/forms.py @@ -1,5 +1,10 @@  # -*- mode: python; -*- +"""Form class attribute names must match model class attribute names +for proper request.form dictionary splatting. + +""" +  from .customers.forms import AddCustomer  from .ferti.forms import AddFertiLog, AddFertiTarget  from .invoices.forms import AddInvoice diff --git a/app/modules/invoices/forms.py b/app/modules/invoices/forms.py index 8ef7bd0..74df40e 100644 --- a/app/modules/invoices/forms.py +++ b/app/modules/invoices/forms.py @@ -26,7 +26,7 @@ class AddInvoice(FlaskForm):      amount_tax = FloatField("Amount of tax", default=0)      submit = SubmitField("Add new Invoice") -    def __init__(self, **kwargs): +    def __init__(self):          super().__init__()          self.customer_id.choices = [              (cus.primary_key, cus.name) for cus in Customer.query.all() | 
