Esempio n. 1
0
    def save(self):
        post = self.initial["post"]
        user = self.initial["user"]
        parent_object = self.initial["parent_object"]

        new_comment = Comment()
        new_comment.comment = self.cleaned_data["comment"]
        new_comment.post = post
        new_comment.user = user
        new_comment.object_id = parent_object.id
        new_comment.content_type = ContentType.objects.get_for_model(parent_object)
        new_comment.is_active = True
        new_comment.activation_code = 0
        new_comment.save()
Esempio n. 2
0
    def save(self):
        post = self.initial["post"]
        user = self.initial["user"]
        parent_object = self.initial["parent_object"]

        new_comment = Comment()
        new_comment.comment = self.cleaned_data["comment"]
        new_comment.post = post
        new_comment.user = user
        new_comment.object_id = parent_object.id
        new_comment.content_type = ContentType.objects.get_for_model(
            parent_object)
        new_comment.is_active = True
        new_comment.activation_code = 0
        new_comment.save()
Esempio n. 3
0
 def save(self):
     parent_object = self.initial["parent_object"]
     email = self.cleaned_data["email"]
     post = self.initial["post"]
     random_int = random.random()*9999
     activation_code = hashlib.sha224("%s:%s"%(email,random_int)).hexdigest()[:50]
     print activation_code
     new_comment = Comment()
     new_comment.comment = self.cleaned_data["comment"]
     new_comment.email = email 
     new_comment.post = post
     new_comment.activation_code = activation_code
     new_comment.object_id = parent_object.id
     new_comment.content_type = ContentType.objects.get_for_model(parent_object)
     new_comment.is_active = False
     new_comment.save()
     send_comment_activation_mail.delay(activation_code, email)
Esempio n. 4
0
 def save(self):
     parent_object = self.initial["parent_object"]
     email = self.cleaned_data["email"]
     post = self.initial["post"]
     random_int = random.random() * 9999
     activation_code = hashlib.sha224("%s:%s" %
                                      (email, random_int)).hexdigest()[:50]
     print activation_code
     new_comment = Comment()
     new_comment.comment = self.cleaned_data["comment"]
     new_comment.email = email
     new_comment.post = post
     new_comment.activation_code = activation_code
     new_comment.object_id = parent_object.id
     new_comment.content_type = ContentType.objects.get_for_model(
         parent_object)
     new_comment.is_active = False
     new_comment.save()
     send_comment_activation_mail.delay(activation_code, email)
Esempio n. 5
0
def addcomment(request, id):
    url = request.META.get('HTTP_REFERER')
    if request.method == 'POST':
        form = CommentForm(request.POST)
        if form.is_valid():
            current_user = request.user
            data = Comment()
            data.user_id = current_user.id
            data.post_id = id
            data.rate = form.cleaned_data['rate']
            data.subject = form.cleaned_data['subject']
            data.comment = form.cleaned_data['comment']
            data.ip = request.META.get('REMOTE_ADDR')
            data.save()
            messages.success(request,
                             "Your comment succesfully send. Thank you")
            return HttpResponseRedirect(url)

    messages.warning(request, "Vups, Someting went wrong. Chechk again")
    return HttpResponseRedirect(url)
Esempio n. 6
0
def post(request, post_id):
	if request.method == "GET":
		p = get_object_or_404(Post, pk=post_id)
		return render_to_response('post/templates/post.html', {'post': p,
			'user': request.user},
		        context_instance=RequestContext(request))
	else:
		print request.POST
		comment = request.POST.get("comment")	
		if comment:
			c = Comment()
			c.post_id = post_id
			c.comment =  comment
			c.username = request.user.username
			c.rating = 0
			c.save()
			p = get_object_or_404(Post, pk=post_id)
			return render_to_response('post/templates/post.html', {'post': p, 
				'user': request.user},
				 context_instance=RequestContext(request))
		else:
			return HttpResponse("<strong>you must provide valid comment</strong>")