@ajax_required
def get_units(request, **kwargs_):
 search_form = UnitSearchForm(request.GET, user=request.user)
 if (not search_form.is_valid()):
  errors = search_form.errors.as_data()
  if ('path' in errors):
   for error in errors['path']:
    if (error.code == 'max_length'):
     raise Http400(_('Path too long.'))
    elif (error.code == 'required'):
     raise Http400(_('Arguments missing.'))
  raise Http404(forms.ValidationError(search_form.errors).messages)
 (total, start, end, units_qs) = search_backend.get(Unit)(request.user, **search_form.cleaned_data).search()
 return JsonResponse({'start': start, 'end': end, 'total': total, 'unitGroups': GroupedResults(units_qs).data})

@ ajax_required def get_units ( request , ** kwargs_ ) : search_form = UnitSearchForm ( request . GET , user = request . user ) if ( not search_form . is_valid ( ) ) : errors = search_form . errors . as_data ( ) if ( 'path' in errors ) : for error in errors [ 'path' ] : if ( error . code == 'max_length' ) : raise Http400 ( _ ( 'Path too long.' ) ) elif ( error . code == 'required' ) : raise Http400 ( _ ( 'Arguments missing.' ) ) raise Http404 ( forms . ValidationError ( search_form . errors ) . messages ) ( total , start , end , units_qs ) = search_backend . get ( Unit ) ( request . user , ** search_form . cleaned_data ) . search ( ) return JsonResponse ( { 'start' : start , 'end' : end , 'total' : total , 'unitGroups' : GroupedResults ( units_qs ) . data } )
gets source and target texts and its metadata .