Beispiel #1
0
    def test_get_tasks_for_person(self):
        self.generate_fixture_task()
        tasks_service.create_comment(
            self.task.id,
            self.task_status.id,
            self.person.id,
            "first comment"
        )
        tasks_service.create_comment(
            self.task.id,
            self.task_status.id,
            self.person.id,
            "last comment"
        )
        tasks = self.get("/data/persons/%s/tasks" % self.person.id)
        self.assertEqual(len(tasks), 1)
        self.assertEqual(tasks[0]["last_comment"]["text"], "last comment")
        self.assertEqual(
            tasks[0]["last_comment"]["person_id"],
            str(self.person.id)
        )
        self.assertEquals(len(tasks), 1)
        self.assertTrue(str(self.person.id) in tasks[0]["assignees"])

        tasks = self.get("/data/persons/%s/tasks" % self.user.id)
        self.assertEquals(len(tasks), 0)
Beispiel #2
0
    def test_get_tasks_for_person(self):
        projects = [self.project.serialize()]
        tasks = tasks_service.get_person_tasks(self.user["id"], projects)
        self.assertEqual(len(tasks), 0)

        tasks_service.assign_task(self.task.id, self.user["id"])
        tasks = tasks_service.get_person_tasks(self.user["id"], projects)
        self.assertEqual(len(tasks), 1)

        tasks_service.create_comment(
            self.task.id,
            self.task_status.id,
            self.person.id,
            "first comment"
        )
        tasks_service.create_comment(
            self.task.id,
            self.task_status.id,
            self.person.id,
            "last comment"
        )
        tasks = tasks_service.get_person_tasks(self.person.id, projects)
        self.assertEqual(len(tasks), 2)
        self.assertEqual(tasks[1]["last_comment"]["text"], "last comment")
        self.assertEqual(
            tasks[1]["last_comment"]["person_id"],
            str(self.person.id)
        )
Beispiel #3
0
 def test_remove_task_force(self):
     tasks_service.create_comment(self.task.id, self.task_status.id,
                                  self.person.id, "first comment")
     TimeSpent.create(person_id=self.person.id,
                      task_id=self.task.id,
                      date=datetime.date(2017, 9, 23),
                      duration=3600)
     deletion_service.remove_task(self.task_id, force=True)
     self.assertRaises(TaskNotFoundException, tasks_service.get_task,
                       self.task_id)
Beispiel #4
0
    def post(self, task_id):
        (task_status_id, comment, person_id) = self.get_arguments()

        task = tasks_service.get_task(task_id)
        if not permissions.has_manager_permissions():
            user_service.check_assigned(task_id)

        task_status = tasks_service.get_task_status(task_status_id)

        if person_id:
            person = persons_service.get_person(person_id)
        else:
            person = persons_service.get_current_user()

        comment = tasks_service.create_comment(object_id=task_id,
                                               object_type="Task",
                                               task_status_id=task_status_id,
                                               person_id=person["id"],
                                               text=comment)

        status_changed = task_status_id != task["task_status_id"]

        tasks_service.update_task(task_id, {"task_status_id": task_status_id})

        notifications_service.create_notifications_for_task_and_comment(
            task, comment, change=status_changed)

        comment["task_status"] = task_status
        comment["person"] = person
        events.emit("comment:new", {"id": comment["id"]})
        return comment, 201
Beispiel #5
0
 def test_create_comment(self):
     comment = tasks_service.create_comment(
         self.task_id,
         self.task_status.id,
         self.person.id,
         "Test @John Doe"
     )
     self.assertEqual(comment["mentions"][0], str(self.person.id))
Beispiel #6
0
 def generate_fixture_comment(self, person=None):
     if person is None:
         person = self.person.serialize()
     self.comment = tasks_service.create_comment(self.task.id,
                                                 self.task_status.id,
                                                 person["id"],
                                                 "first comment")
     return self.comment
Beispiel #7
0
    def post(self, task_id):
        (task_status_id, comment, person_id) = self.get_arguments()

        task = tasks_service.get_task(task_id)
        user_service.check_project_access(task["project_id"])
        task_status = tasks_service.get_task_status(task_status_id)

        if person_id:
            person = persons_service.get_person(person_id)
        else:
            person = persons_service.get_current_user()

        comment = tasks_service.create_comment(
            object_id=task_id,
            object_type="Task",
            task_status_id=task_status_id,
            person_id=person["id"],
            text=comment,
        )

        status_changed = task_status_id != task["task_status_id"]
        new_data = {
            "task_status_id": task_status_id,
            "last_comment_date": comment["created_at"],
        }
        if status_changed:
            if task_status["is_retake"]:
                retake_count = task["retake_count"]
                if retake_count is None or retake_count == "NoneType":
                    retake_count = 0
                new_data["retake_count"] = retake_count + 1

            if task_status["is_done"]:
                new_data["end_date"] = datetime.datetime.now()
            else:
                new_data["end_date"] = None

            if (task_status["short_name"] == "wip"
                    and task["real_start_date"] is None):
                new_data["real_start_date"] = datetime.datetime.now()

        tasks_service.update_task(task_id, new_data)
        task = tasks_service.get_task_with_relations(task_id)

        notifications_service.create_notifications_for_task_and_comment(
            task, comment, change=status_changed)
        news_service.create_news_for_task_and_comment(task,
                                                      comment,
                                                      change=status_changed)

        comment["task_status"] = task_status
        comment["person"] = person
        return comment, 201
Beispiel #8
0
    def generate_fixture_comment(self):
        self.generate_fixture_person()
        self.generate_fixture_assigner()
        self.generate_fixture_department()
        self.generate_fixture_task_type()
        self.task_type_dict = self.task_type_animation.serialize()
        self.generate_fixture_task_status()
        self.task = self.generate_fixture_shot_task()
        self.task_dict = self.task.serialize()
        self.person_dict = self.generate_fixture_person(
            first_name="Jane", email="*****@*****.**").serialize()

        self.comment = tasks_service.create_comment(self.task.id,
                                                    self.task_status.id,
                                                    self.user["id"],
                                                    "first comment")
Beispiel #9
0
    def post(self, file_id):
        (
            task_status_id,  # NOT USED CURRENTLY
            comment,
            person_id,
            created_at,
            checklist) = self.get_arguments()

        output_file = files_service.get_output_file(file_id)

        # TODO: test and maybe check_asset_access
        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"])

        # TODO: improve this
        task_status = TaskStatus.get_by(short_name="wip")
        if not task_status:
            print("no task status")
            return None, 404
        task_status_id = task_status.id

        if not permissions.has_manager_permissions():
            person_id = None
            created_at = None

        if person_id:
            person = persons_service.get_person(person_id)
        else:
            person = persons_service.get_current_user()

        comment = tasks_service.create_comment(object_id=file_id,
                                               object_type="OutputFile",
                                               files=request.files,
                                               person_id=person["id"],
                                               task_status_id=task_status_id,
                                               text=comment,
                                               checklist=checklist,
                                               created_at=created_at)

        comment["task_status"] = task_status.serialize()
        comment["person"] = person
        return comment, 201
Beispiel #10
0
    def post(self, task_id):
        (
            task_status_id,
            comment,
            person_id
        ) = self.get_arguments()

        task = tasks_service.get_task(task_id)
        user_service.check_project_access(task["project_id"])

        task_status = tasks_service.get_task_status(task_status_id)

        if person_id:
            person = persons_service.get_person(person_id)
        else:
            person = persons_service.get_current_user()

        comment = tasks_service.create_comment(
            object_id=task_id,
            object_type="Task",
            task_status_id=task_status_id,
            person_id=person["id"],
            text=comment
        )

        status_changed = task_status_id != task["task_status_id"]

        tasks_service.update_task(
            task_id,
            {"task_status_id": task_status_id}
        )

        notifications_service.create_notifications_for_task_and_comment(
            task, comment, change=status_changed
        )

        comment["task_status"] = task_status
        comment["person"] = person
        return comment, 201
Beispiel #11
0
    def test_get_last_news_for_project(self):
        self.generate_fixture_comment()
        for i in range(1, 81):
            comment = tasks_service.create_comment(self.task.id,
                                                   self.task_status.id,
                                                   self.user["id"],
                                                   "comment %s" % i)
            news = news_service.create_news_for_task_and_comment(
                self.task_dict, comment)
        news_list = news_service.get_last_news_for_project(
            self.task_dict["project_id"])
        self.assertEquals(len(news_list), 50)
        news = news_list[0]
        self.assertEqual(news["project_name"], "Cosmos Landromat")
        self.assertEqual(news["full_entity_name"], "E01 / S01 / P01")
        self.assertEqual(news["project_id"], self.task_dict["project_id"])

        news_list = news_service.get_last_news_for_project(
            self.task_dict["project_id"], page=2)
        self.assertEquals(len(news_list), 30)

        news_list = news_service.get_last_news_for_project(
            self.task_dict["project_id"], news_id=news["id"])
        self.assertEquals(len(news_list), 1)
Beispiel #12
0
 def test_remove_task_force(self):
     tasks_service.create_comment(self.task.id, self.task_status.id,
                                  self.person.id, "first comment")
     tasks_service.remove_task(self.task_id, force=True)
     self.assertRaises(TaskNotFoundException, tasks_service.get_task,
                       self.task_id)
Beispiel #13
0
 def generate_fixture_comment(self):
     self.comment = tasks_service.create_comment(self.task.id,
                                                 self.task_status.id,
                                                 self.person.id,
                                                 "first comment")
     return self.comment
Beispiel #14
0
    def post(self, task_id):
        person_id = self.get_arguments()
        gunicorn_logger.log(logging.ERROR, task_id)
        gunicorn_logger.log(logging.ERROR, person_id)
        task = tasks_service.get_task(task_id)

        working_file_name = re.sub(
            r'_v\d\d\d.\w\w\w', '',
            file_tree_service.get_working_file_name(task))
        gunicorn_logger.log(logging.ERROR, working_file_name)
        next_revision = files_service.get_next_working_revision(
            task_id, working_file_name)
        working_file_path = file_tree_service.get_working_file_path(
            task, mode="working", revision=next_revision)
        working_file = files_service.create_new_working_revision(
            task_id, person_id, "edfd3a91-4d55-47a4-ae15-f2123c07edf6",
            working_file_name, working_file_path)
        comment = tasks_service.create_comment(
            task_id, '4f4256d0-72d9-4de5-bf71-a08209b56750', person_id,
            "Version %s created" % next_revision)
        preview_file = tasks_service.add_preview_file_to_comment(
            comment['id'], person_id, task_id, revision=next_revision)
        entities_service.update_entity_preview(task['entity_id'],
                                               preview_file['id'])

        output_preview_file_path = file_tree_service.get_working_file_path(
            task, mode="preview_output", revision=next_revision)
        output_slated_file_path = file_tree_service.get_working_file_path(
            task, mode="slated_output", revision=next_revision, frame="0001")

        movies_preview_file_path = '/opt/zou/previews/movies/previews/' + preview_file[
            'id'][:3] + '/' + preview_file['id'][3:6] + '/'
        pictures_original_file_path = '/opt/zou/previews/pictures/originals/' + preview_file[
            'id'][:3] + '/' + preview_file['id'][3:6] + '/'
        pictures_preview_file_path = '/opt/zou/previews/pictures/previews/' + preview_file[
            'id'][:3] + '/' + preview_file['id'][3:6] + '/'
        pictures_thumbnail_file_path = '/opt/zou/previews/pictures/thumbnails/' + preview_file[
            'id'][:3] + '/' + preview_file['id'][3:6] + '/'

        if not os.path.exists(movies_preview_file_path):
            os.makedirs(movies_preview_file_path)
        if not os.path.exists(pictures_original_file_path):
            os.makedirs(pictures_original_file_path)
        if not os.path.exists(pictures_preview_file_path):
            os.makedirs(pictures_preview_file_path)
        if not os.path.exists(pictures_thumbnail_file_path):
            os.makedirs(pictures_thumbnail_file_path)

        if not os.path.exists(os.path.dirname(working_file_path)):
            os.makedirs(os.path.dirname(working_file_path))
        file = open(working_file_path, "w")
        file.close()

        os.symlink(output_preview_file_path,
                   movies_preview_file_path + preview_file['id'])
        os.symlink(output_slated_file_path,
                   pictures_original_file_path + preview_file['id'])
        os.symlink(output_slated_file_path,
                   pictures_preview_file_path + preview_file['id'])
        os.symlink(output_slated_file_path,
                   pictures_thumbnail_file_path + preview_file['id'])

        return working_file, 200
Beispiel #15
0
    def post(self, task_id):
        (task_status_id, comment, person_id, created_at,
         checklist) = self.get_arguments()

        task = tasks_service.get_task(task_id)
        user_service.check_project_access(task["project_id"])
        user_service.check_entity_access(task["entity_id"])
        task_status = tasks_service.get_task_status(task_status_id)

        if not permissions.has_manager_permissions():
            person_id = None
            created_at = None

        if person_id:
            person = persons_service.get_person(person_id)
        else:
            person = persons_service.get_current_user()

        comment = tasks_service.create_comment(object_id=task_id,
                                               object_type="Task",
                                               files=request.files,
                                               person_id=person["id"],
                                               task_status_id=task_status_id,
                                               text=comment,
                                               checklist=checklist,
                                               created_at=created_at)

        status_changed = task_status_id != task["task_status_id"]
        new_data = {
            "task_status_id": task_status_id,
            "last_comment_date": comment["created_at"],
        }
        if status_changed:
            if task_status["is_retake"]:
                retake_count = task["retake_count"]
                if retake_count is None or retake_count == "NoneType":
                    retake_count = 0
                new_data["retake_count"] = retake_count + 1

            if task_status["is_done"]:
                new_data["end_date"] = datetime.datetime.now()
            else:
                new_data["end_date"] = None

            if (task_status["short_name"] == "wip"
                    and task["real_start_date"] is None):
                new_data["real_start_date"] = datetime.datetime.now()

        tasks_service.update_task(task_id, new_data)
        if status_changed:
            events.emit(
                "task:status-changed", {
                    "task_id": task_id,
                    "new_task_status_id": new_data["task_status_id"],
                    "previous_task_status_id": task["task_status_id"]
                })

        task = tasks_service.get_task_with_relations(task_id)

        notifications_service.create_notifications_for_task_and_comment(
            task, comment, change=status_changed)
        news_service.create_news_for_task_and_comment(task,
                                                      comment,
                                                      change=status_changed)

        comment["task_status"] = task_status
        comment["person"] = person
        return comment, 201