示例#1
0
 def test_create_asset(self):
     events.register(
         "asset:new",
         "handle_event",
         self
     )
     self.asset_data = {
         "name": "car",
         "description": "Test description",
         "data": {"extra": "test extra"}
     }
     path = "data/projects/%s/asset-types/%s/assets/new" % (
         self.project.id,
         self.entity_type.id
     )
     asset = self.post(path, self.asset_data)
     assets = assets_service.get_assets()
     self.assertIsNotNone(asset.get("id", None))
     self.assertEquals(len(assets), 1)
     self.assertEquals(
         assets[0]["name"],
         self.asset_data["name"]
     )
     self.assertEquals(
         assets[0]["description"],
         self.asset_data["description"]
     )
     self.assertDictEqual(
         assets[0]["data"],
         self.asset_data["data"]
     )
示例#2
0
文件: resources.py 项目: cgwire/zou
 def get(self, project_id, asset_type_id):
     """
     Retrieve all assets for given project and entity type.
     ---
     tags:
         - Assets
     parameters:
       - in: path
         name: project_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
       - in: path
         name: asset_type_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25        
     responses:
         200:
             description: All assets for given project and entity type    
     """
     user_service.check_project_access(project_id)
     criterions = query.get_query_criterions_from_request(request)
     criterions["project_id"] = project_id
     criterions["entity_type_id"] = asset_type_id
     if permissions.has_vendor_permissions():
         criterions["assigned_to"] = persons_service.get_current_user(
         )["id"]
     return assets_service.get_assets(criterions)
示例#3
0
文件: casting.py 项目: withgame/zou
    def prepare_import(self, project_id):
        self.asset_type_map = {}
        self.asset_map = {}
        self.episode_map = {}
        self.sequence_map = {}
        self.shot_map = {}

        asset_types = assets_service.get_asset_types()
        for asset_type in asset_types:
            self.asset_type_map[asset_type["id"]] = slugify(asset_type["name"])

        assets = assets_service.get_assets({"project_id": project_id})
        for asset in assets:
            key = self.get_asset_key(asset)
            self.asset_map[key] = asset["id"]

        episodes = shots_service.get_episodes({"project_id": project_id})
        for episode in episodes:
            self.episode_map[episode["id"]] = slugify(episode["name"])

        sequences = shots_service.get_sequences({"project_id": project_id})
        for sequence in sequences:
            key = self.get_sequence_key(sequence)
            self.sequence_map[sequence["id"]] = key

        shots = shots_service.get_shots({"project_id": project_id})
        for shot in shots:
            key = self.get_shot_key(shot)
            self.shot_map[key] = shot["id"]
示例#4
0
    def test_import_task(self):
        self.load_task()
        self.assertEqual(len(self.tasks), 1)

        self.tasks = self.get("data/tasks")
        self.assertEqual(len(self.tasks), 1)

        task = self.tasks[0]
        task = tasks_service.get_task_with_relations(task["id"])
        project = Project.get_by(name=self.sg_task["project"]["name"])
        task_type = \
            TaskType.get_by(name=self.sg_task["step"]["name"])
        task_status = TaskStatus.get_by(
            short_name=self.sg_task["sg_status_list"])
        assets = assets_service.get_assets(
            {"shotgun_id": self.sg_task["entity"]["id"]})
        entity = assets[0]
        assigner = Person.get_by(
            last_name=self.sg_task["created_by"]["name"].split(" ")[1])
        assignee = Person.get_by(
            last_name=self.sg_task["task_assignees"][0]["name"].split(" ")[1])

        self.assertEqual(task["name"], self.sg_task["cached_display_name"])
        self.assertEqual(task["duration"], self.sg_task["duration"])
        self.assertEqual(task["shotgun_id"], self.sg_task["id"])
        self.assertEqual(task["project_id"], str(project.id))
        self.assertEqual(task["task_type_id"], str(task_type.id))
        self.assertEqual(task["task_status_id"], str(task_status.id))
        self.assertEqual(task["entity_id"], entity["id"])
        self.assertEqual(task["assigner_id"], str(assigner.id))
        self.assertEqual(task["assignees"][0], str(assignee.id))
示例#5
0
 def get(self, project_id):
     """
     Retrieve all assets for given project.
     """
     user_service.check_project_access(project_id)
     criterions = query.get_query_criterions_from_request(request)
     criterions["project_id"] = project_id
     return assets_service.get_assets(criterions)
示例#6
0
 def test_remove_asset(self):
     self.generate_fixture_asset_types()
     self.generate_fixture_asset_character()
     path = "data/assets/%s" % self.asset_character.id
     self.delete(path)
     assets = assets_service.get_assets()
     self.assertEquals(len(assets), 1)
     self.get(path, 404)
示例#7
0
 def get(self):
     """
     Retrieve all entities that are not shot or sequence.
     Adds project name and asset type name.
     """
     criterions = query.get_query_criterions_from_request(request)
     user_service.check_project_access(criterions.get("project_id", None))
     return assets_service.get_assets(criterions)
示例#8
0
 def post(self, task_type_id):
     permissions.check_manager_permissions()
     criterions = query.get_query_criterions_from_request(request)
     assets = assets_service.get_assets(criterions)
     task_type = tasks_service.get_task_type(task_type_id)
     tasks = [
         tasks_service.create_task(task_type, asset) for asset in assets
     ]
     return tasks, 201
示例#9
0
 def get(self, project_id):
     """
     Retrieve all assets for given project.
     """
     if not permissions.has_manager_permissions():
         user_service.check_has_task_related(project_id)
     criterions = query.get_query_criterions_from_request(request)
     criterions["project_id"] = project_id
     assets = assets_service.get_assets(criterions)
     return assets
示例#10
0
文件: resources.py 项目: withgame/zou
 def get(self):
     """
     Retrieve all entities that are not shot or sequence.
     Adds project name and asset type name.
     """
     criterions = query.get_query_criterions_from_request(request)
     user_service.check_project_access(criterions.get("project_id", None))
     if permissions.has_vendor_permissions():
         criterions["assigned_to"] = persons_service.get_current_user(
         )["id"]
     return assets_service.get_assets(criterions)
示例#11
0
文件: resources.py 项目: withgame/zou
 def get(self, project_id):
     """
     Retrieve all assets for given project.
     """
     user_service.check_project_access(project_id)
     criterions = query.get_query_criterions_from_request(request)
     criterions["project_id"] = project_id
     if permissions.has_vendor_permissions():
         criterions["assigned_to"] = persons_service.get_current_user(
         )["id"]
     return assets_service.get_assets(criterions)
示例#12
0
    def post(self, task_type_id):
        criterions = query.get_query_criterions_from_request(request)
        if "project_id" not in criterions:
            return {"error": True, "message": "Project ID is missing"}, 400

        user_service.check_manager_project_access(criterions["project_id"])
        assets = assets_service.get_assets(criterions)
        task_type = tasks_service.get_task_type(task_type_id)
        tasks = [
            tasks_service.create_task(task_type, asset) for asset in assets
        ]
        return tasks, 201
示例#13
0
 def test_remove_asset_with_tasks(self):
     self.generate_fixture_entity()
     self.generate_fixture_person()
     self.generate_fixture_assigner()
     self.generate_fixture_department()
     self.generate_fixture_task_type()
     self.generate_fixture_task_status()
     self.generate_fixture_task()
     path = "data/assets/%s" % self.entity.id
     self.delete(path)
     assets = assets_service.get_assets()
     self.assertEquals(len(assets), 1)
     self.assertEquals(assets[0]["canceled"], True)
示例#14
0
文件: resources.py 项目: cgwire/zou
 def get(self):
     """
     Retrieve all entities that are not shot or sequence.
     Adds project name and asset type name.
     ---
     tags:
       - Assets
     responses:
       200:
         description: All assets
     """
     criterions = query.get_query_criterions_from_request(request)
     check_criterion_access(criterions)
     if permissions.has_vendor_permissions():
         criterions["assigned_to"] = persons_service.get_current_user(
         )["id"]
     return assets_service.get_assets(criterions)
示例#15
0
    def post(self, project_id, task_type_id):
        user_service.check_manager_project_access(project_id)
        task_type = tasks_service.get_task_type(task_type_id)

        asset_ids = request.json
        assets = []
        if type(asset_ids) == list and len(asset_ids) > 0:
            for asset_id in asset_ids:
                asset = assets_service.get_asset(asset_id)
                if asset["project_id"] == project_id:
                    assets.append(asset)
        else:
            criterions = query.get_query_criterions_from_request(request)
            criterions["project_id"] = project_id
            assets = assets_service.get_assets(criterions)

        tasks = tasks_service.create_tasks(task_type, assets)
        return tasks, 201
示例#16
0
    def prepare_import(self, project_id, task_type_id, episode_id=None):
        self.organisation = Organisation.query.first()
        self.assets_map = {}
        self.shots_map = {}
        self.tasks_map = {}

        asset_types_map = {}
        asset_types = assets_service.get_asset_types_for_project(project_id)
        for asset_type in asset_types:
            asset_types_map[asset_type["id"]] = slugify(asset_type["name"])

        criterions_assets = {"project_id": project_id}
        if episode_id is not None and episode_id not in ["main", "all"]:
            criterions_assets["source_id"] = episode_id
        assets = assets_service.get_assets(criterions_assets)
        for asset in assets:
            key = "%s%s" % (
                asset_types_map[asset["entity_type_id"]],
                slugify(asset["name"]),
            )
            self.assets_map[key] = asset["id"]

        sequences_map = {}
        criterions_sequences = {"project_id": project_id}
        if episode_id is not None and episode_id not in ["main", "all"]:
            criterions_sequences["parent_id"] = episode_id
        sequences = shots_service.get_sequences(criterions_sequences)
        for sequence in sequences:
            sequences_map[sequence["id"]] = slugify(sequence["name"])

        shots = shots_service.get_shots({"project_id": project_id})
        for shot in shots:
            sequence_key = sequences_map.get(shot["parent_id"])
            if sequence_key is not None:
                key = "%s%s" % (sequence_key, slugify(shot["name"]))
                self.shots_map[key] = shot["id"]

        for task in tasks_service.get_tasks_for_project_and_task_type(
                project_id, task_type_id):
            self.tasks_map[task["entity_id"]] = task["id"]
示例#17
0
    def post(self, project_id, task_type_id):
        """
        Create a new task for given asset and task type.
        ---
        tags:
        - Tasks
        parameters:
          - in: path
            name: project_id
            required: True
            schema:
                type: UUID
                example: a24a6ea4-ce75-4665-a070-57453082c25
          - in: path
            name: task_type_id
            required: True
            schema:
                type: UUID
                example: a24a6ea4-ce75-4665-a070-57453082c25
        responses:
            201:
                description: New task for given asset and task type created
        """
        user_service.check_manager_project_access(project_id)
        task_type = tasks_service.get_task_type(task_type_id)

        asset_ids = request.json
        assets = []
        if type(asset_ids) == list and len(asset_ids) > 0:
            for asset_id in asset_ids:
                asset = assets_service.get_asset(asset_id)
                if asset["project_id"] == project_id:
                    assets.append(asset)
        else:
            criterions = query.get_query_criterions_from_request(request)
            criterions["project_id"] = project_id
            assets = assets_service.get_assets(criterions)

        tasks = tasks_service.create_tasks(task_type, assets)
        return tasks, 201
示例#18
0
 def test_get_assets(self):
     assets = assets_service.get_assets()
     self.assertEqual(len(assets), 1)
     self.assertEqual(assets[0]["name"], "Tree")
示例#19
0
 def test_remove_asset(self):
     self.generate_fixture_entity()
     path = "data/assets/%s" % self.entity.id
     self.delete(path)
     assets = assets_service.get_assets()
     self.assertEquals(len(assets), 0)
示例#20
0
 def test_remove_asset_with_tasks(self):
     path = "data/assets/%s" % self.asset_dict["id"]
     self.delete(path)
     assets = assets_service.get_assets()
     self.assertEquals(len(assets), 1)
     self.assertEquals(assets[0]["canceled"], True)