Ticket #14175: 14175_comment_long_full_name.diff

File 14175_comment_long_full_name.diff, 3.1 KB (added by Julien Phalip, 14 years ago)
  • django/contrib/comments/forms.py

    diff --git a/django/contrib/comments/forms.py b/django/contrib/comments/forms.py
    index 4ecc4c4..097b3f4 100644
    a b class CommentDetailsForm(CommentSecurityForm):  
    106106    """
    107107    Handles the specific details of the comment (name, comment, etc.).
    108108    """
    109     name          = forms.CharField(label=_("Name"), max_length=50)
     109    name          = forms.CharField(label=_("Name"), max_length=61)
    110110    email         = forms.EmailField(label=_("Email address"))
    111111    url           = forms.URLField(label=_("URL"), required=False)
    112112    comment       = forms.CharField(label=_('Comment'), widget=forms.Textarea,
  • django/contrib/comments/models.py

    diff --git a/django/contrib/comments/models.py b/django/contrib/comments/models.py
    index 5e128d2..d1e2ac8 100644
    a b class Comment(BaseCommentAbstractModel):  
    4949    # was posted by a non-authenticated user.
    5050    user        = models.ForeignKey(User, verbose_name=_('user'),
    5151                    blank=True, null=True, related_name="%(class)s_comments")
    52     user_name   = models.CharField(_("user's name"), max_length=50, blank=True)
     52    user_name   = models.CharField(_("user's name"), max_length=61, blank=True)
    5353    user_email  = models.EmailField(_("user's email address"), blank=True)
    5454    user_url    = models.URLField(_("user's URL"), blank=True)
    5555
  • tests/regressiontests/comment_tests/tests/comment_view_tests.py

    diff --git a/tests/regressiontests/comment_tests/tests/comment_view_tests.py b/tests/regressiontests/comment_tests/tests/comment_view_tests.py
    index b8a62b4..106f249 100644
    a b class CommentViewTests(CommentTestCase):  
    135135        c = Comment.objects.get(user=user)
    136136        self.assertEqual(c.ip_address, "1.2.3.4")
    137137        self.assertEqual(c.user_name, 'jane_other')
    138         user.delete()
    139138
     139    def testPostAsAuthenticatedUserWithLongFullname(self):
     140        """
     141        Check that the user's name in the comment is populated for
     142        authenticated users with a long first_name and last_name (up to 30
     143        characters each).
     144        Refs #14175.
     145        """
     146        user = User.objects.create_user(username='jane_other',
     147                email='jane@example.com', password='jane_other')
     148        user.first_name = 'Loooong First Name of 30 Chars'
     149        user.last_name = 'Looooong Last Name of 30 Chars'
     150        user.save()
     151        a = Article.objects.get(pk=1)
     152        data = self.getValidData(a)
     153        data['name'] = data['email'] = ''
     154        self.client.login(username="jane_other", password="jane_other")
     155        self.response = self.client.post("/post/", data, REMOTE_ADDR="1.2.3.4")
     156        c = Comment.objects.get(user=user)
     157        self.assertEqual(c.ip_address, "1.2.3.4")
     158        self.assertEqual(c.user_name, 'Loooong First Name of 30 Chars Looooong Last Name of 30 Chars')       
     159       
    140160    def testPreventDuplicateComments(self):
    141161        """Prevent posting the exact same comment twice"""
    142162        a = Article.objects.get(pk=1)
Back to Top