Ejemplo n.º 1
0
def newComment(model, request, comment):
    user = request.user
    c = Comment()
    
    c.user = user
    c.user_name = user.username
    c.user_email = user.email
    c.ip_address = request.META.get('REMOTE_ADDR')
    c.comment = comment
    
    # c.site = Site.objects.get(id=settings.SITE_ID)
    c.site_id = settings.SITE_ID
    
    c.content_type = ContentType.objects.get_for_model(model)
    c.object_pk = model.id
    
    c.save()
Ejemplo n.º 2
0
def create_comment(oldcomment):
    current_site = Site.objects.get(id=settings.SITE_ID)
    content_type = ContentType.objects.get(app_label='blog', model='post')
    fields = oldcomment['fields']
    comment = Comment()
    comment.comment  = fields['comment']
    comment.ip_address  = fields['ip_address']
    comment.is_public  = fields['is_public']
    comment.is_removed  = fields['is_removed']
    comment.object_pk  = fields['object_pk']
    comment.submit_date  = fields['submit_date']
    comment.user  = None
    comment.user_email  = fields['user_email']
    comment.user_name  = fields['user_name']
    comment.user_url  = fields['user_url']
    comment.content_type  = content_type
    comment.site  = current_site
    comment.save()
Ejemplo n.º 3
0
def process_comment(request, commentform, post):
    try:
        comment = Comment.objects.get(id=commentform.cleaned_data.get('id', None))
    except Comment.DoesNotExist:
        comment = Comment()
    comment.content_object = post
    comment.site = Site.objects.get_current()
    comment.user = request.user
    try:
        profile = UserProfile.objects.get(user = request.user)
        comment.user_url = profile.get_absolute_url()
    except UserProfile.DoesNotExist:
        pass
    comment.comment = strip_tags(commentform.cleaned_data['comment'])
    comment.submit_date = datetime.datetime.now()
    comment.ip_address = request.META['REMOTE_ADDR']
    comment.is_public = True
    comment.is_removed = False
    comment.save()
    return comment
Ejemplo n.º 4
0
def process_comment(request, commentform, post):
    print commentform.cleaned_data
    try:
        comment = Comment.objects.get(
            id=commentform.cleaned_data.get('id', None))
    except Comment.DoesNotExist:
        comment = Comment()
    comment.content_object = post
    comment.site = Site.objects.get_current()
    comment.user = request.user
    try:
        profile = UserProfile.objects.get(user=request.user)
        comment.user_url = profile.get_absolute_url()
    except UserProfile.DoesNotExist:
        pass
    comment.comment = strip_tags(commentform.cleaned_data['comment'])
    comment.submit_date = datetime.datetime.now()
    comment.ip_address = request.META['REMOTE_ADDR']
    comment.is_public = True
    comment.is_removed = False
    comment.save()
    return comment