def after_charac_value_saved(instance, update_fields, **kwargs): # pylint: disable=W0613 """ Calculates the value of CharacteristicValues and updates the Plot sessions. Called via the post_saved signal """ if not update_fields or 'measurements' in update_fields: _ = instance.value update_plot_sessions()
def recalculate_progress(request): """ Ajax request to get the progress of the calculation """ if request.is_ajax() and request.method == 'POST' and \ request.POST['start_num']: num_invalid_val = __get_invalid_values(request).count_invalid() start_num = int(request.POST['start_num']) progress = int((start_num - num_invalid_val) * 100.0 / start_num) finished = num_invalid_val == 0 if finished: update_plot_sessions() return JsonResponse( {'progress': str(progress), 'remaining': str(num_invalid_val), 'finished': finished}) return JsonResponse({'progress': '0', 'remaining': '0', 'finished': True})