🎉 it runs

This commit is contained in:
NikolajDanger
2022-05-24 14:12:54 +02:00
parent fbefb00707
commit bec0ae3797
16 changed files with 743 additions and 143 deletions

53
aula/Login/routes.py Normal file
View File

@ -0,0 +1,53 @@
from flask import render_template, Blueprint, redirect, url_for, flash, request
from flask_login import current_user, login_user
from aula import bcrypt
from aula.forms import UserLoginForm
from aula.models import select_users
Login = Blueprint('Login', __name__)
posts = [{}]
@Login.route("/")
@Login.route("/home")
def home():
return render_template('home.html', posts=posts)
@Login.route("/about")
def about():
return render_template('about.html', title='About')
@Login.route("/login", methods=['GET', 'POST'])
def login():
if current_user.is_authenticated:
return redirect(url_for('Login.home'))
form = UserLoginForm()
# Først bekræft, at inputtet fra formen er gyldigt... (f.eks. ikke tomt)
if form.validate_on_submit():
user = select_users(form.id.data)
# Derefter tjek om hashet af adgangskoden passer med det fra databasen...
if user != None and bcrypt.check_password_hash(user[2], form.password.data):
login_user(user, remember=form.remember.data)
flash('Login successful.','success')
next_page = request.args.get('next')
return redirect(next_page) if next_page else redirect(url_for('Login.home'))
else:
flash('Login Unsuccessful. Please check identifier and password', 'danger')
return render_template('login.html', title='Login', form=form)
# @Login.route("/logout")
# def logout():
# logout_user()
# return redirect(url_for('Login.home'))
# @Login.route("/account")
# @login_required
# def account():
# return render_template('account.html', title='Account')

26
aula/__init__.py Normal file
View File

@ -0,0 +1,26 @@
from flask import Flask
import psycopg2
from flask_bcrypt import Bcrypt
from flask_login import LoginManager
app = Flask(__name__)
app.config['SECRET_KEY'] = 'fc089b9218301ad987914c53481bff04'
# set your own database
db = "dbname='aula' user='postgres' host='127.0.0.1' password = 'UIS'"
conn = psycopg2.connect(db)
bcrypt = Bcrypt(app)
login_manager = LoginManager(app)
login_manager.login_view = 'login'
login_manager.login_message_category = 'info'
from aula.Login.routes import Login
# from bank.Customer.routes import Customer
# from bank.Employee.routes import Employee
# from bank.Pax.routes import Pax
app.register_blueprint(Login)
# app.register_blueprint(Customer)
# app.register_blueprint(Employee)
# app.register_blueprint(Pax)
#from bank import routes

17
aula/forms.py Normal file
View File

@ -0,0 +1,17 @@
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, SubmitField, BooleanField, IntegerField, SelectField
from wtforms.validators import DataRequired, Length
class AddUserForm(FlaskForm):
username = StringField('Username',
validators=[DataRequired(), Length(min=2, max=20)])
user_id = IntegerField('user_id',
validators=[DataRequired()])
password = PasswordField('Password', validators=[DataRequired()])
submit = SubmitField('Add')
class UserLoginForm(FlaskForm):
user_id = IntegerField('user_id', validators=[DataRequired()])
password = PasswordField('Password', validators=[DataRequired()])
remember = BooleanField('Remember Me')
submit = SubmitField('Login')

View File

@ -1,6 +1,5 @@
# write all your SQL queries in this file.
from datetime import datetime
from bank import conn, login_manager
from aula import conn, login_manager
from flask_login import UserMixin
from psycopg2 import sql
@ -8,26 +7,17 @@ from psycopg2 import sql
def load_user(user_id):
cur = conn.cursor()
schema = 'customers'
id = 'cpr_number'
if str(user_id).startswith('60'):
schema = 'employees'
id = 'id'
schema = 'users'
_id = 'user_id'
user_sql = sql.SQL("""
SELECT * FROM {}
WHERE {} = %s
""").format(sql.Identifier(schema), sql.Identifier(id))
""").format(sql.Identifier(schema), sql.Identifier(_id))
cur.execute(user_sql, (int(user_id),))
if cur.rowcount > 0:
# return-if svarer til nedenstående:
# if schema == 'employees':
# return Employees(cur.fetchone())
# else:
# return Customers(cur.fetchone())
return Employees(cur.fetchone()) if schema == 'employees' else Customers(cur.fetchone())
User(cur.fetchone())
else:
return None
@ -122,143 +112,24 @@ class Transfers(tuple):
self.amount = user_data[1]
self.transfer_date = user_data[2]
def insert_Customers(name, CPR_number, password):
def insert_users(user_id, first_name, last_name, password, email, adresse, role):
cur = conn.cursor()
sql = """
INSERT INTO Customers(name, CPR_number, password)
VALUES (%s, %s, %s)
INSERT INTO Customers(user_id, first_name, last_name, password, email, adresse, role)
VALUES (%s, %s, %s, %s, %s, %s, %s)
"""
cur.execute(sql, (name, CPR_number, password))
cur.execute(sql, (user_id, first_name, last_name, password, email, adresse, role))
# Husk commit() for INSERT og UPDATE, men ikke til SELECT!
conn.commit()
cur.close()
def insert_Employees(id, name, password):
def select_users(user_id):
cur = conn.cursor()
sql = """
INSERT INTO Employees(id, name, password)
VALUES (%s, %s, %s)
SELECT * FROM users
WHERE user_id = %s
"""
cur.execute(sql, (id, name, password))
# Husk commit() for INSERT og UPDATE, men ikke til SELECT!
conn.commit()
cur.close()
def select_Customers(CPR_number):
cur = conn.cursor()
sql = """
SELECT * FROM Customers
WHERE CPR_number = %s
"""
cur.execute(sql, (CPR_number,))
cur.execute(sql, (user_id,))
user = Customers(cur.fetchone()) if cur.rowcount > 0 else None;
cur.close()
return user
def select_Employees(id):
cur = conn.cursor()
sql = """
SELECT * FROM Employees
WHERE id = %s
"""
cur.execute(sql, (id,))
user = Employees(cur.fetchone()) if cur.rowcount > 0 else None;
cur.close()
return user
def select_all_Employees():
cur = conn.cursor()
sql = """
SELECT * FROM Employees
"""
cur.execute(sql)
tuple_resultset = cur.fetchall()
cur.close()
return tuple_resultset
def update_CheckingAccount(amount, CPR_number):
cur = conn.cursor()
sql = """
UPDATE CheckingAccount
SET amount = %s
WHERE CPR_number = %s
"""
cur.execute(sql, (amount, CPR_number))
# Husk commit() for INSERT og UPDATE, men ikke til SELECT!
conn.commit()
cur.close()
def transfer_account(date, amount, from_account, to_account):
cur = conn.cursor()
sql = """
INSERT INTO Transfers(transfer_date, amount, from_account, to_account)
VALUES (%s, %s, %s, %s)
"""
cur.execute(sql, (date, amount, from_account, to_account))
# Husk commit() for INSERT og UPDATE, men ikke til SELECT!
conn.commit()
cur.close()
def select_emp_cus_accounts(emp_cpr_number):
cur = conn.cursor()
sql = """
SELECT
e.name employee
, c.name customer
, cpr_number
, account_number
FROM manages m
NATURAL JOIN accounts
NATURAL JOIN customers c
JOIN employees e ON m.emp_cpr_number = e.id
WHERE emp_cpr_number = %s
;
"""
cur.execute(sql, (emp_cpr_number,))
tuple_resultset = cur.fetchall()
cur.close()
return tuple_resultset
def select_investments(emp_cpr_number):
cur = conn.cursor()
sql = """
SELECT i.account_number, a.cpr_number, a.created_date
FROM investmentaccounts i
JOIN accounts a ON i.account_number = a.account_number
JOIN manages m ON m.account_number = a.account_number
JOIN employees e ON e.id = m.emp_cpr_number
WHERE e.id = %s
"""
cur.execute(sql, (emp_cpr_number,))
tuple_resultset = cur.fetchall()
cur.close()
return tuple_resultset
def select_investments_with_certificates(emp_cpr_number):
cur = conn.cursor()
sql = """
SELECT i.account_number, a.cpr_number, a.created_date
, cd.cd_number, start_date, maturity_date, rate, amount
FROM investmentaccounts i
JOIN accounts a ON i.account_number = a.account_number
JOIN certificates_of_deposit cd ON i.account_number = cd.account_number
JOIN manages m ON m.account_number = a.account_number
JOIN employees e ON e.id = m.emp_cpr_number
WHERE e.id = %s
"""
cur.execute(sql, (emp_cpr_number,))
tuple_resultset = cur.fetchall()
cur.close()
return tuple_resultset
def select_investments_certificates_sum(emp_cpr_number):
cur = conn.cursor()
sql = """
SELECT account_number, cpr_number, created_date, sum
FROM vw_cd_sum
WHERE emp_cpr_number = %s
"""
cur.execute(sql, (emp_cpr_number,))
tuple_resultset = cur.fetchall()
cur.close()
return tuple_resultset

84
aula/static/main.css Normal file
View File

@ -0,0 +1,84 @@
body {
background: #fafafa;
color: #333333;
margin-top: 5rem;
}
h1, h2, h3, h4, h5, h6 {
color: #444444;
}
.bg-steel {
background-color: #5f788a;
}
.site-header .navbar-nav .nav-link {
color: #cbd5db;
}
.site-header li > .nav-item.nav-link {
color: #495057;
}
.site-header .navbar-nav .nav-link:hover {
color: #ffffff;
}
.site-header .navbar-nav .nav-link.active {
font-weight: 500;
}
.content-section {
background: #ffffff;
padding: 10px 20px;
border: 1px solid #dddddd;
border-radius: 3px;
margin-bottom: 20px;
}
.article-title {
color: #444444;
}
a.article-title:hover {
color: #428bca;
text-decoration: none;
}
.article-content {
white-space: pre-line;
}
.article-img {
height: 65px;
width: 65px;
margin-right: 16px;
}
.article-metadata {
padding-bottom: 1px;
margin-bottom: 4px;
border-bottom: 1px solid #e3e3e3
}
.article-metadata a:hover {
color: #333;
text-decoration: none;
}
.article-svg {
width: 25px;
height: 25px;
vertical-align: middle;
}
.account-img {
height: 125px;
width: 125px;
margin-right: 20px;
margin-bottom: 16px;
}
.account-heading {
font-size: 2.5rem;
}

30
aula/templates/about.html Normal file
View File

@ -0,0 +1,30 @@
{% extends "layout.html" %}
{% block content %}
<h1>About Page</h1>
<p>Dette er UIS-prototypen bragt til dig af UIS-holdet 2021/2022:</p>
<ul>
<li style="color: gray;">Ziming Lou</li>
<li style="color: gray;">Lasse Pedersen</li>
<li style="color: gray;">Jan Rolandsen</li>
<li style="color: gray;">Marco Ugo Gambetta</li>
<li>Hubert Dariusz Zajac</li>
<li>Anders Lassen</li>
<li>Finn Kensing</li>
<li>Marcos Vas Salles</li>
<li>Pax Ravn</li>
<li>Nadja Petersen</li>
<li>Rikke Vesterbæk Nielsen</li>
</ul>
<p>I kan registrere nye kundekonti, men medarbejderkonti skal indtastes ved at foretage jeres ændringer i DML-scriptet schema_ins.sql. For at logge ind har vi oprettet nogle testkonti. Kunde-login kan tilgås ved hjælp af et kunde-cpr i intervallerne 5001 til 5007 med adgangskoden "UIS" med store bogstaver. Medarbejder-login kan tilgås ved hjælp af medarbejder-id 6001..6007 og samme adgangskode.</p>
<p>For at tilføje flere eksempeldata skal du foretage dine ændringer i DML-scriptet schema_ins.sql.</p>
<p>Prototypen er vertikal. Vi har implementeret nogle funktioner, men projektet er ufuldstændigt. Prototypen giver et udgangspunkt for jeres arbejde.</p>
<p><b>EN:</b></p>
<p>You can register new customer accounts, but employee accounts must be entered by making your changes to the DML-script schema_ins.sql. To log in we have created some test accounts. The customer login can be accesed using a customer cpr in ranges 5001 to 5007 with the password 'UIS' in uppercase. The employee login can be accessed using employee id 6001..6007 and the same password.</p>
<p>To add more sample data make your changes to the DML-script schema_ins.sql.</p>
<p>The prototype is vertical. We have implemented some functions and not completed. The prototype provides a starting point for your work.</p>
<p>AL/PR 20220504</p>
{% endblock content %}

View File

@ -0,0 +1,4 @@
{% extends "layout.html" %}
{% block content %}
<h1>{{ current_user.name }}</h1>
{% endblock content %}

View File

@ -0,0 +1,59 @@
{% extends "layout.html" %}
{% block content %}
<div class="content-section">
<form method="POST" action="">
{{ form.hidden_tag() }}
<fieldset class="form-group">
<legend class="border-bottom mb-4">Add a new customer</legend>
<div class="form-group">
{{ form.username.label(class="form-control-label") }}
{% if form.username.errors %}
{{ form.username(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.username.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.username(class="form-control form-control-lg") }}
{% endif %}
</div>
<div class="form-group">
{{ form.CPR_number.label(class="form-control-label") }}
{% if form.CPR_number.errors %}
{{ form.CPR_number(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.CPR_number.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.CPR_number(class="form-control form-control-lg") }}
{% endif %}
</div>
<div class="form-group">
{{ form.password.label(class="form-control-label") }}
{% if form.password.errors %}
{{ form.password(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.password.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.password(class="form-control form-control-lg") }}
{% endif %}
</div>
</fieldset>
<div class="form-group">
{{ form.submit(class="btn btn-outline-info") }}
</div>
</form>
</div>
<div class="border-top pt-3">
<small class="text-muted">
Already Have An Account? <a class="ml-2" href="{{ url_for('Login.login') }}">Sign In</a>
</small>
</div>
{% endblock content %}

16
aula/templates/home.html Normal file
View File

@ -0,0 +1,16 @@
{% extends "layout.html" %}
{% block content %}
<h1>{{ current_user.name }}</h1>
{% for post in posts %}
<article class="media content-section">
<div class="media-body">
<div class="article-metadata">
<a class="mr-2" href="#">{{ post.author }}</a>
<small class="text-muted">{{ post.date_posted }}</small>
</div>
<h2><a class="article-title" href="#">{{ post.title }}</a></h2>
<p class="article-content">{{ post.content }}</p>
</div>
</article>
{% endfor %}
{% endblock content %}

View File

@ -0,0 +1,79 @@
{% extends "layout_acc.html" %}
{% block content %}
<h1>{{ current_user.name }}</h1>
<div class="content-section">
<p>Investments:</p>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">account_number</th>
<th scope="col">cpr_number</th>
<th scope="col">creation date</th>
</tr>
</thead>
<tbody>
{% for n in inv %}
<tr>
<th scope="row">{{n[0]}}</th>
<td>{{n[1]}}</td>
<td>{{n[2]}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="content-section">
<p>Investment accounts:</p>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">account_number</th>
<th scope="col">cpr_number</th>
<th scope="col">account created</th>
<th scope="col">deposit total (CD)</th>
</tr>
</thead>
<tbody>
{% for n in inv_sums %}
<tr>
<th scope="row">{{n[0]}}</th>
<td>{{n[1]}}</td>
<td>{{n[2]}}</td>
<td>{{n[3]}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="content-section">
<p>Investment certificats of deposit:</p>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">acc</th>
<th scope="col">cd_number</th>
<th scope="col">start_date</th>
<th scope="col">maturity_date</th>
<th scope="col">rate</th>
<th scope="col">amount</th>
</tr>
</thead>
<tbody>
{% for n in inv_cd_list %}
<tr>
<th scope="row">{{n[0]}}</th>
<td>{{n[3]}}</td>
<td>{{n[4]}}</td>
<td>{{n[5]}}</td>
<td>{{n[6]}}</td>
<td>{{n[7]}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock content %}

View File

@ -0,0 +1,98 @@
<!DOCTYPE html>
<html>
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='main.css') }}">
{% if title %}
<title>UIS Prototype - {{ title }}</title>
{% else %}
<title>UIS Prototype</title>
{% endif %}
</head>
<body>
<header class="site-header">
<nav class="navbar navbar-expand-md navbar-dark bg-steel fixed-top">
<div class="container">
<a class="navbar-brand mr-4" href="/">UIS Prototype</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggle" aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarToggle">
<div class="navbar-nav mr-auto">
<a class="nav-item nav-link" href="{{ url_for('Login.home') }}">Home</a>
{% if current_user.is_authenticated %}
<li class="dropdown">
<a href="#" class="nav-item nav-link dropdown-toggle" data-toggle="dropdown">UIS bank<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a class="nav-item nav-link" href="{{ url_for('Login.account') }}">Account</a></li>
<li class="divider"></li>
<li><a class="nav-item nav-link" href="https://www.pgadmin.org">site pgAdmin</a></li>
<li><a class="nav-item nav-link" href="http://127.0.0.1:58653/browser/ ">pgAdmin4</a></li>
</ul>
</li>
{% else %}
{% endif %}
<a class="nav-item nav-link" href="{{ url_for('Login.about') }}">About</a>
</div>
<!-- Navbar Right Side -->
<div class="navbar-nav">
{% if current_user.is_authenticated %}
<a class="nav-item nav-link" href="{{ url_for('Login.account') }}">Account</a>
<a class="nav-item nav-link" href="{{ url_for('Login.logout') }}">Logout</a>
{% else %}
<a class="nav-item nav-link" href="{{ url_for('Login.login') }}">Login</a>
{% endif %}
</div>
</div>
</div>
</nav>
</header>
<main role="main" class="container">
<div class="row">
<div class="col-md-8">
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="alert alert-{{ category }}">
{{ message }}
</div>
{% endfor %}
{% endif %}
{% endwith %}
{% block content %}{% endblock %}
</div>
<div class="col-md-4">
<div class="content-section">
<h3>Account</h3>
<ul class="list-group">
{% if current_user.is_authenticated %}
<li class="list-group-item list-group-item-light"><a class="nav-item nav-link" href="{{ url_for('Employee.transfer') }}">Transfer</a></li>
<li class="list-group-item list-group-item-light">Checking Accounts</li>
<li class="list-group-item list-group-item-light">Investment Accounts</li>
<li class="list-group-item list-group-item-light"><a class="nav-item nav-link" href="{{ url_for('Customer.invest') }}">View investment accounts</a></li>
<li class="list-group-item list-group-item-light">etc</li>
{% else %}
<li class="list-group-item list-group-item-light">etc</li>
{% endif %}
</ul>
</p>
</div>
</div>
</div>
</main>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>

View File

@ -0,0 +1,100 @@
<!DOCTYPE html>
<html>
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='main.css') }}">
{% if title %}
<title>UIS Prototype - {{ title }}</title>
{% else %}
<title>UIS Prototype</title>
{% endif %}
</head>
<body>
<header class="site-header">
<nav class="navbar navbar-expand-md navbar-dark bg-steel fixed-top">
<div class="container">
<a class="navbar-brand mr-4" href="/">UIS Prototype</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggle" aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarToggle">
<div class="navbar-nav mr-auto">
<a class="nav-item nav-link" href="{{ url_for('Login.home') }}">Home</a>
{% if current_user.is_authenticated %}
<li class="dropdown">
<a href="#" class="nav-item nav-link dropdown-toggle" data-toggle="dropdown">UIS bank<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a class="nav-item nav-link" href="{{ url_for('Login.account') }}">Account</a></li>
<li><a class="nav-item nav-link" href="{{ url_for('Employee.transfer') }}">Transfer</a></li>
<li class="divider"></li>
<li><a class="nav-item nav-link" href="{{ url_for('Customer.invest') }}">Investments</a></li>
<li class="divider"></li>
<li><a class="nav-item nav-link" href="https://www.pgadmin.org">site pgAdmin</a></li>
<li><a class="nav-item nav-link" href="http://127.0.0.1:58653/browser/ ">pgAdmin4</a></li>
</ul>
</li>
{% else %}
{% endif %}
<a class="nav-item nav-link" href="{{ url_for('Login.about') }}">About</a>
</div>
<!-- Navbar Right Side -->
<div class="navbar-nav">
{% if current_user.is_authenticated %}
<a class="nav-item nav-link" href="{{ url_for('Login.account') }}">Account</a>
<a class="nav-item nav-link" href="{{ url_for('Employee.transfer') }}">Transfer</a>
<a class="nav-item nav-link" href="{{ url_for('Customer.invest') }}">Investments</a>
<a class="nav-item nav-link" href="{{ url_for('Login.logout') }}">Logout</a>
{% else %}
<a class="nav-item nav-link" href="{{ url_for('Login.login') }}">Login</a>
<a class="nav-item nav-link" href="{{ url_for('Employee.addcustomer') }}">Register</a>
{% endif %}
</div>
</div>
</div>
</nav>
</header>
<main role="main" class="container">
<div class="row">
<div class="col-md-8">
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="alert alert-{{ category }}">
{{ message }}
</div>
{% endfor %}
{% endif %}
{% endwith %}
{% block content %}{% endblock %}
</div>
<div class="col-md-4">
<div class="content-section">
<h3>Account</h3>
<ul class="list-group">
<li class="list-group-item list-group-item-light"><a class="nav-item nav-link" href="{{ url_for('Employee.transfer') }}">Transfer</a></li>
<li class="list-group-item list-group-item-light">Checking Accounts</li>
<li class="list-group-item list-group-item-light">Investment Accounts</li>
<li class="list-group-item list-group-item-light"><a class="nav-item nav-link" href="{{ url_for('Customer.invest') }}">View investment accounts</a></li>
<li class="list-group-item list-group-item-light">etc</li>
</ul>
</p>
</div>
</div>
</div>
</main>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>

47
aula/templates/login.html Normal file
View File

@ -0,0 +1,47 @@
{% extends "layout.html" %}
{% block content %}
<div class="content-section">
<form method="POST" action="">
{{ form.hidden_tag() }}
<fieldset class="form-group">
<legend class="border-bottom mb-4">Log In</legend>
<div class="form-group">
{{ form.user_id.label(class="form-control-label") }}
{% if form.user_id.errors %}
{{ form.user_id(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.user_id.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.user_id(class="form-control form-control-lg") }}
{% endif %}
</div>
<div class="form-group">
{{ form.password.label(class="form-control-label") }}
{% if form.password.errors %}
{{ form.password(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.password.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.password(class="form-control form-control-lg") }}
{% endif %}
</div>
<div class="form-check">
{{ form.remember(class="form-check-input") }}
{{ form.remember.label(class="form-check-label") }}
</div>
</fieldset>
<div class="form-group">
{{ form.submit(class="btn btn-outline-info") }}
</div>
<small class="text-muted">
<a href="#">Forgot Password?</a>
</small>
</form>
</div>
{% endblock content %}

70
aula/templates/test.html Normal file
View File

@ -0,0 +1,70 @@
{% extends "layout.html" %}
{% block content %}
<h1>Test Page</h1>
<p>Dette er en testside. Hej med dig. <b>fed tekst,</b> <i>kursiv tekst</i> </p>
<p><b>fed tekst, <i>fed og kursiv tekst</i></b></p>
<p>Liste af ansatte:</p>
<ul>
{% for e in emp %}
<li>{{ e[1] }}</li>
{% endfor %}
</ul>
<form method="POST" action="">
{{ form.hidden_tag() }}
<fieldset class="form-group">
<legend class="border-bottom mb-4">Add a new employee</legend>
<!-- Id-felt -->
<div class="form-group">
{{ form.id.label(class="form-control-label") }}
{% if form.id.errors %}
{{ form.id(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.id.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.id(class="form-control form-control-lg") }}
{% endif %}
</div>
<!-- Username-felt -->
<div class="form-group">
{{ form.username.label(class="form-control-label") }}
{% if form.username.errors %}
{{ form.username(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.username.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.username(class="form-control form-control-lg") }}
{% endif %}
</div>
<!-- Password-felt -->
<div class="form-group">
{{ form.password.label(class="form-control-label") }}
{% if form.password.errors %}
{{ form.password(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.password.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.password(class="form-control form-control-lg") }}
{% endif %}
</div>
</fieldset>
<!-- Submit-knap -->
<div class="form-group">
{{ form.submit(class="btn btn-outline-info") }}
</div>
</form>
{% endblock content %}

View File

@ -0,0 +1,46 @@
{% extends "layout.html" %}
{% block content %}
<div class="content-section">
<form method="POST" action="">
{{ form.hidden_tag() }}
<div class="form-group">
{{ form.sourceAccount.label(class="form-control-label") }}
{{ form.sourceAccount(class="form-control")}}
</div>
<fieldset class="form-group">
<div class="form-group">
{{ form.amount.label(class="form-control-label") }}
{% if form.amount.errors %}
{{ form.amount(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.password.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.amount(class="form-control form-control-lg") }}
{% endif %}
</div>
</fieldset>
<div class="form-group">
{{ form.targetAccount.label(class="form-control-label") }}
{{ form.targetAccount(class="form-control") }}
</div>
<div class="form-group">
{{ form.submit(class="btn btn-outline-info") }}
</div>
</form>
</div>
<div class="content-section">
<p>Dropdown customer account tuples:</p>
<ul class="list-group">
{% for n in drop_cus_acc %}
<li class="list-group-item list-group-item-light">{{n}}}</li>
{% endfor %}
</ul>
<br>
<p>Same list with a filter: {{ drop_cus_acc|join(', ') }}</p>
</div>
{% endblock content %}

2
run.py
View File

@ -1,3 +1,3 @@
from bank import app
from aula import app
if __name__ == '__main__':
app.run(debug=True)