blob: 0df888a3706ea454e90f15b813dbe0fe9b335f83 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# frozen_string_literal: true
module Timelogs
class DeleteService < Timelogs::BaseService
def execute
unless can?(current_user, :admin_timelog, timelog)
return ServiceResponse.error(
message: "Timelog doesn't exist or you don't have permission to delete it",
http_status: 404)
end
if timelog.destroy
issuable = timelog.issuable
if issuable
# Add a system note for the timelog removal
SystemNoteService.remove_timelog(issuable, issuable.project, current_user, timelog)
end
ServiceResponse.success(payload: timelog)
else
ServiceResponse.error(message: 'Failed to remove timelog', http_status: 400)
end
end
end
end
|