From af84024889940b4c5650644715661ec9a87ee9a3 Mon Sep 17 00:00:00 2001 From: Kostanjevec Date: Fri, 15 Jul 2022 12:27:24 +0200 Subject: [PATCH] fixed some bugs with the get-all-shared for new users --- auth.py | 5 +++-- share.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/auth.py b/auth.py index 1cc7803..f8454c1 100644 --- a/auth.py +++ b/auth.py @@ -38,9 +38,10 @@ def register(): dbsession.commit() #Preden zapremo naj user dobi vse shared karte od prej. - user_id = None #TODO get user id + new_user = dbsession.query(User).filter(User.username == username).first() + new_user_id = new_user.id - get_all_shared(user_id) + get_all_shared(new_user_id) dbsession.close() diff --git a/share.py b/share.py index 7fe582e..5e25d3b 100644 --- a/share.py +++ b/share.py @@ -35,8 +35,9 @@ def get_all_shared(user_id): dbsession = get_session() #get all cards with a shared id but make suer they are unique. add them to collection of user - all_shared_cards = dbsession.query(Card).filter(Card.share_id != 0).distinct(Card.share_id).group_by(Card.share_id) - # new_card = card = Card(title=card.title, interest_rate=-1.0, owner_id=user.id, item_location=card.item_location, last_review=None, share_id=h) + #@TODO A je to resres ok? + all_shared_cards = dbsession.query(Card).filter(Card.share_id != "0").distinct(Card.share_id).group_by(Card.share_id) + for c in all_shared_cards: new_card = Card(title= c.title, interest_rate=-1.0, owner_id=user_id, item_location=c.item_location, last_review=None, share_id=c.share_id) dbsession.add(new_card)