Repository :
http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
---------------------------------------------------------------
commit 7e6f69bc9c3794a9546ff47ad3c2778faefbc9fc
Author: Johan Cwiklinski <johan(a)x-tnd.be>
Date: Tue Nov 6 19:30:59 2012 +0100
Add month calendar navigation buttons
---------------------------------------------------------------
fedocal/fedocallib/fedora_calendar.py | 14 ++++++++++++++
fedocal/static/fedocal.css | 22 ++++++++++++++++++++--
fedocal/tests/test_fedocallib.py | 6 +++---
3 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/fedocal/fedocallib/fedora_calendar.py
b/fedocal/fedocallib/fedora_calendar.py
index 7bd70f4..578bf7e 100644
--- a/fedocal/fedocallib/fedora_calendar.py
+++ b/fedocal/fedocallib/fedora_calendar.py
@@ -16,6 +16,7 @@ license.
from datetime import date
from calendar import HTMLCalendar
+from calendar import month_name
import flask
@@ -71,6 +72,19 @@ class FedocalCalendar(HTMLCalendar):
return '<tr>%s</tr>' % s
+ def formatmonthname(self, theyear, themonth, withyear=True):
+ """
+ Return a month name as a table row.
+ """
+ if withyear:
+ s = '%s %s' % (month_name[themonth], theyear)
+ else:
+ s = '%s' % month_name[themonth]
+ prev_month_lnk = '<a class="button"
href="#"><</a>'
+ next_month_lnk = '<a class="button"
href="#">></a>'
+ return '<tr><th colspan="7" class="month">%s
%s %s</th></tr>' % (prev_month_lnk, s, next_month_lnk)
+
+
def formatmonth(self, withyear=True):
"""
Return a formatted month as a html valid table.
diff --git a/fedocal/static/fedocal.css b/fedocal/static/fedocal.css
index 59ebe41..da1591f 100644
--- a/fedocal/static/fedocal.css
+++ b/fedocal/static/fedocal.css
@@ -135,7 +135,7 @@ section nav {
}
#agenda .today {
- background-color: #fff7da;
+ background-color: rgba(255, 246, 213, .4);
}
.my_meetings .date {
@@ -255,10 +255,28 @@ table.month td.noday {
}
table.month td.today{
- background-color: #fff7da;
+ background-color: rgba(255, 246, 213, .8);
border-color: #000;
border-width: 1px;
/* ugly hack to work with table collapsed borders */
border-style: double solid solid double;
color: #000;
}
+
+th.month {
+ color: #666;
+ padding-bottom: .4em;
+}
+
+th.month a {
+ color: #4d4d4d;
+ display: inline-block;
+}
+
+th.month a:hover {
+ color: #fff;
+}
+
+th.month .ui-button-text {
+ padding: 0 .5em;
+}
diff --git a/fedocal/tests/test_fedocallib.py b/fedocal/tests/test_fedocallib.py
index 39e0c55..6c5e519 100644
--- a/fedocal/tests/test_fedocallib.py
+++ b/fedocal/tests/test_fedocallib.py
@@ -50,7 +50,7 @@ from tests import Modeltests, TODAY
RESULT_CALENDAR_HTML = """
<table class="month">
-<tr><th colspan="7" class="month">November
2012</th></tr>
+<tr><th colspan="7" class="month"><a
class="button" href="#"><</a> November 2012 <a
class="button" href="#">></a></th></tr>
<tr><td class="noday"> </td><td
class="noday"> </td><td
class="noday"> </td><td
class="thu">1</td><td class="fri">2</td><td
class="sat">3</td><td
class="sun">4</td></tr>
<tr><td class="mon">5</td><td
class="tue">6</td><td class="wed">7</td><td
class="thu">8</td><td class="fri">9</td><td
class="sat">10</td><td
class="sun">11</td></tr>
<tr><td class="mon">12</td><td
class="tue">13</td><td class="wed">14</td><td
class="thu">15</td><td class="fri">16</td><td
class="sat">17</td><td
class="sun">18</td></tr>
@@ -555,8 +555,8 @@ class Fedocallibtests(Modeltests):
'class="%s today">%s'%
(today.strftime('%a').lower(), today.day))
# Handle the change of month
expected_output = expected_output.replace(
- 'class="month">November 2012</th>',
- 'class="month">%s %s</th>' %
(today.strftime('%B'),
+ 'class="month"><a class="button"
href="#"><</a> November 2012 <a class="button"
href="#">></a></th>',
+ 'class="month"><a class="button"
href="#"><</a> %s %s <a class="button"
href="#">></a></th>' % (today.strftime('%B'),
today.year))
# Handle the current_week css class
expected_output = expected_output.split('\n')