Opened 16 years ago
Last modified 10 years ago
#8472 assigned New feature
Add "Recent Actions" panel to app_index template
Reported by: | Julia | Owned by: | Dario Ocles |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Preston Timmons, cmawebsite@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | yes |
Description
This was a feature request and relates to the changeset in #1390. The goal is to produce specified results for the Recent Actions panel (sidebar) to only display logged actions for that particular model. For example, at Home > Auth would only display logged actions for the apps pertaining to that model (e.g. User, Groups).
Attachments (3)
Change History (14)
comment:1 by , 16 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 16 years ago
by , 14 years ago
Attachment: | recent_action_on_appindex.diff added |
---|
comment:4 by , 14 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Severity: | → Normal |
Status: | new → assigned |
Type: | → New feature |
I made a patch to include "recent actions" on app_index. Added 'for_current_app' option on get_admin_log. If it is used on any other place than app_index it just won't filter anything.
comment:5 by , 14 years ago
Easy pickings: | unset |
---|---|
Needs tests: | set |
comment:6 by , 14 years ago
Patch needs improvement: | set |
---|
Ick, I really don't like the way for_current_app
works. Template tags that require specific things from the context aren't a good practice. How about {% get_admin_log 10 as admin_log for_user 23 for_app "appname" %}
? So in the case of admin templates, it'd be {% get_admin_log ... for_app app_list.0.name %}
.
by , 14 years ago
Attachment: | recent_action_on_appindex_v2.diff added |
---|
comment:7 by , 14 years ago
Patch needs improvement: | unset |
---|
I improved the patch as jacob suggested. I removed the 'for_current_app' option and I added the 'for_app' option that recives the app name.
I'm not sure what kind of test I can add to this patch, can someone give me some advise about this? I don't have much experience, sorry.
I removed the check of 'patch needs improvement' but I leave the 'needs tests' unless someone says that it doesn't need any tests.
comment:8 by , 14 years ago
Needs documentation: | set |
---|---|
Needs tests: | unset |
I updated the patch to add test cases. From what I could tell there weren't any existing tests for the get_admin_log template tag.
comment:9 by , 14 years ago
Cc: | added |
---|
comment:10 by , 13 years ago
UI/UX: | set |
---|
comment:11 by , 10 years ago
Cc: | added |
---|
If it helps, I personally register the LogEntry model in the admin:
class LogEntryAdmin(admin.ModelAdmin): list_display = ['action_time', 'obj', 'content_type', 'user', 'action', 'change_message'] list_filter = ['content_type'] readonly_fields = ['user', 'content_type', 'object_id', 'object_repr', 'action_flag', 'change_message'] def obj(self, obj): return '<a href="%s">%s</a>' % (obj.get_edited_object().get_absolute_url(), conditional_escape(obj.object_repr)) obj.allow_tags = True obj.admin_sort_field = 'object_repr' def action(self, obj): return (u'%s' % obj).split()[0] obj.admin_sort_field = 'action_flag'
This would be a nice addition.