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 post(self, task_id, comment_id): is_movie = self.get_arguments() task = tasks_service.get_task(task_id) if not permissions.has_manager_permissions(): user_service.check_assigned(task_id) comment = tasks_service.get_comment_raw(comment_id) task_status = tasks_service.get_task_status(comment.task_status_id) person = persons_service.get_current_user() if not task_status["is_reviewable"]: return { "error": "Comment status is not reviewable, you cannot link a " "preview to it." }, 400 revision = tasks_service.get_next_preview_revision(task_id) preview = files_service.create_preview_file(task["name"], revision, task["id"], person["id"], is_movie) comment.update({"preview_file_id": preview["id"]}) return preview, 201
def get_reply(comment_id, reply_id): comment = tasks_service.get_comment_raw(comment_id) reply = next( reply for reply in comment.replies if reply["id"] == reply_id ) return reply
def delete_reply(comment_id, reply_id): comment = tasks_service.get_comment_raw(comment_id) if comment.replies is None: comment.replies = [] comment.replies = [ reply for reply in comment.replies if reply["id"] != reply_id ] comment.save() return comment.serialize()
def reply_comment(comment_id, text): person = persons_service.get_current_user() comment = tasks_service.get_comment_raw(comment_id) 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 = comment.replies replies.append(reply) comment.replies = [] comment.save() comment.update({"replies": replies}) return reply
def delete_reply(comment_id, reply_id): comment = tasks_service.get_comment_raw(comment_id) task = tasks_service.get_task(comment.object_id) if comment.replies is None: comment.replies = [] comment.replies = [ reply for reply in comment.replies if reply["id"] != reply_id ] comment.save() events.emit("comment:delete-reply", { "task_id": task["id"], "comment_id": str(comment.id), "reply_id": reply_id }, project_id=task["project_id"], persist=False) return comment.serialize()
def acknowledge_comment(comment_id): """ Add current user to the list of people who acknowledged given comment. If he's already present, remove it. """ comment = tasks_service.get_comment_raw(comment_id) task = tasks_service.get_task(str(comment.object_id)) project_id = task["project_id"] current_user = persons_service.get_current_user_raw() current_user_id = str(current_user.id) acknowledgements = fields.serialize_orm_arrays(comment.acknowledgements) is_already_ack = current_user_id in acknowledgements if is_already_ack: _unack_comment(project_id, comment, current_user) else: _ack_comment(project_id, comment, current_user) comment.save() return comment.serialize(relations=True)