2222
2323from app .iris_engine .access_control .iris_user import iris_current_user
2424from app .blueprints .access_controls import ac_api_requires
25+ from app .blueprints .access_controls import ac_api_return_access_denied
2526from app .blueprints .rest .endpoints import response_api_paginated
2627from app .blueprints .rest .endpoints import response_api_not_found
2728from app .blueprints .rest .parsing import parse_pagination_parameters
2829from app .blueprints .rest .endpoints import response_api_created
2930from app .blueprints .rest .endpoints import response_api_error
3031from app .blueprints .rest .endpoints import response_api_success
32+ from app .blueprints .rest .endpoints import response_api_deleted
3133from app .business .comments import comments_get_filtered_by_task
3234from app .business .comments import comments_create_for_task
3335from app .business .comments import comments_get_for_task
36+ from app .business .comments import comments_delete_for_task
3437from app .business .tasks import tasks_get
3538from app .business .errors import ObjectNotFoundError
3639from app .schema .marshables import CommentSchema
@@ -86,6 +89,18 @@ def read(self, task_identifier, identifier):
8689 except ObjectNotFoundError :
8790 return response_api_not_found ()
8891
92+ def delete (self , task_identifier , identifier ):
93+ try :
94+ task = self ._get_task (task_identifier , [CaseAccessLevel .full_access ])
95+ comment = comments_get_for_task (task , identifier )
96+ if comment .comment_user_id != iris_current_user .id :
97+ return ac_api_return_access_denied ()
98+
99+ comments_delete_for_task (task , comment )
100+ return response_api_deleted ()
101+ except ObjectNotFoundError :
102+ return response_api_not_found ()
103+
89104
90105tasks_comments_blueprint = Blueprint ('tasks_comments' , __name__ , url_prefix = '/<int:task_identifier>/comments' )
91106comments_operations = CommentsOperations ()
@@ -107,3 +122,9 @@ def create_tasks_comment(task_identifier):
107122@ac_api_requires ()
108123def get_task_comment (task_identifier , identifier ):
109124 return comments_operations .read (task_identifier , identifier )
125+
126+
127+ @tasks_comments_blueprint .delete ('/<int:identifier>' )
128+ @ac_api_requires ()
129+ def delete_task_comment (task_identifier , identifier ):
130+ return comments_operations .delete (task_identifier , identifier )
0 commit comments