views.py 文件源码

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

项目:valentina 作者: valentinavc 项目源码 文件源码
def chat_preferences(request):

    # abort if invalid request
    should_abort = _should_abort(request, ['POST'])
    if should_abort:
        return should_abort

    form = ChatPreferencesForm(request.POST)
    if not form.is_valid():
        return JsonResponse({'error': form.errors}, status=400)

    pk = Affiliation.get_id_from_hash(form.cleaned_data.get('key'))
    affiliation = get_object_or_404(Affiliation, pk=pk, user=request.user)
    affiliation.active = form.cleaned_data.get('active')
    affiliation.save()
    return JsonResponse(_affiliation_to_dict(affiliation))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号