Opened 7 years ago

Last modified 10 months ago

#8472 assigned New feature

Add "Recent Actions" panel to app_index template

Reported by: juliae Owned by: burzak
Component: contrib.admin Version: master
Severity: Normal Keywords:
Cc: prestontimmons, cmawebsite@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes


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 burzak 5 years ago.
recent_action_on_appindex_v2.diff (4.5 KB) - added by burzak 5 years ago.
recent_action_on_appindex_v3.diff (8.4 KB) - added by prestontimmons 5 years ago.
Added tests to patch

Download all attachments as: .zip

Change History (14)

comment:1 Changed 7 years ago by brosner

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 7 years ago by adrian

This would be a nice addition.

comment:3 Changed 7 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

Changed 5 years ago by burzak

comment:4 Changed 5 years ago by burzak

  • Has patch set
  • Owner changed from nobody to burzak
  • Severity set to Normal
  • Status changed from new to assigned
  • Type set to 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 Changed 5 years ago by julien

  • Easy pickings unset
  • Needs tests set

comment:6 Changed 5 years ago by jacob

  • 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 %}.

Changed 5 years ago by burzak

comment:7 Changed 5 years ago by burzak

  • 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.

Changed 5 years ago by prestontimmons

Added tests to patch

comment:8 Changed 5 years ago by prestontimmons

  • 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 Changed 5 years ago by prestontimmons

  • Cc prestontimmons added

comment:10 Changed 4 years ago by julien

  • UI/UX set

comment:11 Changed 10 months ago by collinanderson

  • 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