def delete(self, task_id, comment_id): task = tasks_service.get_task(task_id) user_service.check_project_access(task["project_id"]) comment = deletion_service.remove_comment(comment_id) tasks_service.reset_task_data(comment["object_id"]) tasks_service.clear_comment_cache(comment_id) return "", 204
def reply_comment(comment_id, text): person = persons_service.get_current_user() comment = tasks_service.get_comment_raw(comment_id) task = tasks_service.get_task(comment.object_id, relations=True) if comment.replies is None: comment.replies = [] reply = { "id": str(fields.gen_uuid()), "date": date_helpers.get_now(), "person_id": person["id"], "text": text } replies = list(comment.replies) replies.append(reply) comment.update({"replies": replies}) tasks_service.clear_comment_cache(comment_id) events.emit( "comment:reply", { "task_id": task["id"], "comment_id": str(comment.id), "reply_id": reply["id"] }, project_id=task["project_id"], ) notifications_service.create_notifications_for_task_and_reply( task, comment.serialize(), reply) return reply
def delete(self, instance_id): """ Delete a comment corresponding at given ID. """ comment = tasks_service.get_comment(instance_id) # TODO: only the self user or a manager can delete a commentary if comment["object_type"] == "Task": task = tasks_service.get_task(comment["object_id"]) user_service.check_project_access(task["project_id"]) self.pre_delete(comment) tasks_service.reset_task_data(comment["object_id"]) self.post_delete(comment) elif comment["object_type"] == "OutputFile": output_file = files_service.get_output_file(comment["object_id"]) if output_file.get("entity_id"): instance = entities_service.get_entity( output_file["entity_id"]) elif output_file.get("asset_instance_id"): instance = assets_service.get_asset_instance( output_file["asset_instance_id"]) user_service.check_project_access(instance["project_id"]) else: current_app.logger.warn("Not yet implemented") return "", 404 deletion_service.remove_comment(comment["id"]) tasks_service.clear_comment_cache(comment["id"]) return "", 204
def post_update(self, instance_dict): comment = tasks_service.reset_mentions(instance_dict) if self.task_status_change: tasks_service.reset_task_data(comment["object_id"]) tasks_service.clear_comment_cache(comment["id"]) notifications_service.reset_notifications_for_mentions(comment) return comment
def delete(self, task_id, comment_id): """ Delete a comment corresponding at given ID. --- tags: - Tasks parameters: - in: path name: task_id required: True schema: type: UUID example: a24a6ea4-ce75-4665-a070-57453082c25 - in: path name: comment_id required: True schema: type: UUID example: a24a6ea4-ce75-4665-a070-57453082c25 responses: 204: description: Comment corresponding at given ID deleted """ comment = tasks_service.get_comment(comment_id) task = tasks_service.get_task(comment["object_id"]) if permissions.has_manager_permissions(): user_service.check_project_access(task["project_id"]) else: user_service.check_person_access(comment["person_id"]) self.pre_delete(comment) deletion_service.remove_comment(comment_id) tasks_service.reset_task_data(comment["object_id"]) tasks_service.clear_comment_cache(comment_id) self.post_delete(comment) return "", 204
def delete(self, instance_id): """ Delete a comment corresponding at given ID. """ comment = tasks_service.get_comment(instance_id) task = tasks_service.get_task(comment["object_id"]) user_service.check_project_access(task["project_id"]) deletion_service.remove_comment(comment["id"]) tasks_service.clear_comment_cache(comment["id"]) return "", 204
def delete(self, task_id, comment_id): """ Delete a comment corresponding at given ID. """ comment = tasks_service.get_comment(comment_id) task = tasks_service.get_task(comment["object_id"]) user_service.check_manager_project_access(task["project_id"]) self.pre_delete(comment) deletion_service.remove_comment(comment_id) tasks_service.reset_task_data(comment["object_id"]) tasks_service.clear_comment_cache(comment_id) self.post_delete(comment) return "", 204
def post_update(self, instance_dict): comment = comments_service.reset_mentions(instance_dict) if self.task_status_change: task_id = comment["object_id"] task = tasks_service.reset_task_data(task_id) events.emit("task:status-changed", { "task_id": task_id, "new_task_status_id": comment["task_status_id"], "previous_task_status_id": self.previous_task_status_id }, project_id=task["project_id"]) tasks_service.clear_comment_cache(comment["id"]) notifications_service.reset_notifications_for_mentions(comment) return comment
def delete(self, task_id, comment_id): """ Delete a comment corresponding at given ID. """ comment = tasks_service.get_comment(comment_id) task = tasks_service.get_task(comment["object_id"]) if permissions.has_manager_permissions(): user_service.check_project_access(task["project_id"]) else: user_service.check_working_on_entity(task["entity_id"]) self.pre_delete(comment) deletion_service.remove_comment(comment_id) tasks_service.reset_task_data(comment["object_id"]) tasks_service.clear_comment_cache(comment_id) self.post_delete(comment) return "", 204
def post_update(self, instance_dict): comment = tasks_service.reset_mentions(instance_dict) tasks_service.clear_comment_cache(comment["id"]) notifications_service.reset_notifications_for_mentions(comment) return comment