def post(request, articleID): article = get_object_or_404(Article, pk=articleID) if request.method == 'POST': form = CommentForm(request.POST) if form.is_valid(): post = form.save(commit=False) post.owner = request.user post.save() article.comments.add(post) #add follower add_follower(article, request.user) #add following add_following(article, request.user) #Send email to buyer or followers send_mail(article, request.user, post) #html content for http response html_content = "<div class='question group'>" +\ "<div class='question-profile-picture width-10 float-left'>" +\ "<div class='container padding-0_5em'>" +\ "<img class='width-100' src='%s'/>" % (post.owner.profile.get_profile_picture()) +\ "</div>" +\ "</div>" +\ "<div class='question-content width-90 float-right'>" +\ "<div class='container padding-0_5em'>" +\ "<div class='question-user-name'>" +\ "<a class='strong attention' href='#'>%s</a>" % (post.owner) +\ "</div>" +\ "<div class='question-info'>" +\ "%s" % (post.comment) +\ "</div>" +\ "<div class='question-published text-align-right'>" +\ "hace %s" % (post.get_timestamp()) +\ "</div>" +\ "</div>" +\ "</div>" +\ "</div>" return HttpResponse(html_content)
def follow(request, articleID): article = get_object_or_404(Article, pk=articleID) add_following(article,request.user) return HttpResponse(json.dumps({'response' : 'siguiendo'}))
def follow(request, articleID): article = get_object_or_404(Article, pk=articleID) add_following(article, request.user) return HttpResponse(json.dumps({'response': 'siguiendo'}))