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)
|
||||
|
||||
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)
|
||||
password = db.Column(db.String, nullable=False)
|
||||
|
||||
geruechte = db.relationship('CreditList', backref='user', lazy=True)
|
||||
|
||||
def toJSON(self):
|
||||
""" Create Dic to dump in JSON
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ def _getFinanzer():
|
|||
users = User.query.all()
|
||||
dic = {}
|
||||
for user in users:
|
||||
dic["userID"] = user.toJSON()
|
||||
dic[user.userID] = user.toJSON()
|
||||
return jsonify(dic)
|
||||
return jsonify({"error": "permission denied"}), 401
|
||||
|
||||
|
@ -92,6 +92,6 @@ def getFinanzer():
|
|||
users = User.query.all()
|
||||
dic = {}
|
||||
for user in users:
|
||||
dic["userID"] = user.toJSON()
|
||||
dic[user.userID] = user.toJSON()
|
||||
print(dic)
|
||||
return jsonify(dic)
|
||||
|
|
BIN
geruecht/site.db
BIN
geruecht/site.db
Binary file not shown.
Loading…
Reference in New Issue