Code

Opened 8 years ago

Last modified 2 years ago

#2901 new New feature

[newforms-admin] Enable admin log display to be restricted to a specific site

Reported by: Christopher Lenz <cmlenz@…> Owned by: nobody
Component: contrib.admin Version: newforms-admin
Severity: Normal Keywords: nfa-someday
Cc: cmlenz@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

The admin log currently only provides way to show changes across all sites. For a project with multiple sites, it'd be very nice to be able to tell the admin log template tag to only show changes to objects that either aren't associated with any site, or associated with the current (or some other specific) site.

This requires the django_admin_log table to be extended with a nullable site_id column, which would require appropriate upgrade instructions ala:

BEGIN;
ALTER TABLE django_admin_log
  ADD site_id integer NULL REFERENCES django_site (id);
COMMIT;

The patch adds a method called get_for_obj to the SiteManager class, which attempts to find the site a given object is related with (either through a many-to-many, or a many-to-one relation). This function is reused in the django.views.defaults.shortcut function, which needs the same thing.

Attachments (2)

admin_log_with_site.diff (10.0 KB) - added by Christopher Lenz <cmlenz@…> 8 years ago.
Patch as described above
admin_log_with_site.2.diff (10.0 KB) - added by Christopher Lenz <cmlenz@…> 8 years ago.
Fixed patch, previous one didn't correctly filter the template tag output

Download all attachments as: .zip

Change History (12)

Changed 8 years ago by Christopher Lenz <cmlenz@…>

Patch as described above

comment:1 Changed 8 years ago by Christopher Lenz <cmlenz@…>

  • Cc cmlenz@… added

Changed 8 years ago by Christopher Lenz <cmlenz@…>

Fixed patch, previous one didn't correctly filter the template tag output

comment:2 follow-up: Changed 8 years ago by jacob

This is a good patch, and the get_for_site() method is a great idea. We probably should wait to apply this until before an actual release to avoid model breakage midstream, though... I'm not sure what our policy is on handling things like that.

comment:3 Changed 7 years ago by Simon G. <dev@…>

  • Triage Stage changed from Unreviewed to Ready for checkin
  • Version changed from 0.95 to SVN

Marked as Ready-for-checkin, given Jacob's comment above, and now (prior to 1.0) is probably the best time to do it.

comment:4 in reply to: ↑ 2 Changed 7 years ago by mtredinnick

Replying to jacob:

This is a good patch, and the get_for_site() method is a great idea. We probably should wait to apply this until before an actual release to avoid model breakage midstream, though... I'm not sure what our policy is on handling things like that.

Don't you mean *just after* an actual release? Otherwise everybody who has been following svn leading up to the release gets bonus code breakage on the day of the release (or just before). If we make a backwards-compat change the day after a release, it will mean that people can stabilise on the released version until they feel like making the changes, without fear of missing any intermediate bug fixes (which is the argument against doing it months after a release).

comment:5 Changed 7 years ago by mtredinnick

  • Patch needs improvement set
  • Summary changed from [patch] Enable admin log display to be restricted to a specific site to [newforms-admin] Enable admin log display to be restricted to a specific site
  • Triage Stage changed from Ready for checkin to Accepted

We're not making any more changes to existing admin, since it has limited lifespan. So the patch needs to be update for newforms-admin and applied whenever the maintainers of that branch can handle the backwards incompatibility (when newforms-admin is merged to trunk, all code using existing admin needs changing anyway, so this becomes part of that).

comment:7 Changed 7 years ago by anonymous

Un-doing vandalism

comment:8 Changed 7 years ago by brosner

  • Keywords nfa-someday added
  • Version changed from SVN to newforms-admin

This functionality isn't critical to the merging of newforms-admin with trunk. Tagging with nfa-someday so it can be looked later.

comment:9 Changed 3 years ago by lrekucki

  • Severity changed from normal to Normal
  • Type changed from enhancement to New feature

comment:10 Changed 2 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:11 Changed 2 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new
The owner will be changed from nobody to anonymous. Next status will be 'assigned'
as The resolution will be set. Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.