Opened 7 years ago

Closed 6 years ago

Last modified 5 years ago

#10759 closed (duplicate)

UserAdmin views should use attribute or current model to lookup the template paths

Reported by: james Turnbull Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords: UserAdmin, add_view, user_change_password
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When overriding the add_view() and user_change_password() in UserAdmin I expected it to use the current model names to find the templates (like the rest of admin).

However, it was hardcoded to use admin/auth/user/add_form.html and admin/auth/user/change_password.html.

Attached patch adds in the path for the current model, falling back to the above for backwards compatibility.

Attachments (2)

admin_user_templates.diff (1.4 KB) - added by james Turnbull 7 years ago.
admin_user_template_vars.diff (3.4 KB) - added by james Turnbull 7 years ago.
More flexible version

Download all attachments as: .zip

Change History (14)

Changed 7 years ago by james Turnbull

Attachment: admin_user_templates.diff added

comment:1 Changed 7 years ago by Alex Gaynor

milestone: 1.2
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

comment:2 Changed 7 years ago by james Turnbull

Any chance this could get set for 1.1 rather than 1.2?

I only ask as it goes very well with my other (set for 1.1) patch here: #10694

comment:3 Changed 7 years ago by Alex Gaynor

That's a bug, this is, in my view, a feature, admittingly a totally low overhead, noncontroversial no work one, but where that bar lies is for a committer to decide, so I've been intentionally rather conservative here.

comment:4 Changed 7 years ago by james Turnbull

Cool, thanks for taking the time to explain.

Changed 7 years ago by james Turnbull

More flexible version

comment:5 Changed 7 years ago by james Turnbull

Summary: UserAdmin views should use the current model to lookup the template pathsUserAdmin views should use attribure or current model to lookup the template paths
Triage Stage: AcceptedUnreviewed

After thinking about this further, I've submitted a new patch and knocked this bug back to "Unreviewed". Apologies for messing it around.

Taking cues from ModelAdmin, this version first looks for local attributes add_form_template and change_password_template before then attempting the template based off the models name, and finally falling back to the auth.user template (for backwards compatiblity).

Also to follow the convention of ModelAdmin in this version I define a variable for the context and pass that into render_to_response rather than defining a variable for the templates as I did in the previous patch.

comment:6 Changed 7 years ago by james Turnbull

Summary: UserAdmin views should use attribure or current model to lookup the template pathsUserAdmin views should use attribute or current model to lookup the template paths

Fixed a typo in the Summary.

comment:7 Changed 7 years ago by Alex Gaynor

Triage Stage: UnreviewedAccepted

comment:8 Changed 7 years ago by James Bennett

milestone: 1.2

1.2 is feature-frozen, moving this feature request off the milestone.

comment:9 Changed 6 years ago by james Turnbull

milestone: 1.3

This patch is ready to go and accepted - can someone push this into Django 1.3?

comment:10 Changed 6 years ago by james Turnbull

Resolution: duplicate
Status: newclosed

This was mostly fixed in #12218, so closing as a dupe.

comment:11 Changed 6 years ago by james Turnbull

Apologies, I meant: [12218]

comment:12 Changed 5 years ago by Jacob

milestone: 1.3

Milestone 1.3 deleted

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