From eba4c1a3113d24319bccc5c52d4d93838334bd31 Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Sun, 3 Jul 2022 20:21:02 +0200 Subject: db now in models; modules. --- app/modules/invoices/forms.py | 10 +++++----- app/modules/invoices/routes.py | 4 +--- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'app/modules/invoices') diff --git a/app/modules/invoices/forms.py b/app/modules/invoices/forms.py index 74df40e..7e2bc50 100644 --- a/app/modules/invoices/forms.py +++ b/app/modules/invoices/forms.py @@ -8,7 +8,7 @@ from wtforms import ( IntegerField, FloatField, BooleanField, - DateTimeField, + DateField, ) from wtforms.validators import InputRequired, Length, NumberRange @@ -19,14 +19,14 @@ class AddInvoice(FlaskForm): customer_id = SelectField("Customer", choices=[]) invoice_id_alt = StringField("Alternative invoice ID") customer_reference = StringField("Customer reference") - date_billed = StringField("Date billed") - date_due = StringField("Date due") + date_billed = DateField('Date billed', format='%Y-%m-%d') + date_due = DateField('Date due', format='%Y-%m-%d') amount_net = FloatField("Amount without tax", default=0) amount_gross = FloatField("Amount with tax", default=0) amount_tax = FloatField("Amount of tax", default=0) - submit = SubmitField("Add new Invoice") + submit = SubmitField("Add Invoice") - def __init__(self): + def __init__(self, **kwargs): super().__init__() self.customer_id.choices = [ (cus.primary_key, cus.name) for cus in Customer.query.all() diff --git a/app/modules/invoices/routes.py b/app/modules/invoices/routes.py index b8a0a68..b6a4fd9 100644 --- a/app/modules/invoices/routes.py +++ b/app/modules/invoices/routes.py @@ -15,7 +15,7 @@ from flask import ( from flask_login import login_required, current_user -from ... import db +# from ... import db from ...models import * from .forms import * @@ -31,8 +31,6 @@ def view(): page = request.args.get('page', 1, type=int) invoices = Invoice.query.order_by(Invoice.primary_key.desc()).paginate(page=page, per_page=5) module = "invoices" - flash(f"Successfully accessed module {module}.", "info") - flash(f"Still fighting against styling in {module}.", "error") return render_template( f"modules/{module}.html", modules=modules, -- cgit v1.2.3