Skip to content

Commit

Permalink
fix: filtered deleted entities from user favourite events
Browse files Browse the repository at this point in the history
  • Loading branch information
codedsun committed Jan 22, 2020
1 parent 494608c commit 9c5a576
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/api/user_favourite_events.py
Expand Up @@ -35,8 +35,9 @@ def before_post(self, args, kwargs, data):
raise ForbiddenException({'source': ''}, 'Only Authorized Users can favourite an event')

data['user'] = current_user.id
user_favourite_event = UserFavouriteEvent.query.filter_by(
user=current_user, event_id=int(data['event'])).first()
user_favourite_event = UserFavouriteEvent.query.filter_by(deleted_at=None,
user=current_user,
event_id=int(data['event'])).first()
if user_favourite_event:
raise ConflictException({'pointer': '/data/relationships/event'}, "Event already favourited")

Expand Down Expand Up @@ -86,8 +87,9 @@ def before_get_object(self, view_kwargs):

if view_kwargs.get('id') is not None:
try:
user_favourite_event = UserFavouriteEvent.query.filter_by(
user=current_user, event_id=view_kwargs['id']).first()
user_favourite_event = UserFavouriteEvent.query.filter_by(deleted_at=None,
user=current_user,
event_id=view_kwargs['id']).first()
except NoResultFound:
raise ObjectNotFound({'source': '/data/relationships/event'}, "Object: not found")
else:
Expand Down

0 comments on commit 9c5a576

Please sign in to comment.