示例#1
0
def add_task_type_setting(project_id, task_type_id, priority=None):
    """
    Add a task type listed in database to the the project task types.
    """
    ProjectTaskTypeLink.create(task_type_id=task_type_id,
                               project_id=project_id,
                               priority=priority)
    return _save_project(get_project_raw(project_id))
示例#2
0
    def test_import_assets(self):
        self.assertEqual(len(Task.query.all()), 0)
        number_of_task_per_entity_to_create = len(
            TaskType.query.filter_by(for_shots=False).all())
        db.session.add(
            ProjectTaskTypeLink(project_id=self.project_id,
                                task_type_id=self.task_type.id))
        db.session.add(
            ProjectTaskTypeLink(
                project_id=self.project_id,
                task_type_id=self.task_type_layout.id,
            ))
        db.session.add(
            ProjectTaskTypeLink(
                project_id=self.project_id,
                task_type_id=self.task_type_animation.id,
            ))
        db.session.commit()
        self.assertEqual(number_of_task_per_entity_to_create, 1)
        path = "/import/csv/projects/%s/assets" % self.project.id

        file_path_fixture = self.get_fixture_file_path(
            os.path.join("csv", "assets.csv"))
        self.upload_file(path, file_path_fixture)

        entities = Entity.query.all()
        self.assertEqual(len(entities), 3)

        entity_types = EntityType.query.all()
        self.assertEqual(len(entity_types), 2)

        tasks = Task.query.all()
        self.assertEqual(
            len(tasks),
            number_of_task_per_entity_to_create * len(entities),
        )

        asset = entities[0]
        self.assertEqual(asset.data.get("contractor", None), "contractor 1")

        task = tasks[0]
        self.assertEqual(task.entity_id, asset.id)

        file_path_fixture = self.get_fixture_file_path(
            os.path.join("csv", "assets_no_metadata.csv"))
        self.upload_file("%s?update=true" % path, file_path_fixture)

        entities = Entity.query.all()
        self.assertEqual(len(entities), 3)

        asset = entities[0]
        self.assertEqual(asset.data.get("contractor", None), "contractor 1")
示例#3
0
    def test_import_shots(self):
        self.assertEqual(len(Task.query.all()), 0)
        db.session.add(
            ProjectTaskTypeLink(project_id=self.project_id,
                                task_type_id=self.task_type.id))
        db.session.add(
            ProjectTaskTypeLink(
                project_id=self.project_id,
                task_type_id=self.task_type_layout.id,
            ))
        path = "/import/csv/projects/%s/shots" % self.project.id
        self.project.update({"production_type": "tvshow"})

        file_path_fixture = self.get_fixture_file_path(
            os.path.join("csv", "shots.csv"))
        self.upload_file(path, file_path_fixture)

        sequences = shots_service.get_sequences()
        self.assertEqual(len(sequences), 3)
        shots = shots_service.get_shots()
        self.assertEqual(len(shots), 4)

        entity_types = EntityType.query.all()
        self.assertEqual(len(entity_types), 3)

        tasks = Task.query.all()
        self.assertEqual(
            len(tasks),
            len(shots),
        )

        shot = shots[0]
        self.assertEqual(shot["data"].get("contractor", None), "contractor 1")

        self.assertEqual(
            set(str(task.entity_id) for task in tasks),
            set(shot["id"] for shot in shots),
        )

        file_path_fixture = self.get_fixture_file_path(
            os.path.join("csv", "shots_no_metadata.csv"))
        self.upload_file("%s?update=true" % path, file_path_fixture)

        shots = shots_service.get_shots()
        self.assertEqual(len(shots), 4)

        entity_types = EntityType.query.all()
        self.assertEqual(len(entity_types), 3)

        shot = shots[0]
        self.assertEqual(shot["data"].get("contractor", None), "contractor 1")
示例#4
0
def create_project_task_type_link(project_id, task_type_id, priority):
    task_type_link = ProjectTaskTypeLink.get_by(project_id=project_id,
                                                task_type_id=task_type_id)

    if priority is not None:
        priority = int(priority)

    if task_type_link is None:
        task_type_link = ProjectTaskTypeLink.create(project_id=project_id,
                                                    task_type_id=task_type_id,
                                                    priority=priority)
    else:
        task_type_link.update({"priority": priority})

    return task_type_link.serialize()
示例#5
0
def create_or_update_projecttasktypelink(project_id, task_type_id, priority):
    task_type_link = ProjectTaskTypeLink.query.filter_by(
        project_id=project_id, task_type_id=task_type_id).first()

    if task_type_link is None:
        task_type_link = ProjectTaskTypeLink(
            project_id=project_id,
            task_type_id=task_type_id,
        )

    if priority is not None:
        priority = int(priority)

    task_type_link.update({"priority": priority})

    return task_type_link
示例#6
0
def add_task_type_setting(project_id, task_type_id, priority=None):
    """
    Add a task type listed in database to the the project task types.
    """
    link = ProjectTaskTypeLink(task_type_id=task_type_id,
                               project_id=project_id,
                               priority=priority)
    db.session.add(link)
    db.session.commit()
    return _save_project(get_project_raw(project_id))