Opened 15 years ago

Closed 11 years ago

#10838 closed New feature (wontfix)

Pass user object to CommentForm (initial data)

Reported by: Maciej Wiśniowski Owned by: nobody
Component: contrib.comments Version: dev
Severity: Normal Keywords: comments
Cc: pigletto@…, waylan@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

CommentForm should check if current user is authenticated and if so, initial data for user's 'name' and 'email' should be filled.
Also, it is very useful to have access to at last user object (request?) in form's init. This way you're able to customize it a lot, eg. hide some fields or mark them readonly depending on user.
Proposed patch passes user object to CommentForm and then initial data are populated with 'name' and 'email' from user object

Attachments (2)

comments.diff (2.1 KB ) - added by Maciej Wiśniowski 15 years ago.
10838.diff (1.2 KB ) - added by Thejaswi Puthraya 15 years ago.
git-patch against the latest checkout

Download all attachments as: .zip

Change History (11)

by Maciej Wiśniowski, 15 years ago

Attachment: comments.diff added

comment:1 by Maciej Wiśniowski, 15 years ago

Version: 1.0SVN

comment:2 by Thejaswi Puthraya, 15 years ago

Ideally, you shouldn't change the API because Django is committed to
backwards-compatibility. The CommentForm always had access to initial
kwarg that would display the default values.

I have attached a patch that doesn't break compatibility but I somehow
feel that I am violating DRY at
http://code.djangoproject.com/browser/django/trunk/django/contrib/comments/views/comments.py#L34

Let's see what the core-devs have to tell.

by Thejaswi Puthraya, 15 years ago

Attachment: 10838.diff added

git-patch against the latest checkout

comment:3 by Maciej Wiśniowski, 15 years ago

Cc: pigletto@… added

Patch from thejaswi_puthraya only adds username and e-mail to inital_data while my original idea was also to pass user object to form's init function. This way it is possible to customize form, eg. by hiding some fields for specific users.
Backward compatibility is only broken if one has own comment form with overriden init function that doesn't accept kwargs.

comment:4 by anonymous, 15 years ago

Triage Stage: UnreviewedDesign decision needed

comment:5 by Waylan Limberg, 15 years ago

Cc: waylan@… added

comment:6 by Chris Beaven, 13 years ago

Severity: Normal
Type: New feature

comment:7 by Thejaswi Puthraya, 13 years ago

Easy pickings: unset
UI/UX: unset

Slightly related to #12742

comment:9 by Jacob, 11 years ago

Resolution: wontfix
Status: newclosed

django.contrib.comments has been deprecated and is no longer supported, so I'm closing this ticket. We're encouraging users to transition to a custom solution, or to a hosted solution like Disqus.

The code itself has moved to https://github.com/django/django-contrib-comments; if you want to keep using it, you could move this bug over there.

Note: See TracTickets for help on using tickets.
Back to Top