Opened 16 years ago

Closed 13 years ago

Last modified 13 years ago

#10890 closed New feature (fixed)

generic views archive_week and archive_day should have next/previous as Template Context

Reported by: ee_lars Owned by: Aymeric Augustin
Component: Generic views Version: dev
Severity: Normal Keywords: generic views date_based archive_day archive_week
Cc: ben.welsh@…, michel@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Theses two generic views don't manage next/previous day/week.
It could be usefull and more coherent with archive_month and archive_year views which deal with these feature.

Attachments (2)

week_pagination.diff (2.2 KB ) - added by palewire 15 years ago.
An addition to the archive_week generic view that adds next_week and previous_week objects to the context for easier pagination in your templates
week_pagination2.diff (2.2 KB ) - added by Michel Sabchuk 14 years ago.
Fix over the first attachment.

Download all attachments as: .zip

Change History (16)

comment:1 by Jacob, 16 years ago

milestone: 1.1

by palewire, 15 years ago

Attachment: week_pagination.diff added

An addition to the archive_week generic view that adds next_week and previous_week objects to the context for easier pagination in your templates

comment:2 by palewire, 15 years ago

Has patch: set
Needs tests: set

I've attached a patch that tries to tackle the issue.

One complication: There isn't a week attribute on datetime objects, or at least I'm not aware of it. Typically, I use dt.isocalendar()[1] to get week numbers. But that's a pretty big hassle to do in your templates, so I'm not sure that just passing out a datetime object, as is done with the other date_based generic views, will work here.

If you check out my patch, what I tried was passing out dictionaries instead. Each with a 'year' and 'week' attribute that contains integers, and a 'date' key that hooks you up with the datetime object, if you happen to want that as well.

Dumb idea?

comment:3 by palewire, 15 years ago

Cc: ben.welsh@… added

comment:4 by Russell Keith-Magee, 15 years ago

Triage Stage: UnreviewedAccepted

comment:5 by Michel Sabchuk, 14 years ago

Cc: michel@… added

comment:6 by Michel Sabchuk, 14 years ago

Palewire: I think you can use "day.strftime('%U')" instead of "day.isocalendar()[1]". With the second choice, you can't do an easy navigation because the week numbers of day.isocalendar() are different from the result of the '%U'.

Once django itself uses the '%U' to know what week we are, using it in the dates will be better. I will send a patch.

I will make the tests and documentation for it too, maybe it can appear in the django1.3?

by Michel Sabchuk, 14 years ago

Attachment: week_pagination2.diff added

Fix over the first attachment.

comment:7 by palewire, 14 years ago

I'm totally open to alternatives and if your fix dovetails with a broader change to the Django core, all the better.

comment:8 by Russell Keith-Magee, 14 years ago

Needs documentation: set
Patch needs improvement: set

Patch needs to be updated for class-based views.

comment:9 by Chris Beaven, 14 years ago

Severity: Normal
Type: New feature

comment:10 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:11 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:12 by Aymeric Augustin, 13 years ago

Owner: changed from nobody to Aymeric Augustin

comment:13 by Aymeric Augustin <aymeric.augustin@…>, 13 years ago

Resolution: fixed
Status: newclosed

In [fcb09b5746192fea1b672346c915ee11e4120d7e]:

Fixed #10890: added prev/next_week in the context

of per-week date-based generic views. Thanks ee_lars for the report.

comment:14 by Aymeric Augustin <aymeric.augustin@…>, 13 years ago

In [b0c1e5c081472436bf2300af3073cef1df1bd696]:

Documented next/previous_week. Refs #10890.

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