def api_transform_profile_id_delete(id=None, auth_user=None, api_core=None, request=None): u"""Delete a transformation profile.""" profile = api_core.get_transform_profile(spec={u'_id': id}) if not profile: raise IndexError(to_bytes(u'No transformation profile with id {0}.'.format(id))) api_core.delete_transform_profile(profile) return ok_200(u'The transformation profile "{0}" has been deleted.'.format(profile.title), include_properties=False)
def view_transform_profiles_delete(request, id): u"""Delete a transformation profile.""" try: profile = api_core.get_transform_profile(spec={u'_id': id}) if not profile: return {u'errors': [u'No transformation profile with id {0}.'.format(id)]} api_core.delete_transform_profile(profile) return {u'infos': [u'The transformation profile "{0}" has been deleted.'.format(profile.title)]} except Exception as e: logging.exception(e) return {u'errors': [unicode(e)]}
def view_transform_tasks_list(request): u"""Show the transformation tasks list page.""" try: data = get_request_data(request, accepted_keys=api_core.db_find_keys, qs_only_first_value=True, optional=True) tasks = remove_underscores(api_core.get_transform_tasks(**data)) data.setdefault(u'skip', 50) # ask for the last 50 media assets if skip is not provided for task in tasks: task.profile = remove_underscores(api_core.get_transform_profile(spec={u'_id': task.profile_id})) task.media_in = remove_underscores(api_core.get_media(spec={u'_id': task.media_in_id})) task.media_out = remove_underscores(api_core.get_media(spec={u'_id': task.media_out_id})) task.statistic[u'elapsed_time'] = secs_to_time(task.statistic.get(u'elapsed_time', 0)).strftime(u'%H:%M:%S') task.statistic[u'eta_time'] = secs_to_time(task.statistic.get(u'eta_time', 0)).strftime(u'%H:%M:%S') return {u'tasks': tasks, u'refresh_rate': 5} except Exception as e: logging.exception(e) return {u'errors': [unicode(e)], u'refresh_rate': 30}
def api_transform_profile_id_get(id=None, auth_user=None, api_core=None, request=None): u"""Return a transformation profile serialized to JSON.""" profile = api_core.get_transform_profile(spec={u'_id': id}) if not profile: raise IndexError(to_bytes(u'No transformation profile with id {0}.'.format(id))) return ok_200(profile, include_properties=True)