From 6f76944741726d83eb174dd4bff1a9b35b7a5619 Mon Sep 17 00:00:00 2001 From: TaaviE Date: Fri, 4 Jan 2019 16:55:10 +0200 Subject: [PATCH] Hide gifted gifts --- views.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/views.py b/views.py index cf9b38d..21bb606 100755 --- a/views.py +++ b/views.py @@ -44,6 +44,7 @@ from flask_dance.contrib.facebook import make_facebook_blueprint from flask_dance.contrib.github import make_github_blueprint from flask_dance.contrib.google import make_google_blueprint +from sqlalchemy import and_ from sqlalchemy.orm.exc import NoResultFound # Translation @@ -261,7 +262,9 @@ def notes(): empty = False try: - db_notes = Wishlist.query.filter(Wishlist.user_id == user_id).all() + # noinspection PyComparisonWithNone + # SQLAlchemy doesn't like "is None" + db_notes = Wishlist.query.filter(and_(Wishlist.user_id == user_id, Wishlist.received == None)).all() for note in db_notes: notes_from_file[note.item] = encrypt_id(note.id) except Exception as e: @@ -588,6 +591,9 @@ def giftingto(): modifyable = False name = "" + if note.received is not None: + continue + if note.status == NoteState.DEFAULT.value["id"]: selections = all_states selections.insert(0, selections.pop(selections.index(NoteState.DEFAULT.value)))