diff options
Diffstat (limited to 'app/modules/products')
-rw-r--r-- | app/modules/products/forms.py | 23 | ||||
-rw-r--r-- | app/modules/products/routes.py | 26 |
2 files changed, 49 insertions, 0 deletions
diff --git a/app/modules/products/forms.py b/app/modules/products/forms.py new file mode 100644 index 0000000..f00441f --- /dev/null +++ b/app/modules/products/forms.py @@ -0,0 +1,23 @@ +from flask_wtf import FlaskForm +from wtforms import ( + SubmitField, + SelectField, + HiddenField, + StringField, + PasswordField, + IntegerField, + FloatField, + BooleanField, + DateTimeField, +) +from wtforms.validators import InputRequired, Length, NumberRange + + +class AddProduct(FlaskForm): + name = StringField("Product name", validators=[InputRequired()]) + code_accounting = StringField("Accounting code", default=0) + unit_weight = FloatField("Unit weight", default=0) + price_net = FloatField("Price (net)", default=0) + price_gross = FloatField("Price (gross)", default=0) + tax_rate = FloatField("Tax rate", default=0) + submit = SubmitField("Add/Update Product") diff --git a/app/modules/products/routes.py b/app/modules/products/routes.py new file mode 100644 index 0000000..735fef9 --- /dev/null +++ b/app/modules/products/routes.py @@ -0,0 +1,26 @@ +# -*- mode: python; -*- + + +from flask import Blueprint, render_template, request, redirect, flash +from flask_login import login_required + +from ... import db +from ...models import Module, Product +from .forms import * + +products = Blueprint("products", __name__) + + +@products.route("/modules/products") +@login_required +def list(): + modules = Module.query.all() + prods = Product.query.order_by(Product.primary_key.desc()) + module = "products" + 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, + products=prods, + ) |