new start

This commit is contained in:
Tim Gröger 2019-04-11 23:56:55 +02:00
parent 84c5f796d6
commit 5c5799206f
22 changed files with 195 additions and 1371 deletions

View File

@ -1,17 +1,18 @@
from flask import Flask, g from flask import Flask
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
from flask_bcrypt import Bcrypt from flask_bcrypt import Bcrypt
from flask_login import LoginManager from .controller.accesTokenController import AccesTokenController
# from flask_login import LoginManager
app = Flask(__name__) app = Flask(__name__)
app.config['SECRET_KEY'] = '0a657b97ef546da90b2db91862ad4e29' # app.config['SECRET_KEY'] = '0a657b97ef546da90b2db91862ad4e29'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///site.db' app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///site.db'
db = SQLAlchemy(app) db = SQLAlchemy(app)
bcrypt = Bcrypt(app) bcrypt = Bcrypt(app)
login_manager = LoginManager(app) accesTokenController = AccesTokenController()
login_manager.login_view = 'login' # login_manager = LoginManager(app)
login_manager.login_message_category = 'info' # login_manager.login_view = 'login'
# login_manager.login_message_category = 'info'
from geruecht import routes from geruecht import routes

View File

View File

@ -0,0 +1,25 @@
from geruecht.model.accessToken import AccessToken
from datetime import datetime
import hashlib
class AccesTokenController():
tokenList = None
def __init__(self):
self.tokenList = []
def findAccesToken(self, token):
for accToken in self.tokenList:
if accToken == token:
return accToken
return None
def createAccesToken(self, user):
time = datetime.ctime(datetime.now())
token = hashlib.md5((time + user.password).encode('utf-8')).hexdigest()
self.tokenList.append(AccessToken(user, token))
print(self.tokenList)
return token
def isSameGroup(self, accToken, group):
return True if accToken.user.group == group else False

View File

@ -1,23 +0,0 @@
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, PasswordField;
from wtforms.validators import DataRequired, Length, ValidationError
from geruecht.model import User
class RegistrationForm(FlaskForm):
username = StringField('Name', validators=[DataRequired(), Length(min=2, max=20)])
submit = SubmitField('Create')
def validate_username(self, username):
user = User.query.filter_by(username=username.data).first()
if user:
raise ValidationError('Bist du behindert!? Der Name ist vergeben!!')
class FinanzerLogin(FlaskForm):
username = StringField('Name', validators=[DataRequired(), Length(min=2, max=20)])
password = PasswordField('Password', validators=[DataRequired()])
submit = SubmitField('Login')

View File

@ -1,341 +0,0 @@
from geruecht import db, login_manager
from threading import Timer
from flask_login import UserMixin
from datetime import date
@login_manager.user_loader
def load_finanzer(finanzer_id):
return Finanzer.query.get(int(finanzer_id))
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(20), unique=True, nullable=False)
sum = db.Column(db.Float, nullable=False, default=0.0)
jan = db.Column(db.Float, nullable=False, default=0)
jan_sub = db.Column(db.Float, nullable=False, default=0)
jan_year = db.Column(db.Integer, nullable=False, default=date.today().year)
feb = db.Column(db.Float, nullable=False, default=0)
feb_sub = db.Column(db.Float, nullable=False, default=0)
feb_year = db.Column(db.Integer, nullable=False, default=date.today().year)
maer = db.Column(db.Float, nullable=False, default=0)
maer_sub = db.Column(db.Float, nullable=False, default=0)
maer_year = db.Column(db.Integer, nullable=False, default=date.today().year)
apr = db.Column(db.Float, nullable=False, default=0)
apr_sub = db.Column(db.Float, nullable=False, default=0)
apr_year = db.Column(db.Integer, nullable=False, default=date.today().year)
mai = db.Column(db.Float, nullable=False, default=0)
mai_sub = db.Column(db.Float, nullable=False, default=0)
mai_year = db.Column(db.Integer, nullable=False, default=date.today().year)
jun = db.Column(db.Float, nullable=False, default=0)
jun_sub = db.Column(db.Float, nullable=False, default=0)
jun_year = db.Column(db.Integer, nullable=False, default=date.today().year)
jul = db.Column(db.Float, nullable=False, default=0)
jul_sub = db.Column(db.Float, nullable=False, default=0)
jul_year = db.Column(db.Integer, nullable=False, default=date.today().year)
aug = db.Column(db.Float, nullable=False, default=0)
aug_sub = db.Column(db.Float, nullable=False, default=0)
aug_year = db.Column(db.Integer, nullable=False, default=date.today().year)
sep = db.Column(db.Float, nullable=False, default=0)
sep_sub = db.Column(db.Float, nullable=False, default=0)
sep_year = db.Column(db.Integer, nullable=False, default=date.today().year)
okt = db.Column(db.Float, nullable=False, default=0)
okt_sub = db.Column(db.Float, nullable=False, default=0)
okt_year = db.Column(db.Integer, nullable=False, default=date.today().year)
nov = db.Column(db.Float, nullable=False, default=0)
nov_sub = db.Column(db.Float, nullable=False, default=0)
nov_year = db.Column(db.Integer, nullable=False, default=date.today().year)
dez = db.Column(db.Float, nullable=False, default=0)
dez_sub = db.Column(db.Float, nullable=False, default=0)
dez_year = db.Column(db.Integer, nullable=False, default=date.today().year)
def getsum(self):
jan = self.jan - self.jan_sub
feb = self.feb - self.feb_sub
maer = self.maer - self.maer_sub
apr = self.apr - self.apr_sub
mai = self.mai - self.mai_sub
jun = self.jun - self.jun_sub
jul = self.jul - self.jul_sub
aug = self.aug - self.aug_sub
sep = self.sep - self.sep_sub
okt = self.okt - self.okt_sub
nov = self.nov - self.nov_sub
dez = self.dez - self.dez_sub
result = jan + feb + maer + apr + mai + jun + jul + aug + sep + okt + nov + dez
return result
def add_sub(self, value):
year = date.today().year
month = date.today().month
if month == 1:
if year == self.jan_year:
self.jan_sub += value
else:
self.jan = 0
self.jan_sub = value
self.jan_year = year;
elif month == 2:
if year == self.feb_year:
self.feb_sub += value
else:
self.feb = 0
self.feb_sub = value
self.feb_year = year
elif month == 3:
if year == self.maer_year:
self.maer_sub += value
else:
self.maer = 0
self.maer_sub = value
self.maer_year = year
elif month == 4:
if year == self.apr_year:
self.apr_sub += value
else:
self.apr = 0
self.apr_sub = value
self.apr_year = year
elif month == 5:
if year == self.mai_year:
self.mai_sub += value
else:
self.mai = 0
self.mai_sub = value
self.mai_year = year
elif month == 6:
if year == self.jun_year:
self.jun_sub += value
else:
self.jun = 0
self.jun_sub = value
self.jun_year = year
elif month == 7:
if year == self.jul_year:
self.jul_sub += value
else:
self.jul = 0
self.jul_sub = value
self.jul_year = year
elif month == 8:
if year == self.aug_year:
self.aug_sub += value
else:
self.aug = 0
self.aug_sub = value
self.aug_year = year
elif month == 9:
if year == self.sep_year:
self.sep_sub += value
else:
self.sep = 0
self.sep_sub = value
self.sep_year = year
elif month == 10:
if year == self.okt_year:
self.okt_sub += value
else:
self.okt = 0
self.okt_sub = value
self.okt_year = year
elif month == 11:
if year == self.nov_year:
self.nov_sub += value
else:
self.nov = 0
self.nov_sub = value
self.nov_year = year
elif month == 12:
if year == self.dez_year:
self.dez_sub += value
else:
self.dez = 0
self.dez_sub = value
self.dez_year = year
else:
raise IndexError('Mehr monate gibt es nicht')
def add(self, value):
year = date.today().year
month = date.today().month
if month == 1 :
if year == self.jan_year:
self.jan += value
else:
self.jan = value
self.jan_sub = 0
self.jan_year = year
elif month == 2:
if year == self.feb_year:
self.feb += value
else:
self.feb = value
self.feb_sub = 0
self.feb_year = year
elif month == 3:
if year == self.maer_year:
self.maer += value
else:
self.maer = value
self.mear_sub = 0
self.mear_year = year
elif month == 4:
if year == self.apr_year:
self.apr += value
else:
self.apr = value
self.apr_sub = 0
self.apr_year = year
elif month == 5:
if year == self.mai_year:
self.mai += value
else:
self.mai = value
self.mai_sub = 0
self.mai_year = year
elif month == 6:
if year == self.jun_year:
self.jun += value
else:
self.jun = value
self.jun_sub = 0
self.jun_year = year
elif month == 7:
if year == self.jul_year:
self.jul += value
else:
self.jul = value
self.jul_sub = 0
self.jul_year = year
elif month == 8:
if year == self.aug_year:
self.aug += value
else:
self.aug = value
self.aug_sub = 0
self.aug_year = year
elif month == 9:
if year == self.sep_year:
self.sep += value
else:
self.sep = value
self.sep_sub = 0
self.sep_year = year
elif month == 10:
if year == self.okt_year:
self.okt += value
else:
self.okt = value
self.okt_sub = 0
self.okt_year = year
elif month == 11:
if year == self.nov_year:
self.nov += value
else:
self.nov = value
self.nov_sub = 0
self.nov_year = year
elif month == 12:
if year == self.dez_year:
self.dez += value
else:
self.dez = value
self.dez_sub = 0
self.dez_year = year
else:
raise IndexError('Mehr monate gibt es nicht')
def storner(self, value, month):
if month == 1:
self.jan = self.jan - value
elif month == 2:
self.feb = self.feb - value
elif month == 3:
self.maer = self.maer - value
elif month == 4:
self.apr = self.apr - value
elif month == 5:
self.mai = self.mai - value
elif month == 6:
self.jun = self.jun - value
elif month == 7:
self.jul = self.jul - value
elif month == 8:
self.aug = self.aug - value
elif month == 9:
self.sep = self.sep - value
elif month == 10:
self.okt = self.okt - value
elif month == 11:
self.nov = self.nov - value
elif month == 12:
self.dez = self.dez - value
else:
raise IndexError('Mehr monate gibt es nicht')
def __repr__(self):
return f"User('{self.username}', '{self.sum}')"
class Finanzer(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(20), unique=True, nullable=False)
password = db.Column(db.String(60), nullable=False)
def __repr__(self):
return f"Finanzer('{self.username}')"
class History:
history = []
user = None
def __init__(self, history, user, value):
self.history = history
self.history.append(self)
self.user = user
self.month = date.today().month
self.value = value
self.timer = Timer(60, self.kill)
self.timer.start()
def exec(self):
self.timer.cancel()
User.query.filter_by(username=self.user.username).first().storner(self.value, self.month)
self.kill()
def kill(self):
print("{} deledet from history".format(self.user))
self.history.remove(self)
print(self.history)
'''
def __repr__(self):
print(f'self:{self}, history:{self.history}, user:{self.user}, value:{self.value}')
def __str__(self):
print(f'self:{self}, history:{self.history}, user:{self.user}, value:{self.value}')
'''

View File

View File

@ -0,0 +1,27 @@
from datetime import datetime
class AccessToken():
timestamp = None
user = None
token = None
def __init__(self, user, token, timestamp=datetime.now()):
self.user = user
self.timestamp = timestamp
self.token = token
def updateTimestamp(self):
self.timestamp = datetime.now()
def __eq__(self, token):
return True if self.token == token else False
def __sub__(self, other):
return other - self.timestamp
def __str__(self):
return f"AccessToken({self.user}, {self.token}, {self.timestamp}"
def __repr__(self):
return f"AccessToken({self.user}, {self.token}, {self.timestamp}"

View File

@ -0,0 +1,45 @@
from geruecht import db
from datetime import datetime
class CreditList(db.Model):
id = db.Column(db.Integer, primary_key=True)
jan_guthaben = db.Column(db.Integer, nullable=False, default=0)
jan_schulden = db.Column(db.Integer, nullable=False, default=0)
feb_guthaben = db.Column(db.Integer, nullable=False, default=0)
feb_schulden = db.Column(db.Integer, nullable=False, default=0)
maer_guthaben = db.Column(db.Integer, nullable=False, default=0)
maer_schulden = db.Column(db.Integer, nullable=False, default=0)
apr_guthaben = db.Column(db.Integer, nullable=False, default=0)
apr_schulden = db.Column(db.Integer, nullable=False, default=0)
mai_guthaben = db.Column(db.Integer, nullable=False, default=0)
mai_schulden = db.Column(db.Integer, nullable=False, default=0)
jun_guthaben = db.Column(db.Integer, nullable=False, default=0)
jun_schulden = db.Column(db.Integer, nullable=False, default=0)
jul_guthaben = db.Column(db.Integer, nullable=False, default=0)
jul_schulden = db.Column(db.Integer, nullable=False, default=0)
aug_guthaben = db.Column(db.Integer, nullable=False, default=0)
aug_schulden = db.Column(db.Integer, nullable=False, default=0)
sep_guthaben = db.Column(db.Integer, nullable=False, default=0)
sep_schulden = db.Column(db.Integer, nullable=False, default=0)
okt_guthaben = db.Column(db.Integer, nullable=False, default=0)
okt_schulden = db.Column(db.Integer, nullable=False, default=0)
nov_guthaben = db.Column(db.Integer, nullable=False, default=0)
nov_schulden = db.Column(db.Integer, nullable=False, default=0)
dez_guthaben = db.Column(db.Integer, nullable=False, default=0)
dez_schulden = db.Column(db.Integer, nullable=False, default=0)
last_schulden = db.Column(db.Integer, nullable=False, default=0)
year = db.Column(db.Integer, nullable=False, default=datetime.now().year)

View File

@ -0,0 +1,13 @@
from geruecht import db
class PriceList(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String, nullable=False, unique=True)
price = db.Column(db.Integer, nullable=False)
price_club = db.Column(db.Integer, nullable=False)
price_ext_club = db.Column(db.Integer, nullable=False)
category = db.Column(db.Integer, nullable=False)
upPrice = db.Column(db.Integer)
upPrice_club = db.Column(db.Integer)
upPrice_ext_club = db.Column(db.Integer)

24
geruecht/model/user.py Normal file
View File

@ -0,0 +1,24 @@
from geruecht import db
from geruecht import bcrypt
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
userID = db.Column(db.String, nullable=False, unique=True)
username = db.Column(db.String, nullable=False, unique=True)
firstname = db.Column(db.String, nullable=False)
lastname = db.Column(db.String, nullable=False)
group = db.Column(db.String, nullable=False)
password = db.Column(db.String, nullable=False)
def toJSON(self):
dic = {
"username": self.username,
"firstname": self.firstname,
"lastname": self.lastname,
"group": self.group,
}
return dic
def login(self, password):
return True if bcrypt.check_password_hash(self.password, password) else False

View File

@ -1,156 +1,59 @@
from flask import render_template, url_for, redirect, flash, jsonify, g, request from geruecht import app, db, accesTokenController
from flask_login import login_user, current_user, logout_user, login_required from geruecht.model.user import User
from geruecht import app, db, bcrypt from geruecht.model.creditList import CreditList
from geruecht.forms import RegistrationForm, FinanzerLogin from geruecht.model.priceList import PriceList
from geruecht.model import User, History, Finanzer from flask import request, jsonify
import flask_sijax
import os, sys
path = os.path.join('.', os.path.dirname(__file__), '../') MONEY = "moneymaster"
sys.path.append(path) GASTRO = "gastro"
USER = "user"
# The path where you want the extension to create the needed javascript files def verifyAccessToken(token, group):
# DON'T put any of your files in this directory, because they'll be deleted! accToken = accesTokenController.findAccesToken(token)
app.config["SIJAX_STATIC_PATH"] = os.path.join('.', os.path.dirname(__file__), 'static/js/sijax/') print(accToken)
if accToken is not None:
if accesTokenController.isSameGroup(accToken, group):
accToken.updateTimestamp()
return accToken
return None
# You need to point Sijax to the json2.js library if you want to support @app.route("/getFinanzerMain", methods=['POST'])
# browsers that don't support JSON natively (like IE <= 7) def _getFinanzer():
app.config["SIJAX_JSON_URI"] = '/static/js/sijax/json2.js' data = request.get_json()
token = data["token"]
flask_sijax.Sijax(app) accToken = verifyAccessToken(token, MONEY)
if accToken is not None:
users = User.query.all()
dic = {}
for user in users:
dic["userID"] = user.toJSON()
return jsonify(dic)
return jsonify({"error": "permission denied"}), 401
history = [] @app.route("/login", methods=['POST'])
def _login():
data = request.get_json()
@flask_sijax.route(app, "/", methods=['GET', 'POST']) print(data)
@flask_sijax.route(app, "/home", methods=['GET', 'POST']) username = data['username']
def home(): password = data['password']
def add(obj_response, username, value): user = User.query.filter_by(username=username).first()
user_2 = User.query.filter_by(username=username).first() if user:
print(user_2) if user.login(password):
print(user_2.id) token = accesTokenController.createAccesToken(user)
user_2.add(value) dic = user.toJSON()
print(user_2) dic["token"] = token
db.session.commit() return jsonify({user.userID: dic})
print(obj_response, username, value)
History(history=history, user=user_2, value=value)
print(history)
obj_response.html('div#flash', f'{user_2.username} wurde {"%.2f"%value} € hinzugefügt')
obj_response.attr('div#flash', "class", "alert alert-success")
obj_response.html(f'#{user_2.id}-sum', str("%.2f" % user_2.getsum() + ""))
def storner(obj_response):
try:
obj = history[len(history)-1]
user_2 = User.query.filter_by(username=obj.user.username).first()
print("{} {}".format(obj.user, obj.value))
obj.exec()
print(history)
print(user_2)
db.session.commit()
obj_response.html('div#flash', f'{"%.2f"%obj.value} wurden von {user_2.username} storniert')
obj_response.attr('div#flash', "class", "alert alert-success")
obj_response.html(f'#{user_2.id}-sum', str("%.2f" % user_2.getsum() + ""))
except IndexError:
print("history: {} is empty".format(history))
obj_response.html('div#flash', "Der Timer ist abgelaufen!! Die Stornierliste ist leer!! Falls es was wichtiges ist, melde dich beim Finanzer oder Administrator!!")
obj_response.attr('div#flash', "class", "alert alert-error")
if g.sijax.is_sijax_request:
g.sijax.register_callback('add', add)
g.sijax.register_callback('storner', storner)
return g.sijax.process_request()
form = RegistrationForm()
if form.validate_on_submit():
user = User(username=form.username.data)
db.session.add(user)
db.session.commit()
flash(f'Person wurde angelegt: {form.username.data}', 'success')
return redirect(url_for('home'))
return render_template('home.html', users=User.query.all(), form=form)
@flask_sijax.route(app, "/return")
def to_home():
return home()
@app.route("/login", methods=['GET', 'POST'])
def login():
if current_user.is_authenticated:
return redirect(url_for('home'))
login_form = FinanzerLogin()
if login_form.validate_on_submit():
user = Finanzer.query.filter_by(username=login_form.username.data).first()
if user:
if user and bcrypt.check_password_hash(user.password, login_form.password.data):
login_user(user)
next_page = request.args.get('next')
return redirect(next_page) if next_page else redirect(url_for('home'))
else:
flash('Passwort ist falsch', 'error')
else: else:
flash('nur der finanzer kann sich einloggen !!', 'error') return jsonify({"error": "wrong password"}), 401
return render_template('login.html', title='Login', form=login_form) return jsonify({"error": "wrong username"}), 402
@app.route("/getFinanzer")
@app.route("/logout") def getFinanzer():
def logout(): users = User.query.all()
logout_user() dic = {}
return redirect(url_for('home')) for user in users:
dic["userID"] = user.toJSON()
print(dic)
@flask_sijax.route(app, "/uebersicht") return jsonify(dic)
@login_required
def finanzen():
def supply(obj_response, arg1, arg2):
list = zip(arg1, arg2)
try:
for value in arg2:
if value:
float(value)
for user_id, value in list:
if user_id and value:
user_ = User.query.get(user_id)
user_.add_sub(float(value))
db.session.commit()
obj_response.attr(f'#{user_id}-input', 'value', '')
obj_response.html('div#flash', "Alle Werte wurden übernommen")
obj_response.attr('div#flash', 'class', "alert alert-success")
for user_ in User.query.all():
obj_response.html(f'p#{user_.id}-jan-sub', "%.2f"%user_.jan_sub + "")
obj_response.html(f'p#{user_.id}-feb-sub', "%.2f"%user_.feb_sub + "")
obj_response.html(f'p#{user_.id}-maer-sub', "%.2f"%user_.maer_sub + "")
obj_response.html(f'p#{user_.id}-apr-sub', "%.2f"%user_.apr_sub + "")
obj_response.html(f'p#{user_.id}-mai-sub', "%.2f"%user_.mai_sub + "")
obj_response.html(f'p#{user_.id}-jun-sub', "%.2f"%user_.jun_sub + "")
obj_response.html(f'p#{user_.id}-jul-sub', "%.2f"%user_.jul_sub + "")
obj_response.html(f'p#{user_.id}-aug-sub', "%.2f"%user_.aug_sub + "")
obj_response.html(f'p#{user_.id}-sep-sub', "%.2f"%user_.sep_sub + "")
obj_response.html(f'p#{user_.id}-okt-sub', "%.2f"%user_.okt_sub + "")
obj_response.html(f'p#{user_.id}-nov-sub', "%.2f"%user_.nov_sub + "")
obj_response.html(f'p#{user_.id}-dez-sub', "%.2f"%user_.dez_sub + "")
obj_response.html(f'p#{user_.id}-sum', "%.2f"%user_.getsum() + "")
except ValueError:
obj_response.html('div#flash',
"Du hast irgendwo keine Zahl eingegeb!!")
obj_response.attr('div#flash', "class", "alert alert-error")
if g.sijax.is_sijax_request:
g.sijax.register_callback('supply', supply)
return g.sijax.process_request()
return render_template('finanzer.html', users=User.query.all())
@flask_sijax.route(app, "/about")
def about():
return render_template('about.html', title='about')

BIN
geruecht/site.db Normal file

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

View File

@ -1,194 +0,0 @@
body {
margin: 0 auto;
}
.topnav {
background-color: #077BCB;
height: 61;
overflow: hidden;
}
.blue-button {
color: white;
background-color: #055288;
text-align: center;
padding: 5px 5px;
margin: 7px 17px;
text-decoration: none;
font-size: 17px;
border: 5px solid #055288;
border-style: solid;
border-radius: 10px;
transition-duration: 0.4s;
/*box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);*/
}
.no-mg {
margin: 0;
}
.no-pd {
padding: 0;
}
.blue-button:hover {
background: white;
border: 5px solid #055288;
color: black;
}
.blue-button:active {
transform: translateY(4px);
}
.first {
float: left;;
margin-left: 10%;
}
.last {
float: right;
}
.logo-nav {
height: 61px;
width: auto;
transition-duration: 0.4s;
}
.logo-nav:active {
transform: translateY(4px)
}
.logo-nav img {
position: absolute;
transition-duration: 0.4s;
}
.logo-nav img.main-logo:hover {
opacity: 0;
}
.geruecht {
margin: 5px auto;
display: table;
border: 0px;
border-top: 1px gray;
border-bottom: 1px gray;
border-radius: 15px;
border-style: solid;
width: 100%;
border-spacing: 5px;
height: 30px;
}
.g-item {
display: table-cell;
text-align: center;
vertical-align: middle;
width: 20%;
}
.auto-width {
width:6.66%;
}
.width-auto {
width:80%;
}
.g-item p {
font-size: 15px;
}
.button {
width: 70px;
heigt: 30px;
border-radius: 10px;
border: 5px solid green;
background: green;
color: white;
transition-duration: 0.4s;
}
.button:hover {
color: green;
background: white;
}
.button:active {
transform: translateY(4px);
}
.bottombar {
background-color: #077BCB;
overflow: scroll;
position: fixed;
bottom: 0;
width: 100%;
height: 62px;
display: table;
}
.bottombar-element {
float: left;
line-height: auto;
vertical-align: middle;
}
.right {
float: right;
}
.form-group {
float: left;
border: 0;
height: auto;
padding: 5px;
margin: auto;
float: left;
vertical-align: middle;
}
.reg-label {
color: white;
}
.m {
margin-top: 10px;
}
.alert {
color: black;
font-size: 15px;
text-align: center;
}
.alert-success {
background: lightgreen;
border: 1px solid darkgreen;
color: darkgreen;
border-radius: 5px;
padding: 6px;
}
.alert-error {
background: darksalmon;
border: 1px solid darkred;
color: darkred;
border-radius: 5px;
padding: 6px;
}
.container {
margin-bottom: 50%;
}
.schulden {
color: red;
}
.bezahlt {
color: green;
}

View File

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

View File

@ -1,119 +0,0 @@
{% extends 'layout.html' %}
{% block content %}
<div class="geruecht">
<div class="g-item auto-width">
<b>Username</b>
</div>
<div class="g-item auto-width">
<b>Januar</b>
</div>
<div class="g-item auto-width">
<b>Februar</b>
</div>
<div class="g-item auto-width">
<b>März</b>
</div>
<div class="g-item auto-width">
<b>April</b>
</div>
<div class="g-item auto-width">
<b>Mai</b>
</div>
<div class="g-item auto-width">
<b>Juni</b>
</div>
<div class="g-item auto-width">
<b>July</b>
</div>
<div class="g-item auto-width">
<b>August</b>
</div>
<div class="g-item auto-width">
<b>September</b>
</div>
<div class="g-item auto-width">
<b>Oktober</b>
</div>
<div class="g-item auto-width">
<b>November</b>
</div>
<div class="g-item auto-width">
<b>Dezember</b>
</div>
<div class="g-item auto-width">
<b>Schulden</b>
</div>
<div class="g-item auto-width">
<b>Ausgleich</b>
</div>
</div>
{% for user in users %}
<div class="geruecht">
<div class="g-item auto-width">
<p>{{ user.username }}</p>
</div>
<div class="g-item auto-width">
<p id="{{ user.id }}-jan" class="schulden">{{ "%.2f"%user.jan }} €</p>
<p id="{{ user.id }}-jan-sub" class="bezahlt">{{ "%.2f"%user.jan_sub }} €</p>
</div>
<div class="g-item auto-width">
<p id="{{ user.id }}-feb" class="schulden">{{ "%.2f"%user.feb }} €</p>
<p id="{{ user.id }}-feb-sub" class="bezahlt">{{ "%.2f"%user.feb_sub }} €</p>
</div>
<div class="g-item auto-width">
<p id="{{ user.id }}-maer" class="schulden">{{ "%.2f"%user.maer }} €</p>
<p id="{{ user.id }}-maer-sub" class="bezahlt">{{ "%.2f"%user.maer_sub }} €</p>
</div>
<div class="g-item auto-width">
<p id="{{ user.id }}-apr" class="schulden">{{ "%.2f"%user.apr }} €</p>
<p id="{{ user.id }}-apr-sub" class="bezahlt">{{ "%.2f"%user.apr_sub }} €</p>
</div>
<div class="g-item auto-width">
<p id="{{ user.id }}-mai" class="schulden">{{ "%.2f"%user.mai }} €</p>
<p id="{{ user.id }}-mai-sub" class="bezahlt">{{ "%.2f"%user.mai_sub }} €</p>
</div>
<div class="g-item auto-width">
<p id="{{ user.id }}-jun" class="schulden">{{ "%.2f"%user.jun }} €</p>
<p id="{{ user.id }}-jun-sub" class="bezahlt">{{ "%.2f"%user.jun_sub }} €</p>
</div>
<div class="g-item auto-width">
<p id="{{ user.id }}-jul" class="schulden">{{ "%.2f"%user.jul }} €</p>
<p id="{{ user.id }}-jul-sub" class="bezahlt">{{ "%.2f"%user.jul_sub }} €</p>
</div>
<div class="g-item auto-width">
<p id="{{ user.id }}-aug" class="schulden">{{ "%.2f"%user.aug }} €</p>
<p id="{{ user.id }}-aug-sub" class="bezahlt">{{ "%.2f"%user.aug_sub }} €</p>
</div>
<div class="g-item auto-width">
<p id="{{ user.id }}-sep" class="schulden">{{ "%.2f"%user.sep }} €</p>
<p id="{{ user.id }}-sep-sub" class="bezahlt">{{ "%.2f"%user.sep_sub }} €</p>
</div>
<div class="g-item auto-width">
<p id="{{ user.id }}-okt" class="schulden">{{ "%.2f"%user.okt }} €</p>
<p id="{{ user.id }}-okt-sub" class="bezahlt">{{ "%.2f"%user.okt_sub }} €</p>
</div>
<div class="g-item auto-width">
<p id="{{ user.id }}-nov" class="schulden">{{ "%.2f"%user.nov }} €</p>
<p id="{{ user.id }}-nov-sub" class="bezahlt">{{ "%.2f"%user.nov_sub }} €</p>
</div>
<div class="g-item auto-width">
<p id="{{ user.id }}-dez" class="schulden">{{ "%.2f"%user.dez }} €</p>
<p id="{{ user.id }}-dez-sub" class="bezahlt">{{ "%.2f"%user.dez_sub }} €</p>
</div>
<div class="g-item auto-width">
<p id="{{ user.id }}-sum">{{ "%.2f"%user.getsum() }} €</p>
</div>
<div class="g-item auto-width">
<input class="g-item width-auto" type="text" id="{{ user.id }}-input">
</div>
</div>
{% endfor %}
{% endblock %}
{% block bottombar %} <!-- , [[{% for user in users %} {{ user.id }}, {% endfor %} None], [{% for user in users %} $('#{{ user.id }}-input').attr('value'), {% endfor %} None]] -->
<!-- document.getElementById('1-input').value -->
<div id="btn" class="right blue-button buttombar-element" textref="javascript://" onclick="Sijax.request('supply', [[{% for user in users %} {{ user.id }}, {% endfor %} null], [{% for user in users %}document.getElementById('{{ user.id }}-input').value, {% endfor %} null]]);">
Anwenden
</div>
{% endblock %}

View File

@ -1,53 +0,0 @@
{% extends "layout.html" %}
{% block content %}
{% for user in users %}
<div class="geruecht">
<div class="g-item">
<p>{{ user.username }}</p>
</div>
<div class="g-item button" id="{{ user.id }}-2" href="javascript://" onclick="Sijax.request('add', ['{{ user.username }}', 2]);">
+2 &euro;
</div>
<div class="g-item button" id="{{ user.it }}-1" href="javascript://" onclick="Sijax.request('add', ['{{ user.username }}', 1]);">
+1 &euro;
</div>
<div class="g-item button" id="{{ user.id }}-050" href="javascript://" onclick="Sijax.request('add', ['{{ user.username }}', 0.5]);">
+0,5 &euro;
</div>
<div class="g-item button" id="{{ user.id }}-040" href="javascript://" onclick="Sijax.request('add', ['{{ user.username }}', 0.4]);">
+0,4 &euro;
</div>
<div class="g-item button" id="{{ user.id }}-020" href="javascript://" onclick="Sijax.request('add', ['{{ user.username }}', 0.2]);">
+0,2 &euro;
</div>
<div class="g-item button" id="{{ user.id }}-010" href="javascript://" onclick="Sijax.request('add', ['{{ user.username }}', 0.1]);">
+0,1 &euro;
</div>
<div class="g-item">
<p id="{{ user.id }}-sum">{{ "%.2f"%user.getsum() }} €</p>
</div>
</div>
{% endfor %}
{% endblock %}
{% block bottombar %}
<div class="bottombar-element">
{% if form %}
<form method="POST" action="">
{{ form.hidden_tag() }}
<fieldset class="form-group">
<!-- <legend class="reg-label">neue Person hinzufügen</legend> -->
<div class="form-group">
{{ form.username.label(class="reg-label") }}
{{ form.username() }}
</div>
</fieldset>
<div class="form-group m">
{{ form.submit(class="blue-button no-mg") }}
</div>
</form>
{% endif %}
</div>
<div class="right blue-button buttombar-element" href="javascript://" onclick="Sijax.request('storner');">
Stornieren
</div>
{% endblock %}

View File

@ -1,89 +0,0 @@
<!DOCTYPE html>
<head>
{% if title %}
<title>{{ title }}</title>
{% else %}
<title>Gerüchteküche</title>
{% endif %}
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="{{ url_for('static', filename='master.css') }}", type="text/css", rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript"
src="/static/js/sijax/sijax.js"></script>
<script type="text/javascript">
{{ g.sijax.get_js()|safe }}
</script>
</head>
<body>
<div class="topnav">
<a class="logo-nav first" href="{{ url_for('to_home') }}">
<img class="logo-nav background-logo" src="{{ url_for('static', filename='img/logo_selected.png')}}">
<img class="logo-nav main-logo" src="{{ url_for('static', filename='img/logo.png') }}">
</a>
{% if current_user.is_authenticated %}
<a class="last blue-button" href="{{ url_for('logout') }}">Logout</a>
<a class="last blue-button" href="{{ url_for('finanzen') }}">Übersicht</a>
{% else %}
<a class="last blue-button" href="{{ url_for('login') }}">Finanzer</a>
{% endif %}
</div>
<div class="container">
{% block content %}
{% endblock %}
</div>
<div class="bottombar">
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="alert alert-{{ category }}">
{{ message }}
</div>
{% endfor %}
{% endif %}
{% if form %}
{% if form.username.errors %}
{% for error in form.username.errors %}
<div class="alert alert-error">
<span>{{ error }}</span>
</div>
{% endfor %}
{% endif %}
{% if form.password %}
{% if form.password.errors %}
{% for error in form.password.errors %}
<div class="alert alert-error">
<span>{{ error }}</span>
</div>
{% endfor %}
{% endif %}
{% endif %}
{% endif %}
{% endwith %}
<div id="flash"></div>
{% block bottombar %}
{% endblock %}
</div>
<!-- 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

@ -1,41 +0,0 @@
{% extends "layout.html" %}
{% block content %}
<div class="login-content">
<form method="POST" action="">
{{ form.hidden_tag() }}
<fieldset class="login-group">
<legend class="">Log In</legend>
<div class="login-group">
{{ form.username.label(class="") }}
{% if form.username.errors %}
{{ form.username(class="") }}
<div class="">
{% for error in form.username.error %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.username(class="") }}
{% endif %}
</div>
<div class="login-group">
{{ form.password.label(class="") }}
{% if form.password.errors %}
{{ form.password(class="") }}
<div class="">
{% for error in form.password.error %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.password(class="") }}
{% endif %}
</div>
</fieldset>
<div class="login-group">
{{ form.submit(class="") }}
</div>
</form>
</div>
{% endblock %}

View File

@ -1,346 +0,0 @@
<!DOCTYPE html>
<head>
<title>Home</title>
<link rel="stylesheet" href="css/master.css">
</head>
<body>
<div class="topnav">
<a class="first" href="#">Finanzer</a>
</div>
<div class="geruecht">
<div class="g-item first">
<p>dummy 1</p>
</div>
<div class="g-item button">
<p>+2 &euro;</p>
</div>
<div class="g-item button">
<p>+1 &euro;</p>
</div>
<div class="g-item button">
<p>+0,5 &euro;</p>
</div>
<div class="g-item button">
<p>+0,4 &euro;</p>
</div>
<div class="g-item button">
<p>+0,2 &euro;</p>
</div>
<div class="g-item button">
<p>+0,1 &euro;</p>
</div>
<div class="g-item">
<p>Gesamt</p>
</div>
</div>
<div class="geruecht">
<div class="g-item first">
<p>dummy 1</p>
</div>
<div class="g-item button">
<p>+2 &euro;</p>
</div>
<div class="g-item button">
<p>+1 &euro;</p>
</div>
<div class="g-item button">
<p>+0,5 &euro;</p>
</div>
<div class="g-item button">
<p>+0,4 &euro;</p>
</div>
<div class="g-item button">
<p>+0,2 &euro;</p>
</div>
<div class="g-item button">
<p>+0,1 &euro;</p>
</div>
<div class="g-item">
<p>Gesamt</p>
</div>
</div>
<div class="geruecht">
<div class="g-item first">
<p>dummy 1</p>
</div>
<div class="g-item button">
<p>+2 &euro;</p>
</div>
<div class="g-item button">
<p>+1 &euro;</p>
</div>
<div class="g-item button">
<p>+0,5 &euro;</p>
</div>
<div class="g-item button">
<p>+0,4 &euro;</p>
</div>
<div class="g-item button">
<p>+0,2 &euro;</p>
</div>
<div class="g-item button">
<p>+0,1 &euro;</p>
</div>
<div class="g-item">
<p>Gesamt</p>
</div>
</div>
<div class="geruecht">
<div class="g-item first">
<p>dummy 1</p>
</div>
<div class="g-item button">
<p>+2 &euro;</p>
</div>
<div class="g-item button">
<p>+1 &euro;</p>
</div>
<div class="g-item button">
<p>+0,5 &euro;</p>
</div>
<div class="g-item button">
<p>+0,4 &euro;</p>
</div>
<div class="g-item button">
<p>+0,2 &euro;</p>
</div>
<div class="g-item button">
<p>+0,1 &euro;</p>
</div>
<div class="g-item">
<p>Gesamt</p>
</div>
</div>
<div class="geruecht">
<div class="g-item first">
<p>dummy 1</p>
</div>
<div class="g-item button">
<p>+2 &euro;</p>
</div>
<div class="g-item button">
<p>+1 &euro;</p>
</div>
<div class="g-item button">
<p>+0,5 &euro;</p>
</div>
<div class="g-item button">
<p>+0,4 &euro;</p>
</div>
<div class="g-item button">
<p>+0,2 &euro;</p>
</div>
<div class="g-item button">
<p>+0,1 &euro;</p>
</div>
<div class="g-item">
<p>Gesamt</p>
</div>
</div>
<div class="geruecht">
<div class="g-item first">
<p>dummy 1</p>
</div>
<div class="g-item button">
<p>+2 &euro;</p>
</div>
<div class="g-item button">
<p>+1 &euro;</p>
</div>
<div class="g-item button">
<p>+0,5 &euro;</p>
</div>
<div class="g-item button">
<p>+0,4 &euro;</p>
</div>
<div class="g-item button">
<p>+0,2 &euro;</p>
</div>
<div class="g-item button">
<p>+0,1 &euro;</p>
</div>
<div class="g-item">
<p>Gesamt</p>
</div>
</div>
<div class="geruecht">
<div class="g-item first">
<p>dummy 1</p>
</div>
<div class="g-item button">
<p>+2 &euro;</p>
</div>
<div class="g-item button">
<p>+1 &euro;</p>
</div>
<div class="g-item button">
<p>+0,5 &euro;</p>
</div>
<div class="g-item button">
<p>+0,4 &euro;</p>
</div>
<div class="g-item button">
<p>+0,2 &euro;</p>
</div>
<div class="g-item button">
<p>+0,1 &euro;</p>
</div>
<div class="g-item">
<p>Gesamt</p>
</div>
</div>
<div class="geruecht">
<div class="g-item first">
<p>dummy 1</p>
</div>
<div class="g-item button">
<p>+2 &euro;</p>
</div>
<div class="g-item button">
<p>+1 &euro;</p>
</div>
<div class="g-item button">
<p>+0,5 &euro;</p>
</div>
<div class="g-item button">
<p>+0,4 &euro;</p>
</div>
<div class="g-item button">
<p>+0,2 &euro;</p>
</div>
<div class="g-item button">
<p>+0,1 &euro;</p>
</div>
<div class="g-item">
<p>Gesamt</p>
</div>
</div>
<div class="geruecht">
<div class="g-item first">
<p>dummy 1</p>
</div>
<div class="g-item button">
<p>+2 &euro;</p>
</div>
<div class="g-item button">
<p>+1 &euro;</p>
</div>
<div class="g-item button">
<p>+0,5 &euro;</p>
</div>
<div class="g-item button">
<p>+0,4 &euro;</p>
</div>
<div class="g-item button">
<p>+0,2 &euro;</p>
</div>
<div class="g-item button">
<p>+0,1 &euro;</p>
</div>
<div class="g-item">
<p>Gesamt</p>
</div>
</div>
<div class="geruecht">
<div class="g-item first">
<p>dummy 1</p>
</div>
<div class="g-item button">
<p>+2 &euro;</p>
</div>
<div class="g-item button">
<p>+1 &euro;</p>
</div>
<div class="g-item button">
<p>+0,5 &euro;</p>
</div>
<div class="g-item button">
<p>+0,4 &euro;</p>
</div>
<div class="g-item button">
<p>+0,2 &euro;</p>
</div>
<div class="g-item button">
<p>+0,1 &euro;</p>
</div>
<div class="g-item">
<p>Gesamt</p>
</div>
</div>
<div class="geruecht">
<div class="g-item first">
<p>dummy 1</p>
</div>
<div class="g-item button">
<p>+2 &euro;</p>
</div>
<div class="g-item button">
<p>+1 &euro;</p>
</div>
<div class="g-item button">
<p>+0,5 &euro;</p>
</div>
<div class="g-item button">
<p>+0,4 &euro;</p>
</div>
<div class="g-item button">
<p>+0,2 &euro;</p>
</div>
<div class="g-item button">
<p>+0,1 &euro;</p>
</div>
<div class="g-item">
<p>Gesamt</p>
</div>
</div>
<div class="geruecht">
<div class="g-item first">
<p>dummy 1</p>
</div>
<div class="g-item button">
<p>+2 &euro;</p>
</div>
<div class="g-item button">
<p>+1 &euro;</p>
</div>
<div class="g-item button">
<p>+0,5 &euro;</p>
</div>
<div class="g-item button">
<p>+0,4 &euro;</p>
</div>
<div class="g-item button">
<p>+0,2 &euro;</p>
</div>
<div class="g-item button">
<p>+0,1 &euro;</p>
</div>
<div class="g-item">
<p>Gesamt</p>
</div>
</div>
<div class="bottombar">
<div class="bottombar-element">
<form class="field" action="index.html" method="post">
Name: <input type="text" name="" value="">
<input type="submit" name="" value="erstellen">
</form>
</div>
<div class="bottombar-element right">
<p>Stornieren</p>
</div>
</div>
</body>

4
run.py
View File

@ -1,9 +1,5 @@
from geruecht import app from geruecht import app
if __name__ == '__main__': if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0') app.run(debug=True, host='0.0.0.0')