def ans_comment(request): if request.method == 'POST': response = {} r_html = {} r_elements = [] comment = request.POST['comment'] id = request.POST['id'] answer = Answer.objects.get(id=id) user = request.user c = Comments(answer=answer, comment=comment, user=user) c.save() create_notifications(from_user=user, to_user=answer.user, typ='C', answer=answer) r_elements = ['comments'] r_html['comments'] = render_to_string('snippets/comment.html', {'comment': c}) response['html'] = r_html response['elements'] = r_elements response['append'] = True return HttpResponse(json.dumps(response), content_type="application/json") else: print('problem hai')
def ques_comment(request): if request.method == 'POST': response = {} r_html = {} r_elements = [] user = request.user comment = request.POST['comment'] id = request.POST['id'] question = Question.objects.get(id=id) comment = Comments(question=question, user=user, comment=comment) comment.save() user.userprofile.notify_q_commented(question=question) create_notifications(from_user=user, to_user=question.user, typ='C', question=question) # also commented r_elements = ['comments'] r_html['comments'] = render_to_string('snippets/comment.html', {'comment': comment}) response['html'] = r_html response['elements'] = r_elements response['append'] = True return HttpResponse(json.dumps(response), content_type="application/json")
def ques_comment(request): if request.method == 'POST': response = {} r_html = {} r_elements = [] user = request.user comment = request.POST['comment'] id = request.POST['id'] question = Question.objects.get(id=id) comment = Comments(question=question, user=user, comment=comment) comment.save() user.userprofile.notify_q_commented(question=question) user.userprofile.notify_also_q_commented(question=question) r_elements = ['comments'] r_html['comments'] = render_to_string('snippets/comment.html', {'comment':comment}) response['html'] = r_html response['elements'] = r_elements response['prepend'] = True return HttpResponse(json.dumps(response), content_type="application/json")
def ans_comment(request): if request.method == 'POST': response = {} r_html = {} r_elements = [] comment = request.POST['comment'] id = request.POST['id'] answer = Answer.objects.get(id=id) user = request.user c = Comments(answer=answer, comment=comment, user=user) c.save() create_notifications(from_user=user, to_user=answer.user, typ='C', answer=answer) r_elements = ['comments'] r_html['comments'] = render_to_string('snippets/comment.html', {'comment':c}) response['html'] = r_html response['elements'] = r_elements response['append'] = True return HttpResponse(json.dumps(response), content_type="application/json") else: print('problem hai')