Ticket #10838: 10838.diff

File 10838.diff, 1.2 KB (added by Thejaswi Puthraya, 16 years ago)

git-patch against the latest checkout

  • django/contrib/comments/templatetags/comments.py

    diff --git a/django/contrib/comments/templatetags/comments.py b/django/contrib/comments/templatetags/comments.py
    index 9f8180a..8d15def 100644
    a b from django.conf import settings  
    44from django.contrib.contenttypes.models import ContentType
    55from django.contrib import comments
    66from django.utils.encoding import smart_unicode
     7from django.contrib.auth.models import AnonymousUser
    78
    89register = template.Library()
    910
    class CommentFormNode(BaseCommentNode):  
    124125    def get_form(self, context):
    125126        ctype, object_pk = self.get_target_ctype_pk(context)
    126127        if object_pk:
    127             return comments.get_form()(ctype.get_object_for_this_type(pk=object_pk))
     128            if isinstance(context['user'], AnonymousUser):
     129                initial = {}
     130            else:
     131                initial = {"name"  : context['user'].get_full_name() or context['user'].username,
     132                           "email" : context['user'].email}
     133            return comments.get_form()(ctype.get_object_for_this_type(pk=object_pk), initial=initial)
    128134        else:
    129135            return None
    130136
Back to Top