share now changes shareid for owner of card, almost fixing the bug
parent
ce72547bec
commit
314acb358a
8
share.py
8
share.py
|
@ -5,13 +5,17 @@ from create_db import User, Card, get_session
|
|||
|
||||
from hashlib import md5
|
||||
|
||||
|
||||
#@TODO najbrž je treba narediti tako da org card tudi dobi share id in se ostalo, kar to obsega
|
||||
def share(card, user_id):
|
||||
dbsession = get_session()
|
||||
|
||||
#tu bi lahko naredili nek autoincrement ampak i guess da hash unique idja tudi daje unique share_id, tega potem uporabljamo, da preverimo matche
|
||||
h = md5(str(card.id).encode("utf-8")).hexdigest()
|
||||
card.share_id = h
|
||||
|
||||
owner_card = dbsession.query(Card).filter(Card.id == card.id).first()
|
||||
owner_card.share_id = h
|
||||
dbsession.commit()
|
||||
|
||||
# all users
|
||||
users = dbsession.query(User).filter(User.id != user_id).all()
|
||||
|
@ -22,4 +26,4 @@ def share(card, user_id):
|
|||
print("sharing to, ", user.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)
|
||||
dbsession.add(new_card)
|
||||
dbsession.commit()
|
||||
dbsession.commit()
|
Loading…
Reference in New Issue