views.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:zing 作者: evernote 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号