Opened 15 years ago

Closed 12 years ago

Last modified 12 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 14 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 13 years ago.
Fix over the first attachment.

Download all attachments as: .zip

Change History (16)

comment:1 Changed 15 years ago by Jacob

milestone: 1.1

Changed 14 years ago by palewire

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 Changed 14 years ago by palewire

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 Changed 14 years ago by palewire

Cc: ben.welsh@… added

comment:4 Changed 14 years ago by Russell Keith-Magee

Triage Stage: UnreviewedAccepted

comment:5 Changed 14 years ago by Michel Sabchuk

Cc: michel@… added

comment:6 Changed 13 years ago by Michel Sabchuk

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?

Changed 13 years ago by Michel Sabchuk

Attachment: week_pagination2.diff added

Fix over the first attachment.

comment:7 Changed 13 years ago by palewire

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

comment:8 Changed 13 years ago by Russell Keith-Magee

Needs documentation: set
Patch needs improvement: set

Patch needs to be updated for class-based views.

comment:9 Changed 13 years ago by Chris Beaven

Severity: Normal
Type: New feature

comment:10 Changed 12 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:11 Changed 12 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:12 Changed 12 years ago by Aymeric Augustin

Owner: changed from nobody to Aymeric Augustin

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

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 Changed 12 years ago by Aymeric Augustin <aymeric.augustin@…>

In [b0c1e5c081472436bf2300af3073cef1df1bd696]:

Documented next/previous_week. Refs #10890.

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