def add_metadata_descriptor(project_id, entity_type, name, choices, for_client, departments=[]): if not departments: departments = [] try: departments_objects = [ Department.get(department_id) for department_id in departments if department_id is not None ] except StatementError: raise DepartmentNotFoundException() descriptor = MetadataDescriptor.create( project_id=project_id, entity_type=entity_type, name=name, choices=choices, for_client=for_client, departments=departments_objects, field_name=slugify.slugify(name, separator="_"), ) events.emit( "metadata-descriptor:new", {"metadata_descriptor_id": str(descriptor.id)}, project_id=project_id, ) clear_project_cache(project_id) return descriptor.serialize()
def generate_fixture_metadata_descriptor(self, entity_type="Asset"): self.meta_descriptor = MetadataDescriptor.create( project_id=self.project.id, name="Contractor", field_name="contractor", choices=["value 1", "value 2"], entity_type=entity_type) return self.meta_descriptor
def add_metadata_descriptor(project_id, entity_type, name, choices): descriptor = MetadataDescriptor.create(project_id=project_id, entity_type=entity_type, name=name, choices=choices, field_name=slugify.slugify( name, separator="_")) events.emit("metadata-descriptor:new", {"descriptor_id": str(descriptor.id)}) return descriptor.serialize()
def test_export_with_metadata(self): MetadataDescriptor.create( project_id=self.project.id, name="Start frame", field_name="start_frame", choices=["0", "100"], entity_type="Edit", ) self.edit.update( { "data": { "start_frame": "100", } } ) csv_edits = self.get_raw( "/export/csv/projects/%s/edits.csv" % self.project.id ) expected_result = """Project;Episode;Name;Description;Time Spent;Start frame;Edit\r Cosmos Landromat;E01;Edit;Description of the Edit;0.21;100;opn\r\n""" self.assertEqual(csv_edits, expected_result)