Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 12007cc442a6697a04bcb03eee321362fe3e47fb
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Nov 6 09:52:46 2012 +0100
Give the day to FedoraCalendar as well so that we can pin point the current week.
>---------------------------------------------------------------
fedocal/fedocallib/__init__.py | 22 +++++++++++++---------
fedocal/fedocallib/fedora_calendar.py | 23 +++++++++++++++++++++--
2 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/fedocal/fedocallib/__init__.py b/fedocal/fedocallib/__init__.py
index 76db809..5f1d09d 100644
--- a/fedocal/fedocallib/__init__.py
+++ b/fedocal/fedocallib/__init__.py
@@ -452,23 +452,27 @@ def add_meetings_to_vcal(ical, meetings):
for meeting in meetings:
add_meeting_to_vcal(ical, meeting)
-def get_html_monthly_cal(month=None, year=None, calendar_name=None):
+def get_html_monthly_cal(day=None, month=None, year=None,
+ calendar_name=None):
""" Display a monthly calendar as HTML.
- :kwarg month: optionnal month. Defaults to current month
+ :kwarg day: optionnal day (as int). Defaults to current day
+ :kwarg month: optionnal month (as int). Defaults to current month
:kwarg year: optionnal year. Defaults to current year.
:kwarg calendar_name: the name of the calendar to which the links
should point.
"""
- if year is None or month is None:
- curdate = date.today()
- if year is None:
- year = curdate.year
+ cur_date = date.today()
+ if not year:
+ year = cur_date.year
+
+ if not month:
+ month = cur_date.month
- if month is None:
- month = curdate.month
+ if not day:
+ day = cur_date.day
- htmlcal = FedocalCalendar(year=year, month=month,
+ htmlcal = FedocalCalendar(day=day, year=year, month=month,
calendar_name=calendar_name)
curmonth_cal_nf = htmlcal.formatmonth()
diff --git a/fedocal/fedocallib/fedora_calendar.py b/fedocal/fedocallib/fedora_calendar.py
index 79c2c31..7bd70f4 100644
--- a/fedocal/fedocallib/fedora_calendar.py
+++ b/fedocal/fedocallib/fedora_calendar.py
@@ -24,13 +24,14 @@ class FedocalCalendar(HTMLCalendar):
html validation and some features 'locally required'
"""
- def __init__(self, year, month, calendar_name=None):
+ def __init__(self, year, month, day, calendar_name=None):
""" Constructor.
Stores the year and the month asked.
"""
super(FedocalCalendar, self).__init__()
self.year = year
self.month = month
+ self.day = day
self.calendar_name = calendar_name
def formatday(self, day, weekday):
@@ -56,6 +57,20 @@ class FedocalCalendar(HTMLCalendar):
return '<td class="%s">%s</td>' % (
self.cssclasses[weekday], link_day)
+ def formatweek(self, theweek, current=False):
+ """ Return a complete week as a table row.
+
+ :kwarg current: a boolean stating wether this is the current
+ week or not (the current week will have the css class:
+ current_week)
+ """
+ s = ''.join(self.formatday(d, wd) for (d, wd) in theweek)
+ if current:
+ return '<tr class="current_week">%s</tr>' % s
+ else:
+ return '<tr>%s</tr>' % s
+
+
def formatmonth(self, withyear=True):
"""
Return a formatted month as a html valid table.
@@ -69,7 +84,11 @@ class FedocalCalendar(HTMLCalendar):
#a(self.formatweekheader())
#a('\n')
for week in self.monthdays2calendar(self.year, self.month):
- a(self.formatweek(week))
+ days = [item[0] for item in week]
+ if self.day in days:
+ a(self.formatweek(week, current=True))
+ else:
+ a(self.formatweek(week))
a('\n')
a('</table>')
a('\n')
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit b9d3515d7a19c5fdf103fb21e9186bf63ae754f2
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Nov 6 09:02:48 2012 +0100
Remove TODO, now done
>---------------------------------------------------------------
fedocal/fedocallib/fedora_calendar.py | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/fedocal/fedocallib/fedora_calendar.py b/fedocal/fedocallib/fedora_calendar.py
index 932a142..79c2c31 100644
--- a/fedocal/fedocallib/fedora_calendar.py
+++ b/fedocal/fedocallib/fedora_calendar.py
@@ -37,8 +37,6 @@ class FedocalCalendar(HTMLCalendar):
"""
Return a day as a table cell.
"""
- ## TODO: Fix the links so that they point to something that
- # makes sense
cur_date = date.today()
if day == 0:
return '<td class="noday"> </td>' # day outside month