Opened 16 years ago

Last modified 9 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)

recent_action_on_appindex.diff (4.9 KB ) - added by Dario Ocles 13 years ago.
recent_action_on_appindex_v2.diff (4.5 KB ) - added by Dario Ocles 13 years ago.
recent_action_on_appindex_v3.diff (8.4 KB ) - added by Preston Timmons 13 years ago.
Added tests to patch

Download all attachments as: .zip

Change History (14)

comment:1 by Brian Rosner, 16 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Adrian Holovaty, 16 years ago

This would be a nice addition.

comment:3 by (none), 15 years ago

milestone: post-1.0

Milestone post-1.0 deleted

by Dario Ocles, 13 years ago

comment:4 by Dario Ocles, 13 years ago

Has patch: set
Owner: changed from nobody to Dario Ocles
Severity: Normal
Status: newassigned
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 Julien Phalip, 13 years ago

Easy pickings: unset
Needs tests: set

comment:6 by Jacob, 13 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 Dario Ocles, 13 years ago

comment:7 by Dario Ocles, 13 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.

by Preston Timmons, 13 years ago

Added tests to patch

comment:8 by Preston Timmons, 13 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 Preston Timmons, 13 years ago

Cc: Preston Timmons added

comment:10 by Julien Phalip, 13 years ago

UI/UX: set

comment:11 by Collin Anderson, 9 years ago

Cc: cmawebsite@… 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'
Note: See TracTickets for help on using tickets.
Back to Top