Compare commits
2 Commits
31036f5d50
...
d5abea0c76
Author | SHA1 | Date | |
---|---|---|---|
d5abea0c76 | |||
2dd340e593 |
26
bank/Pax/routes.py
Normal file
26
bank/Pax/routes.py
Normal file
@ -0,0 +1,26 @@
|
||||
from flask import render_template, url_for, flash, redirect, request, Blueprint
|
||||
from bank import app, conn, bcrypt
|
||||
from bank.forms import AddEmployeeForm
|
||||
from flask_login import login_user, current_user, logout_user, login_required
|
||||
from bank.models import select_all_Employees, insert_Employees
|
||||
|
||||
Pax = Blueprint('Pax', __name__)
|
||||
|
||||
posts = [{}]
|
||||
|
||||
|
||||
@Pax.route("/test", methods=['GET', 'POST'])
|
||||
def test():
|
||||
form = AddEmployeeForm()
|
||||
# Nedenstånde kode køres kun ved POST-forespørgsler:
|
||||
if form.validate_on_submit():
|
||||
hashed_password = bcrypt.generate_password_hash(form.password.data).decode('utf-8')
|
||||
id=form.id.data
|
||||
name=form.username.data
|
||||
password=hashed_password
|
||||
insert_Employees(id, name, password)
|
||||
flash('Employee has been created! The employee is now able to log in', 'success')
|
||||
return redirect(url_for('Login.home'))
|
||||
# Og denne køres GET-forespørgsler:
|
||||
employees = select_all_Employees()
|
||||
return render_template('test.html', title='Hej med dig', emp=employees, form=form)
|
@ -17,8 +17,10 @@ login_manager.login_message_category = 'info'
|
||||
from bank.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
|
||||
|
@ -9,6 +9,13 @@ class AddCustomerForm(FlaskForm):
|
||||
password = PasswordField('Password', validators=[DataRequired()])
|
||||
submit = SubmitField('Add')
|
||||
|
||||
class AddEmployeeForm(FlaskForm):
|
||||
id = IntegerField('Id',
|
||||
validators=[DataRequired()])
|
||||
username = StringField('Username',
|
||||
validators=[DataRequired(), Length(min=2, max=20)])
|
||||
password = PasswordField('Password', validators=[DataRequired()])
|
||||
submit = SubmitField('Add')
|
||||
|
||||
class CustomerLoginForm(FlaskForm):
|
||||
id = IntegerField('CPR_number', validators=[DataRequired()])
|
||||
@ -36,4 +43,4 @@ class DepositForm(FlaskForm):
|
||||
submit = SubmitField('Confirm')
|
||||
|
||||
class InvestForm(FlaskForm):
|
||||
submit = SubmitField('Confirm')
|
||||
submit = SubmitField('Confirm')
|
||||
|
@ -83,6 +83,17 @@ def insert_Customers(name, CPR_number, password):
|
||||
conn.commit()
|
||||
cur.close()
|
||||
|
||||
def insert_Employees(id, name, password):
|
||||
cur = conn.cursor()
|
||||
sql = """
|
||||
INSERT INTO Employees(id, name, password)
|
||||
VALUES (%s, %s, %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 = """
|
||||
@ -105,6 +116,16 @@ def select_Employees(id):
|
||||
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 = """
|
||||
|
@ -1,88 +1,84 @@
|
||||
body {
|
||||
background: #fafafa;
|
||||
color: #333333;
|
||||
margin-top: 5rem;
|
||||
background: #fafafa;
|
||||
color: #333333;
|
||||
margin-top: 5rem;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
color: #444444;
|
||||
color: #444444;
|
||||
}
|
||||
|
||||
.bg-steel {
|
||||
background-color: #5f788a;
|
||||
background-color: #5f788a;
|
||||
}
|
||||
|
||||
.site-header .navbar-nav .nav-link {
|
||||
color: #cbd5db;
|
||||
color: #cbd5db;
|
||||
}
|
||||
|
||||
.site-header li > .nav-item.nav-link {
|
||||
color: #495057;
|
||||
}
|
||||
|
||||
.site-header .navbar-nav .nav-link:hover {
|
||||
color: #ffffff;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.site-header .navbar-nav .nav-link.active {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.site-header .dropdown-menu > li > .nav-item.nav-link {
|
||||
color: #495057;
|
||||
}
|
||||
|
||||
.site-header .dropdown-menu > li > .nav-item.nav-link:hover {
|
||||
color: #798592;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.content-section {
|
||||
background: #ffffff;
|
||||
padding: 10px 20px;
|
||||
border: 1px solid #dddddd;
|
||||
border-radius: 3px;
|
||||
margin-bottom: 20px;
|
||||
background: #ffffff;
|
||||
padding: 10px 20px;
|
||||
border: 1px solid #dddddd;
|
||||
border-radius: 3px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.article-title {
|
||||
color: #444444;
|
||||
color: #444444;
|
||||
}
|
||||
|
||||
a.article-title:hover {
|
||||
color: #428bca;
|
||||
text-decoration: none;
|
||||
color: #428bca;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.article-content {
|
||||
white-space: pre-line;
|
||||
white-space: pre-line;
|
||||
}
|
||||
|
||||
.article-img {
|
||||
height: 65px;
|
||||
width: 65px;
|
||||
margin-right: 16px;
|
||||
height: 65px;
|
||||
width: 65px;
|
||||
margin-right: 16px;
|
||||
}
|
||||
|
||||
.article-metadata {
|
||||
padding-bottom: 1px;
|
||||
margin-bottom: 4px;
|
||||
border-bottom: 1px solid #e3e3e3
|
||||
padding-bottom: 1px;
|
||||
margin-bottom: 4px;
|
||||
border-bottom: 1px solid #e3e3e3
|
||||
}
|
||||
|
||||
.article-metadata a:hover {
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.article-svg {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
vertical-align: middle;
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.account-img {
|
||||
height: 125px;
|
||||
width: 125px;
|
||||
margin-right: 20px;
|
||||
margin-bottom: 16px;
|
||||
height: 125px;
|
||||
width: 125px;
|
||||
margin-right: 20px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.account-heading {
|
||||
font-size: 2.5rem;
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
|
@ -47,6 +47,7 @@
|
||||
<!-- Navbar Right Side -->
|
||||
<div class="navbar-nav">
|
||||
{% if current_user.is_authenticated %}
|
||||
<a class="nav-item nav-link" href="{{ url_for('Pax.test') }}">Test</a>
|
||||
<a class="nav-item nav-link" href="{{ url_for('Login.account') }}">Account</a>
|
||||
<a class="nav-item nav-link" href="{{ url_for('Employee.addcustomer') }}">Add customer</a>
|
||||
<a class="nav-item nav-link" href="{{ url_for('Employee.transfer') }}">Transfer</a>
|
||||
|
70
bank/templates/test.html
Normal file
70
bank/templates/test.html
Normal 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 %}
|
||||
|
Reference in New Issue
Block a user