Skip to content

Commit

Permalink
delete fundraiseritem
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhongxuanWang committed Dec 4, 2023
1 parent dacb8eb commit 00470ec
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/fundraisers/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,23 @@ def add_fundraiser_item():
return success_message(new_fundraiser_item)


@bp.route('/delete_item/<item_id>', methods=['DELETE'])
@role_required('club')
def delete_fundraiser_item(item_id):
fundraiser_item = FundraiserItem.query.filter_by(id=item_id).first()

# If and only if the return is tuple, the error was prompted in the getting function

if fundraiser_item is None:
return failure_message(FAIL_MSG.TARGET_NOT_FOUND)

try:
db.session.delete(fundraiser_item)
db.session.commit()
except Exception as e:
return failure_message(FAIL_MSG.REMOVE_FROM_DATABASE + str(e))


@bp.route('/<fundraiser_id>/', methods=['DELETE'])
@role_required('club')
def delete_fundraiser_by_id(fundraiser_id):
Expand Down

0 comments on commit 00470ec

Please sign in to comment.