Opened 7 years ago

Closed 7 years ago

#28082 closed Cleanup/optimization (fixed)

BaseDateListView should pass all context to subclasses

Reported by: Leon Matthews Owned by: Sebastián Sassi
Component: Generic views Version: dev
Severity: Normal Keywords: BaseDateListView
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Leon Matthews)

Pass the extra_content from get_dated_items() as kwargs into get_context_data() to allow users access to it.

BaseDateListView.get() currently modifies the context after calling get_context_data(), which prevents users from access those data in their base classes. I ran into this suprising quirk when I wanted to access the current month in my MonthArchiveView subclass's get_context_data().

I have created a pull request for a very minimal patch.

(To really tidy things up, we could have all instances get_dated_items() return a single dictionary that we pass to get_context_data as kwargs, but I am a realist on occasion...)

Change History (5)

comment:1 by Claude Paroz, 7 years ago

Has patch: set
Needs tests: set
Summary: Pull request #8364: BaseDateListView should pass all context to subclassesBaseDateListView should pass all context to subclasses
Triage Stage: UnreviewedAccepted

comment:2 by Leon Matthews, 7 years ago

Description: modified (diff)

Linked to pull request as requested.

comment:3 by Sebastián Sassi, 7 years ago

Owner: changed from nobody to Sebastián Sassi
Status: newassigned

comment:4 by Tim Graham, 7 years ago

Needs tests: unset
Triage Stage: AcceptedReady for checkin

PR with test.

comment:5 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: assignedclosed

In 58483052:

Fixed #28082 -- Made BaseDateListView pass context from get_dated_items() to subclasses.

Thanks leon-matthews for the report and fix.

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