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))
评论列表
文章目录