Ticket #10838: comments.diff

File comments.diff, 2.1 KB (added by Maciej Wiśniowski, 16 years ago)
  • django/contrib/comments/templatetags/comments.py

     
    123123
    124124    def get_form(self, context):
    125125        ctype, object_pk = self.get_target_ctype_pk(context)
     126        user = context.get('user', None)
    126127        if object_pk:
    127             return comments.get_form()(ctype.get_object_for_this_type(pk=object_pk))
     128            return comments.get_form()(ctype.get_object_for_this_type(pk=object_pk), user=user)
    128129        else:
    129130            return None
    130131
  • django/contrib/comments/views/comments.py

     
    6161    preview = "preview" in data
    6262
    6363    # Construct the comment form
    64     form = comments.get_form()(target, data=data)
     64    form = comments.get_form()(target, data=data, user=request.user)
    6565
    6666    # Check security information
    6767    if form.security_errors():
  • django/contrib/comments/forms.py

     
    9696    comment       = forms.CharField(label=_('Comment'), widget=forms.Textarea,
    9797                                    max_length=COMMENT_MAX_LENGTH)
    9898
     99    def __init__(self, target_object, data=None, initial=None, user=None):
     100        self.user = user
     101        if initial is None:
     102            initial = {}
     103        if user and user.is_authenticated():
     104            initial.update({"name":user.get_full_name() or user.username,
     105                                   "email":user.email})
     106        super(CommentDetailsForm, self).__init__(target_object, data=data, initial=initial)
     107
    99108    def get_comment_object(self):
    100109        """
    101110        Return a new (unsaved) comment object based on the information in this
Back to Top