Esempio n. 1
0
def _ignore(request):
    question_id = request.GET["question_id"]
    question = Question.objects.get(pk=question_id)
    try:
        ignore = Ignored.objects.get(question=question, user=request.user)
    except:
        ignore = Ignored(user=request.user, question=question)
        ignore.save()

    data = {"status": "success"}
    return JsonResponse(data)
Esempio n. 2
0
def api_poll_ignore(request):
    api_result = {"api": "poll_ignore", "status": "success"}
    try:
        token = request.GET["token"]
        user = get_user_from_token(token)
        if not user:
            api_result["status"] = "failure"
            api_result["error"] = "user not found"
        else:
            ignore_id = request.GET["id"]
            question = Question.objects.get(pk=ignore_id)
            try:
                ignore = Ignored.objects.get(question=question, user=user)
            except:
                ignore = Ignored(user=user, question=question)
                ignore.save()
    except Exception as e:
        api_result["status"] = "failure"
        api_result["error"] = e.message
        pass

    return JsonResponse(api_result)