Opened 16 years ago
Closed 12 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)
Change History (11)
by , 16 years ago
Attachment: | comments.diff added |
---|
comment:1 by , 16 years ago
Version: | 1.0 → SVN |
---|
comment:2 by , 16 years ago
comment:3 by , 16 years ago
Cc: | 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 , 15 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:5 by , 15 years ago
Cc: | added |
---|
comment:6 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:8 by , 13 years ago
Check my comment on https://code.djangoproject.com/ticket/12742#comment:7
comment:9 by , 12 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
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.
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.