summaryrefslogtreecommitdiff
path: root/app/main.py
blob: 0f4b80008316124a27e09b89b60fbf3950628ec9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# -*- mode: python; -*-

"""
routes.py module
----------------

This Python module contains the logic supporting:
1. Navigating between website pages
2. Interpreting user requests to the server
3. Dispatching requested content back to the user

Python dependencies:
- flask: provides web application features
- forms: provides secure user form submission
- sqlalchemy: provides communication with database on server.

Personal imports:
These are used to avoid cluttering this file with
placeholder data for posts' content.
"""


from flask import (
    Blueprint,
    render_template,
    send_file,
    request,
    redirect,
    flash,
    url_for,
    jsonify,
    abort,
)
from flask_login import login_required, current_user


# from datetime import datetime
# import inspect

from . import db

main = Blueprint("main", __name__)

from .models import Module, User

modules = [
    "auth",
    "customers",
    "ferti",
    "invoices",
    "orders",
    "products",
]


@main.route("/")
@main.route("/index")
def home():
    """This is our project home page."""
    modules = Module.query.all()
    return render_template(
        "home.html", user=current_user, project="fapg", modules=modules
    )


@main.route("/download-database")
def download_database():
    return send_file("test.db")


@main.route("/modules")
def all_modules():
    # If user is unlogged, should present promotional material for
    # available modules.
    return render_template("modules-promo.html", modules=modules)
Copyright 2019--2024 Marius PETER