Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1192 (closed defect: wontfix)

Opened 13 years ago

Last modified 12 years ago

CalendarDateTimePicker need to accept callables for default values

Reported by: guest Owned by: anonymous
Priority: normal Milestone: 1.0
Component: TG Widgets Version: 1.0b2
Severity: normal Keywords:
Cc:

Description

I think this is a must. In my project I want the user to input a range of dates, where the default range is between today and 2 weeks ago.

Thesamet

Change History

comment:1 Changed 13 years ago by alberto

  • Status changed from new to closed
  • Resolution set to wontfix

Why dont you make your own picker by subclassing?

from tubogears.widgets import CalendarDateTimePicker
from datetime import datetime, timedelta

class DeltaCalendar(CalendarDateTimePicker):
    params = ['delta']
    delta = timedelta()
    def update_params(self,d):
        super(MyCalendar, self).update_params(d)
        d['value'] = datetime.now() + d['delta']

cal = DeltaCalendar("date", delta=timedelta(weeks=-2))

# Can also change the delta when displaying or pass a callable to determine it for every request:

cal.diplay(delta=timedelta(weeks=-1))

cal = DeltaCalendar("date", delta=lambda: timedelta(days=2))

You get the idea...

1.0b2 is in feature freeze so I'll close this as wontfix. Sorry.

Alberto

Note: See TracTickets for help on using tickets.