From 7bec023d57d6e05939089e6037b2bf8dc769da5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 23 Apr 2019 20:26:20 +0200 Subject: [PATCH] =?UTF-8?q?relationship=20zwischen=20user=20und=20creditli?= =?UTF-8?q?st=20fixed=20bug:=20json=20mit=20['userID']=20wird=20nicht=20me?= =?UTF-8?q?hr=20=C3=BCberschrieben?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- geruecht/model/creditList.py | 2 ++ geruecht/model/user.py | 2 ++ geruecht/routes.py | 4 ++-- geruecht/site.db | Bin 28672 -> 28672 bytes 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/geruecht/model/creditList.py b/geruecht/model/creditList.py index a99b5cb..039f486 100644 --- a/geruecht/model/creditList.py +++ b/geruecht/model/creditList.py @@ -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) diff --git a/geruecht/model/user.py b/geruecht/model/user.py index 591b0a3..011d4d7 100644 --- a/geruecht/model/user.py +++ b/geruecht/model/user.py @@ -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 diff --git a/geruecht/routes.py b/geruecht/routes.py index a413bbb..6497a1a 100644 --- a/geruecht/routes.py +++ b/geruecht/routes.py @@ -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) diff --git a/geruecht/site.db b/geruecht/site.db index 172ae01ada83bfeb1859bd052b769c271b5ec6ed..26c840d443926f4c28ad54a0ffccbd27c140ec75 100644 GIT binary patch delta 573 zcmZp8z}WDBaY80P$0G*53jXu_%XnV%IdeSP*qFtk*1^WcF0QQ1*dJVyn3R*6T$GxU zSrVUt=sWQ$|)+HgR{w$!qu}CNJa?V`ST0!Pmpc z#mx7JfqxFa1>d91f&y3g>O+`08H7Qgku@o?2pOpuC8-!1srX0chGa&iI~#cxcw|KS zx+OcNXXd7s=X$!BxkV+F8mAU{rCU^`XQWiRl;tL8hE^2>rkW)&aWY6sOG=7@OicoM zxi~MsJU2Dfy(l$3zsRj9v!p5&g&Bb%#mvPl38X>Z yV`5_#<^;L`qWUod|6~5w{NI79uky>nRC6;+GeU!biGx`jq&zouQGmjt0098BjkA>i delta 402 zcmZp8z}WDBaY80Pr#1s$1^;>eWn4QrwYi!%3kq!JU~UR!o&1hRfst)9Kd&hxD;t}* zyW-?E{1THB`NX){+ih9c#g&yA`y3~~;gDuz-ORz+!8~~lj{p;w=H?2%9!3r(eiH`% zsr)9J1r;>->*JX?8APQeC50PVOEVKwi}Ui!b5m2(i&E3`i_(fROR7?n5{p!fl2iW7g{74nSxZujOG=AVi;{~nbBj~+N-}fPBa8A=(^HFb^YcH3vznHk0WjSH?LzKN_;Qz}15~%DhzXUh4G$YjO VOkB*;oKP3?Ze|SlFTW^2007#Bc7p%_