def post(self,request): if "postid" in request.POST and "email" in request.session: postid = request.POST['postid'] comments = request.POST['comment'] user = MyUeers.objects.get(email=request.session.get("email")) data = [] if user: comment_d = Comment() comment_d.comment = comments comment_d.userid = user.pk comment_d.contentid = int(postid) comment_d.save() data = { 'name': user.first_name, "photo" : user.photo, 'comment': comment_d.comment, "usrid" : user.pk, "date" :comment_d.pub_date, "email" : user.email, 'response': "sussecsful" } return render(request,"dashboard/comment.html",{"comment": data})
def send(request): error = "error" if "email" in request.session and request.method in "POST" and "userid" \ in request.POST and "comment" in request.POST and "bookid" in request.POST: userid = request.POST['userid'] user = MyUeers.objects.get(pk=int(userid)) email = user.email comment = request.POST["comment"] bookid = request.POST["bookid"] if comment != "" and request.session["email"] == email: comment_d = Comment() comment_d.comment = comment comment_d.userid = int(userid) comment_d.contentid = int(bookid) comment_d.save() return render(request,"mobile/dashboard/load/commet.html",{"comment" : comment_d,"userdata" : user}) error = json.dumps({'comment': comment,'email': email}) return HttpResponse(error)
def add_comment (request, comment_id): comment = Comment () comment.id_blog = BlogRecord (id = int (comment_id) ) comment.name = request.GET[u'name'] comment.comment = request.GET[u'comment'] comment.save () return HttpResponse ('<div style = "color: green">Comment add!</div>')
def responses_to_comments(): for pk, fields in respuestas.iteritems(): c = Comment() c.comment = fields['content'] c.published = True c.content_object = Dateo.objects.get(pk=fields['map_items'][0]) c.object_id = fields['map_items'][0] c.user_id = get_user(fields['user']) c.client_domain = datea c.save() created = date_parser(fields['created']) Comment.objects.filter(pk=c.pk).update(created=created)
def create_comments(): Comment.objects.all().delete() for pk, fields in comentarios.iteritems(): c = Comment(pk=pk) c.comment = fields['comment'] c.published = fields['published'] c.user_id = get_user(fields['user']) c.content_object = Dateo.objects.get(pk=fields['object_id']) c.object_id = fields['object_id'] c.client_domain = datea c.save() created = date_parser(fields['created']) Comment.objects.filter(pk=c.pk).update(created=created)