def function_wrapper(request, pk, **kwargs): # noqa Z430 try: workflow = access( request, wid=kwargs.get('wid'), select_related=s_related, prefetch_related=pf_related, ) except Exception as exc: messages.error(request, str(exc)) workflow = None if not workflow: if request.is_ajax(): return JsonResponse({'html_redirect': reverse('home')}) return redirect('home') # Update the session store_workflow_in_session(request, workflow) kwargs['workflow'] = workflow if workflow.nrows == 0: messages.error( request, _('Workflow has no data. ' + 'Go to "Manage table data" to upload data.'), ) if request.is_ajax(): return JsonResponse( {'html_redirect': reverse('action:index')}) return redirect(reverse('action:index')) if not kwargs.get('condition'): # Get the condition condition = Condition.objects.filter(pk=pk).filter( Q(action__workflow__user=request.user) | Q(action__workflow__shared=request.user), action__workflow=workflow, ) if is_filter is not None: condition = condition.filter(is_filter=is_filter) # Get the condition condition = condition.select_related('action').first() if not condition: if request.is_ajax(): return JsonResponse({'html_redirect': reverse('home')}) return redirect('home') kwargs['condition'] = condition return func(request, pk, **kwargs)
def function_wrapper(request, **kwargs): # noqa Z430 try: workflow = access( request, wid=kwargs.get('wid'), select_related=s_related, prefetch_related=pf_related, ) except Exception as exc: messages.error(request, str(exc)) workflow = None if not workflow: if request.is_ajax(): return JsonResponse({'html_redirect': reverse('home')}) return redirect('home') # Update the session store_workflow_in_session(request, workflow) kwargs['workflow'] = workflow return func(request, **kwargs)