def get_units(request):
"""Based on the vector of uids and the vector of header uids,
return a dictionary of lightweight results for the view rows.
:return: A JSON-encoded string containing the dictionary
"""
form = UnitViewRowsForm(request.GET, user=request.user)
if not form.is_valid():
errors = form.errors.as_data()
if 'uids' in errors:
for error in errors['uids']:
if error.code in ['invalid', 'required']:
raise Http400(error.message)
raise Http404(forms.ValidationError(form.errors).messages)
units = search_backend.get(Unit)(
request.user, **form.cleaned_data
).get_units()
return JsonResponse(ViewRowResults(units, form.cleaned_data['headers']).data)
评论列表
文章目录