relationship zwischen user und creditlist
fixed bug: json mit ['userID'] wird nicht mehr überschrieben
This commit is contained in:
parent
2ba7240611
commit
7bec023d57
|
@ -55,3 +55,5 @@ class CreditList(db.Model):
|
||||||
last_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)
|
year = db.Column(db.Integer, nullable=False, default=datetime.now().year)
|
||||||
|
|
||||||
|
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
|
||||||
|
|
|
@ -23,6 +23,8 @@ class User(db.Model):
|
||||||
group = db.Column(db.String, nullable=False)
|
group = db.Column(db.String, nullable=False)
|
||||||
password = db.Column(db.String, nullable=False)
|
password = db.Column(db.String, nullable=False)
|
||||||
|
|
||||||
|
geruechte = db.relationship('CreditList', backref='user', lazy=True)
|
||||||
|
|
||||||
def toJSON(self):
|
def toJSON(self):
|
||||||
""" Create Dic to dump in JSON
|
""" Create Dic to dump in JSON
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ def _getFinanzer():
|
||||||
users = User.query.all()
|
users = User.query.all()
|
||||||
dic = {}
|
dic = {}
|
||||||
for user in users:
|
for user in users:
|
||||||
dic["userID"] = user.toJSON()
|
dic[user.userID] = user.toJSON()
|
||||||
return jsonify(dic)
|
return jsonify(dic)
|
||||||
return jsonify({"error": "permission denied"}), 401
|
return jsonify({"error": "permission denied"}), 401
|
||||||
|
|
||||||
|
@ -92,6 +92,6 @@ def getFinanzer():
|
||||||
users = User.query.all()
|
users = User.query.all()
|
||||||
dic = {}
|
dic = {}
|
||||||
for user in users:
|
for user in users:
|
||||||
dic["userID"] = user.toJSON()
|
dic[user.userID] = user.toJSON()
|
||||||
print(dic)
|
print(dic)
|
||||||
return jsonify(dic)
|
return jsonify(dic)
|
||||||
|
|
BIN
geruecht/site.db
BIN
geruecht/site.db
Binary file not shown.
Loading…
Reference in New Issue