Opened 7 years ago

Closed 6 years ago

Last modified 5 years ago

#13607 closed (fixed)

Admin date_hierarchy drill-down should auto-initialise to appropriate level

Reported by: Simon Meers Owned by: Simon Meers
Component: User Experience Version: master
Severity: Keywords: admin, date_hierarchy, sprintdec2010
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Say you have a model with a date_hierarchy field selected in the ModelAdmin, but the dates so far only span a few days. Instead of seeing the year displayed, then clicking it to show the month, then clicking it to show the days, perhaps it would be a good idea to initialise it based on the span of dates to show the first level with multiple options. That is, if all the dates are in one month, show the day-level drill-down initially. If two months are spanned, but in the same year, show the month-level drill down initially. If multiple years are indeed spanned, then start with the year-level interface.

Similarly to how list_filters intelligently show/hide themselves based on available data.

Happy to code this, just wanted to get my thoughts down first.

Attachments (5)

date_hierarchy_initialisation.diff (959 bytes) - added by Simon Meers 6 years ago.
date_hierarchy_initialisation.2.diff (958 bytes) - added by Simon Meers 6 years ago.
Oops, can't use "any" yet…
date_hierarchy_initialisation.3.diff (1.1 KB) - added by Simon Meers 6 years ago.
Include check in case of empty querysets
13607.diff (6.4 KB) - added by Simon Meers 6 years ago.
13607.2.diff (6.6 KB) - added by Simon Meers 6 years ago.
Whitespace fixes :)

Download all attachments as: .zip

Change History (12)

comment:1 Changed 6 years ago by Russell Keith-Magee

Triage Stage: UnreviewedAccepted

Sounds like a reasonable suggestion; implementing it in an efficient way could be interesting, though.

Changed 6 years ago by Simon Meers

comment:2 Changed 6 years ago by Simon Meers

Has patch: set
Owner: set to Simon Meers
Status: newassigned

Pretty dead-simple patch really. Much nicer to use now. I don't think the aggregate query has any major efficiency issues?

Changed 6 years ago by Simon Meers

Oops, can't use "any" yet...

Changed 6 years ago by Simon Meers

Include check in case of empty querysets

comment:3 Changed 6 years ago by Matthias Kestenholz

Needs tests: set
Patch needs improvement: set

A (dumb?) question: Is cl.query_set the unfiltered queryset or is it already filtered down by list_filters?

Plus, tests are missing.

Changed 6 years ago by Simon Meers

Attachment: 13607.diff added

comment:4 Changed 6 years ago by Simon Meers

Keywords: sprintdec2010 added
Needs tests: unset
Patch needs improvement: unset

Changed 6 years ago by Simon Meers

Attachment: 13607.2.diff added

Whitespace fixes :)

comment:5 Changed 6 years ago by Brodie Rao

Triage Stage: AcceptedReady for checkin

comment:6 Changed 6 years ago by Jannis Leidel

Resolution: fixed
Status: assignedclosed

(In [14879]) Fixed #13607 -- Auto-initialize admin's date hierarchy links intelligently. Thanks, Simon Meers.

comment:7 Changed 5 years ago by Jacob

milestone: 1.3

Milestone 1.3 deleted

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