1.1 --- a/EventAggregatorSupport.py Thu Jul 08 22:18:54 2010 +0200
1.2 +++ b/EventAggregatorSupport.py Fri Jul 09 01:56:45 2010 +0200
1.3 @@ -161,7 +161,7 @@
1.4 else:
1.5 return int(value)
1.6
1.7 - def get_month_lists(self):
1.8 + def get_month_lists(self, default_as_current=0):
1.9
1.10 """
1.11 Return two lists of HTML element definitions corresponding to the start
1.12 @@ -177,11 +177,15 @@
1.13 start_month_list = []
1.14 end_month_list = []
1.15
1.16 - start_month = self._get_input(form, "start-month", getCurrentMonth().month())
1.17 + start_month = self._get_input(form, "start-month", default_as_current and getCurrentMonth().month() or None)
1.18 end_month = self._get_input(form, "end-month", start_month)
1.19
1.20 # Prepare month lists, selecting specified months.
1.21
1.22 + if not default_as_current:
1.23 + start_month_list.append('<option value=""></option>')
1.24 + end_month_list.append('<option value=""></option>')
1.25 +
1.26 for month in range(1, 13):
1.27 month_label = _(getMonthLabel(month))
1.28 selected = self._get_selected(month, start_month)
1.29 @@ -191,14 +195,14 @@
1.30
1.31 return start_month_list, end_month_list
1.32
1.33 - def get_year_defaults(self):
1.34 + def get_year_defaults(self, default_as_current=0):
1.35
1.36 "Return defaults for the start and end years."
1.37
1.38 form = self.get_form()
1.39
1.40 - start_year_default = form.get("start-year", [""])[0] or getCurrentYear()
1.41 - end_year_default = form.get("end-year", [""])[0] or start_year_default
1.42 + start_year_default = form.get("start-year", [default_as_current and getCurrentYear() or ""])[0]
1.43 + end_year_default = form.get("end-year", [default_as_current and start_year_default or ""])[0]
1.44
1.45 return start_year_default, end_year_default
1.46
1.47 @@ -1457,6 +1461,18 @@
1.48 else:
1.49 return None
1.50
1.51 +def getFullMonthLabel(request, year_month):
1.52 +
1.53 + """
1.54 + Return the full month plus year label using the given 'request' and
1.55 + 'year_month'.
1.56 + """
1.57 +
1.58 + _ = request.getText
1.59 + year, month = year_month.as_tuple()
1.60 + month_label = _(getMonthLabel(month))
1.61 + return "%s %s" % (month_label, year)
1.62 +
1.63 # Page-related functions.
1.64
1.65 def getPrettyPageName(page):