fixed some bugs with the get-all-shared for new users

master
Kostanjevec 2022-07-15 12:27:24 +02:00
parent 0339653954
commit af84024889
2 changed files with 6 additions and 4 deletions

View File

@ -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()

View File

@ -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)