Skip to content

Commit

Permalink
fix: edit prayhelper when deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
baebae02 committed Oct 31, 2023
1 parent 22ed8f0 commit 9d6e403
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/utils/share.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ def share_pray(prayList):
pray = Storage.query.filter_by(id=pray_id).order_by(Storage.created_at).first()
if pray is None or pray.user_id == g.user_id or pray.deleted_at is not None:
raise ShareError('공유할 수 없는 기도제목입니다.')
if Share.query.filter_by(receipt_id=g.user_id, storage_id=pray_id).first():
raise ShareError('이미 공유받은 기도제목입니다.')
if Share.query.filter_by(receipt_id=g.user_id, storage_id=pray_id, deleted_at=None).first():
raise ShareError('이미 공유받은 기도제목입니다.')
if Share.query.filter_by(receipt_id=g.user_id, pray_id=pray.pray_id).first().deleted_at is not None:
share.deleted_at = None
pray.pray.is_shared = True
db.session.commit()
try:
share = ShareDTO(receipt_id=g.user_id, storage_id=pray_id, pray_id=pray.pray_id)
share.save()
Expand Down

0 comments on commit 9d6e403

Please sign in to comment.