def save_version_if_needed(self, shot, previous_shot): previous_data = previous_shot.get("data", {}) or {} data = shot.get("data", {}) frame_in = data.get("frame_in", 0) pframe_in = previous_data.get("frame_in", 0) frame_out = data.get("frame_in", 0) pframe_out = previous_data.get("frame_in", 0) name = data.get("name", "") pname = previous_shot["name"] version = None if frame_in != pframe_in or frame_out != pframe_out or name != pname: current_user_id = persons_service.get_current_user()["id"] previous_updated_at = fields.get_date_object( previous_shot["updated_at"], date_format="%Y-%m-%dT%H:%M:%S" ) updated_at = fields.get_date_object( shot["updated_at"], date_format="%Y-%m-%dT%H:%M:%S" ) if ( date_helpers.get_date_diff(previous_updated_at, updated_at) > 60 ): version = EntityVersion.create( entity_id=shot["id"], name=pname, data=shot["data"], person_id=current_user_id, ) return version
def save_version_if_needed(self, shot, previous_shot): previous_data = previous_shot.get("data", {}) or {} data = shot.get("data", {}) frame_in = data.get("frame_in", 0) pframe_in = previous_data.get("frame_in", 0) frame_out = data.get("frame_in", 0) pframe_out = previous_data.get("frame_in", 0) name = data.get("name", "") pname = previous_shot["name"] version = None if frame_in != pframe_in or frame_out != pframe_out or name != pname: version = EntityVersion.create( entity_id=shot["id"], name=pname, data=previous_data ) return version