def getEntity(entityType=None, entityId=None): if entityType is None or entityId is None: return None if entityType == 'user': return ftrack.User(entityId) if entityType == 'show': return ftrack.Project(entityId) elif entityType == 'task': return ftrack.Task(entityId) elif entityType == 'list': return ftrack.List(entityId) elif entityType == 'reviewsession': return ftrack.ReviewSession(entityId) else: return None
def launch(self, event): data = event["data"] selection = data.get("selection", []) session = ftrack.ReviewSession(selection[0]["entityId"]) objs = session.getObjects() sort_start = objs[0].get("sort_order") names = {} for obj in objs: names[obj.get("name")] = obj if sort_start > obj.get("sort_order"): sort_start = obj.get("sort_order") names_sorted = sorted(names) for key in names_sorted: order = sort_start + names_sorted.index(key) names[key].set("sort_order", order) return {"success": True, "message": "Review sorted!"}
def launch(self, event): data = event['data'] selection = data.get('selection', []) session = ftrack.ReviewSession(selection[0]['entityId']) objs = session.getObjects() sort_start = objs[0].get('sort_order') names = {} for obj in objs: names[obj.get('name')] = obj if sort_start > obj.get('sort_order'): sort_start = obj.get('sort_order') names_sorted = sorted(names) for key in names_sorted: order = sort_start + names_sorted.index(key) names[key].set('sort_order', order) return {'success': True, 'message': 'Client Review sorted!'}
def generate_feedback(self, event): data = event["data"] selection = data.get("selection", []) session = ftrack.ReviewSession(selection[0]["entityId"]) invitees = {} for invite in session.getInvitees(): invitees[invite.get("id")] = invite.get("name") session_objects = {} for obj in session.getObjects(): notes = {"frames": [], "non_frame": []} for note in obj.getNotes(): meta = note.getMeta() data = { "text": note.get("text"), "invitee": invitees[meta["inviteeId"]], "replies": [] } for reply in note.getNotes(): data["replies"].append(reply) if "reviewFrame" in note.getMeta(): frame_number = json.loads(meta["reviewFrame"])["number"] notes["frames"].append(frame_number) if str(frame_number) in notes: notes[str(frame_number)].append(data) else: notes[str(frame_number)] = [data] else: notes["non_frame"].append(data) session_objects[obj.get("name")] = notes text = "" for obj in session_objects: text += obj + ":\n\n\n" frames = list(set(session_objects[obj]["frames"])) frames.sort() for frame in frames: text += "Frame: %s " % str(frame) + "-" * 50 + "\n\n" for note in session_objects[obj][str(frame)]: text += note["invitee"] + ":\n" text += note["text"] + "\n" for reply in note["replies"]: text += "\n" text += invitees[reply.getMeta()["inviteeId"]] + ":\n" text += reply.get("text") + "\n" text += "\n" text += "\n\n" text += "-" * 50 f = os.path.join(tempfile.gettempdir(), str(uuid.uuid4()) + ".txt") with open(f, "w") as temp_file: temp_file.write(text) return f
def getEntity(entityType=None, entityId=None): if entityType is None or entityId is None: return None return ftrack.ReviewSession(entityId)