Skip to content

Commit

Permalink
Update index.py (#159)
Browse files Browse the repository at this point in the history
在操作时都需要判断 ticket 当前是否能够进行操作,处于 pending 状态下才能操作 关闭/通过/拒绝
  • Loading branch information
QSummerY authored Oct 9, 2023
1 parent 2d46f0a commit 456860a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions helpdesk/views/api/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ async def ticket_op(ticket_id: int, op: str,
ticket = await Ticket.get(ticket_id)
if not ticket:
raise HTTPException(status_code=404, detail='Ticket not found')
if ticket.status != "pending":
raise HTTPException(status_code=400, detail='Ticket not pending, can not be operated')

if op == 'close':
"申请人才可主动关闭工单"
if ticket.submitter != current_user.name:
raise HTTPException(status_code=403, detail='Permission denied, only submitter can close')
if ticket.status != "pending":
raise HTTPException(status_code=400, detail='Ticket not pending, can not be closed')
ticket.annotate(closed=True)
ticket.confirmed_by = current_user.name
ticket.confirmed_at = datetime.now()
Expand Down

0 comments on commit 456860a

Please sign in to comment.