示例#1
0
 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
示例#2
0
    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
示例#3
0
 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
示例#4
0
 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
示例#5
0
 def delete(data):
     if data.get("sync", False):
         return
     model_id = data[event_name.replace("-", "_") + "_id"]
     if event_name == "comment":
         comment = deletion_service.remove_comment(model_id)
         tasks_service.reset_task_data(comment["object_id"])
     else:
         model.delete_all_by(id=model_id)
     forward_base_event(event_name, "delete", data)
     logger.info("Deletion: %s %s" % (model_name, model_id))
示例#6
0
文件: comments.py 项目: mmasjedi/zou
 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.reset_task_data(comment["object_id"])
     tasks_service.clear_comment_cache(comment["id"])
     return "", 204
示例#7
0
文件: resources.py 项目: ricekab/zou
 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
示例#8
0
    def post_update(self, instance_dict):
        comment = tasks_service.reset_mentions(instance_dict)
        if self.task_status_change:
            task_id = comment["object_id"]
            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
                })

        tasks_service.clear_comment_cache(comment["id"])
        notifications_service.reset_notifications_for_mentions(comment)
        return comment
示例#9
0
 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