[fedocal] master: Make use of the current day index to highlight in the agenda the current day (43ce8fc)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 43ce8fcfe7b6b5a1f51a6b98c2e9b3320f8846ad
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Nov 6 14:18:55 2012 +0100
Make use of the current day index to highlight in the agenda the current day
>---------------------------------------------------------------
fedocal/__init__.py | 2 ++
fedocal/static/fedocal.css | 4 ++++
fedocal/templates/agenda.html | 27 +++++++++++++++------------
3 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/fedocal/__init__.py b/fedocal/__init__.py
index cb624fe..89eda91 100644
--- a/fedocal/__init__.py
+++ b/fedocal/__init__.py
@@ -114,6 +114,7 @@ def calendar_fullday(calendar_name, year, month, day):
calendarobj = Calendar.by_id(SESSION, calendar_name)
week_start = fedocallib.get_start_week(year, month, day)
weekdays = fedocallib.get_week_days(year, month, day)
+ day_index = fedocallib.get_week_day_index(year, month, day)
meetings = fedocallib.get_meetings(SESSION, calendarobj, year,
month, day)
next_week = fedocallib.get_next_week(week_start.year,
@@ -129,6 +130,7 @@ def calendar_fullday(calendar_name, year, month, day):
calendar=calendarobj,
month=month_name,
weekdays=weekdays,
+ day_index=day_index,
meetings=meetings,
next_week=next_week,
prev_week=prev_week,
diff --git a/fedocal/static/fedocal.css b/fedocal/static/fedocal.css
index b9bb805..59ebe41 100644
--- a/fedocal/static/fedocal.css
+++ b/fedocal/static/fedocal.css
@@ -134,6 +134,10 @@ section nav {
width: 7em;
}
+#agenda .today {
+ background-color: #fff7da;
+}
+
.my_meetings .date {
border-left: solid 0px;
width: 100px;
diff --git a/fedocal/templates/agenda.html b/fedocal/templates/agenda.html
index 9a77a59..54af0b4 100644
--- a/fedocal/templates/agenda.html
+++ b/fedocal/templates/agenda.html
@@ -44,21 +44,24 @@
<tr>
<th class="time">{{ time_entry }}</th>
{% for meeting_list in meetings[time_entry] %}
- {% if meeting_list %}
+ {% if loop.index == day_index %}
+ <td class="today">
+ {% else %}
<td>
- {% for meeting in meeting_list %}
- <a class="event meeting_{{ meeting.meeting_id }}" href="{{ url_for('view_meeting',
- meeting_id=meeting.meeting_id) }}">
- {{ meeting.meeting_name }}
- </a>
- {% if not loop.last %}
- -
- {% endif %}
+ {% endif %}
+ {% if meeting_list %}
+ {% for meeting in meeting_list %}
+ <a class="event meeting_{{ meeting.meeting_id }}"
+ href="{{ url_for('view_meeting',
+ meeting_id=meeting.meeting_id) }}">
+ {{ meeting.meeting_name }}
+ </a>
+ {% if not loop.last %}
+ -
+ {% endif %}
{% endfor %}
+ {% endif %}
</td>
- {% else %}
- <td></td>
- {% endif %}
{% endfor %}
</tr>
{% endfor %}
10 years, 11 months
[fedocal] master: Make use of strftime instead of global variable and add the method get_week_day_index (64b83e5)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 64b83e5a666e6de8b1c6b0314f4656c966822012
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Nov 6 14:18:28 2012 +0100
Make use of strftime instead of global variable and add the method get_week_day_index
This method is aimed at highlighting in the front page of fedocal the current
day.
>---------------------------------------------------------------
README.html | 431 ++++++++++++++++++++++++++++++++++++++
fedocal/__init__.py | 2 +-
fedocal/fedocallib/__init__.py | 31 +++-
fedocal/tests/test_fedocallib.py | 13 +-
4 files changed, 468 insertions(+), 9 deletions(-)
diff --git a/README.html b/README.html
new file mode 100644
index 0000000..f44ff09
--- /dev/null
+++ b/README.html
@@ -0,0 +1,431 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta name="generator" content="Docutils 0.8.1: http://docutils.sourceforge.net/" />
+<title>fedocal</title>
+<meta name="author" content="Pierre-Yves Chibon <pingou@pingoured.fr>" />
+<style type="text/css">
+
+/*
+:Author: David Goodger (goodger(a)python.org)
+:Id: $Id: html4css1.css 7056 2011-06-17 10:50:48Z milde $
+:Copyright: This stylesheet has been placed in the public domain.
+
+Default cascading style sheet for the HTML output of Docutils.
+
+See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
+customize this style sheet.
+*/
+
+/* used to remove borders from tables and images */
+.borderless, table.borderless td, table.borderless th {
+ border: 0 }
+
+table.borderless td, table.borderless th {
+ /* Override padding for "table.docutils td" with "! important".
+ The right padding separates the table cells. */
+ padding: 0 0.5em 0 0 ! important }
+
+.first {
+ /* Override more specific margin styles with "! important". */
+ margin-top: 0 ! important }
+
+.last, .with-subtitle {
+ margin-bottom: 0 ! important }
+
+.hidden {
+ display: none }
+
+a.toc-backref {
+ text-decoration: none ;
+ color: black }
+
+blockquote.epigraph {
+ margin: 2em 5em ; }
+
+dl.docutils dd {
+ margin-bottom: 0.5em }
+
+object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
+ overflow: hidden;
+}
+
+/* Uncomment (and remove this text!) to get bold-faced definition list terms
+dl.docutils dt {
+ font-weight: bold }
+*/
+
+div.abstract {
+ margin: 2em 5em }
+
+div.abstract p.topic-title {
+ font-weight: bold ;
+ text-align: center }
+
+div.admonition, div.attention, div.caution, div.danger, div.error,
+div.hint, div.important, div.note, div.tip, div.warning {
+ margin: 2em ;
+ border: medium outset ;
+ padding: 1em }
+
+div.admonition p.admonition-title, div.hint p.admonition-title,
+div.important p.admonition-title, div.note p.admonition-title,
+div.tip p.admonition-title {
+ font-weight: bold ;
+ font-family: sans-serif }
+
+div.attention p.admonition-title, div.caution p.admonition-title,
+div.danger p.admonition-title, div.error p.admonition-title,
+div.warning p.admonition-title {
+ color: red ;
+ font-weight: bold ;
+ font-family: sans-serif }
+
+/* Uncomment (and remove this text!) to get reduced vertical space in
+ compound paragraphs.
+div.compound .compound-first, div.compound .compound-middle {
+ margin-bottom: 0.5em }
+
+div.compound .compound-last, div.compound .compound-middle {
+ margin-top: 0.5em }
+*/
+
+div.dedication {
+ margin: 2em 5em ;
+ text-align: center ;
+ font-style: italic }
+
+div.dedication p.topic-title {
+ font-weight: bold ;
+ font-style: normal }
+
+div.figure {
+ margin-left: 2em ;
+ margin-right: 2em }
+
+div.footer, div.header {
+ clear: both;
+ font-size: smaller }
+
+div.line-block {
+ display: block ;
+ margin-top: 1em ;
+ margin-bottom: 1em }
+
+div.line-block div.line-block {
+ margin-top: 0 ;
+ margin-bottom: 0 ;
+ margin-left: 1.5em }
+
+div.sidebar {
+ margin: 0 0 0.5em 1em ;
+ border: medium outset ;
+ padding: 1em ;
+ background-color: #ffffee ;
+ width: 40% ;
+ float: right ;
+ clear: right }
+
+div.sidebar p.rubric {
+ font-family: sans-serif ;
+ font-size: medium }
+
+div.system-messages {
+ margin: 5em }
+
+div.system-messages h1 {
+ color: red }
+
+div.system-message {
+ border: medium outset ;
+ padding: 1em }
+
+div.system-message p.system-message-title {
+ color: red ;
+ font-weight: bold }
+
+div.topic {
+ margin: 2em }
+
+h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
+h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
+ margin-top: 0.4em }
+
+h1.title {
+ text-align: center }
+
+h2.subtitle {
+ text-align: center }
+
+hr.docutils {
+ width: 75% }
+
+img.align-left, .figure.align-left, object.align-left {
+ clear: left ;
+ float: left ;
+ margin-right: 1em }
+
+img.align-right, .figure.align-right, object.align-right {
+ clear: right ;
+ float: right ;
+ margin-left: 1em }
+
+img.align-center, .figure.align-center, object.align-center {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.align-left {
+ text-align: left }
+
+.align-center {
+ clear: both ;
+ text-align: center }
+
+.align-right {
+ text-align: right }
+
+/* reset inner alignment in figures */
+div.align-right {
+ text-align: inherit }
+
+/* div.align-center * { */
+/* text-align: left } */
+
+ol.simple, ul.simple {
+ margin-bottom: 1em }
+
+ol.arabic {
+ list-style: decimal }
+
+ol.loweralpha {
+ list-style: lower-alpha }
+
+ol.upperalpha {
+ list-style: upper-alpha }
+
+ol.lowerroman {
+ list-style: lower-roman }
+
+ol.upperroman {
+ list-style: upper-roman }
+
+p.attribution {
+ text-align: right ;
+ margin-left: 50% }
+
+p.caption {
+ font-style: italic }
+
+p.credits {
+ font-style: italic ;
+ font-size: smaller }
+
+p.label {
+ white-space: nowrap }
+
+p.rubric {
+ font-weight: bold ;
+ font-size: larger ;
+ color: maroon ;
+ text-align: center }
+
+p.sidebar-title {
+ font-family: sans-serif ;
+ font-weight: bold ;
+ font-size: larger }
+
+p.sidebar-subtitle {
+ font-family: sans-serif ;
+ font-weight: bold }
+
+p.topic-title {
+ font-weight: bold }
+
+pre.address {
+ margin-bottom: 0 ;
+ margin-top: 0 ;
+ font: inherit }
+
+pre.literal-block, pre.doctest-block, pre.math {
+ margin-left: 2em ;
+ margin-right: 2em }
+
+span.classifier {
+ font-family: sans-serif ;
+ font-style: oblique }
+
+span.classifier-delimiter {
+ font-family: sans-serif ;
+ font-weight: bold }
+
+span.interpreted {
+ font-family: sans-serif }
+
+span.option {
+ white-space: nowrap }
+
+span.pre {
+ white-space: pre }
+
+span.problematic {
+ color: red }
+
+span.section-subtitle {
+ /* font-size relative to parent (h1..h6 element) */
+ font-size: 80% }
+
+table.citation {
+ border-left: solid 1px gray;
+ margin-left: 1px }
+
+table.docinfo {
+ margin: 2em 4em }
+
+table.docutils {
+ margin-top: 0.5em ;
+ margin-bottom: 0.5em }
+
+table.footnote {
+ border-left: solid 1px black;
+ margin-left: 1px }
+
+table.docutils td, table.docutils th,
+table.docinfo td, table.docinfo th {
+ padding-left: 0.5em ;
+ padding-right: 0.5em ;
+ vertical-align: top }
+
+table.docutils th.field-name, table.docinfo th.docinfo-name {
+ font-weight: bold ;
+ text-align: left ;
+ white-space: nowrap ;
+ padding-left: 0 }
+
+h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
+h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
+ font-size: 100% }
+
+ul.auto-toc {
+ list-style-type: none }
+
+</style>
+</head>
+<body>
+<div class="document" id="fedocal">
+<h1 class="title">fedocal</h1>
+<table class="docinfo" frame="void" rules="none">
+<col class="docinfo-name" />
+<col class="docinfo-content" />
+<tbody valign="top">
+<tr><th class="docinfo-name">Author:</th>
+<td>Pierre-Yves Chibon <<a class="reference external" href="mailto:pingou@pingoured.fr">pingou@pingoured.fr</a>></td></tr>
+</tbody>
+</table>
+<p>fedocal is a web based calendar application.</p>
+<div class="section" id="get-this-project">
+<h1>Get this project:</h1>
+<p>Source: <a class="reference external" href="https://github.com/pypingou/fedocal">https://github.com/pypingou/fedocal</a></p>
+</div>
+<div class="section" id="dependencies">
+<h1>Dependencies:</h1>
+<p>This project is a <a class="reference external" href="http://flask.pocoo.org/">Flask</a> application. The calendars and meetings are
+stored into a relational database using <a class="reference external" href="http://www.sqlalchemy.org/">SQLAlchemy</a> as Object Relational
+Mapper (ORM). fedocal provides an <a class="reference external" href="http://en.wikipedia.org/wiki/ICalendar">iCal</a> feed for each calendar and relies
+on <a class="reference external" href="http://vobject.skyhouseconsulting.com/">python-vobject</a> for this.</p>
+<p>The dependency list is therefore:</p>
+<ul class="simple">
+<li><a class="reference external" href="http://www.python.org">python</a> (2.5 minimum)</li>
+<li><a class="reference external" href="http://flask.pocoo.org/">python-flask</a></li>
+<li><a class="reference external" href="http://packages.python.org/Flask-WTF/">python-flask-wtf</a></li>
+<li><a class="reference external" href="http://wtforms.simplecodes.com/docs/1.0.1/">python-wtforms</a></li>
+<li><a class="reference external" href="http://www.sqlalchemy.org/">python-sqlalchemy</a></li>
+<li><a class="reference external" href="http://vobject.skyhouseconsulting.com/">python-vobject</a></li>
+<li><a class="reference external" href="http://packages.python.org/kitchen/">python-kitchen</a></li>
+</ul>
+</div>
+<div class="section" id="running-a-development-instance">
+<h1>Running a development instance:</h1>
+<p>Clone the source:</p>
+<pre class="literal-block">
+git clone https://github.com/pypingou/fedocal.git
+</pre>
+<p>Copy the configuration file:</p>
+<pre class="literal-block">
+cp fedocal.cfg.sample fedocal.cfg
+</pre>
+<p>Adjust the configuration file (secret key, database URL, admin group...)</p>
+<p>Create the database scheme:</p>
+<pre class="literal-block">
+python fedocal/fedocallib/model.py
+</pre>
+<dl class="docutils">
+<dt>Run the server::</dt>
+<dd>python fedocal/__init__.py</dd>
+</dl>
+<p>You should be able to access the server at <a class="reference external" href="http://localhost:5000">http://localhost:5000</a></p>
+</div>
+<div class="section" id="deploying-this-project">
+<h1>Deploying this project:</h1>
+<p>Instruction to deploy this application is available on the
+<a class="reference external" href="http://flask.pocoo.org/docs/deploying/">Flask deployment documentation</a> page.</p>
+<blockquote>
+<strong>My approach.</strong></blockquote>
+<p>Below is the approach I took to deploy the instance on a local (test) machine.</p>
+<p>Retrieve the sources:</p>
+<pre class="literal-block">
+cd /srv/
+git clone <repo>
+cd fedocal
+</pre>
+<p>Copy the configuration file:</p>
+<pre class="literal-block">
+cp fedocal.cfg.sample fedocal.cfg
+</pre>
+<p>Adjust the configuration file (secret key, database URL, admin group...)</p>
+<p>Create the database scheme:</p>
+<pre class="literal-block">
+python fedocal/fedocallib/model.py
+</pre>
+<p>Then configure apache:</p>
+<pre class="literal-block">
+sudo vim /etc/httd/conf.d/wsgi.conf
+</pre>
+<p>and put in this file:</p>
+<pre class="literal-block">
+WSGIScriptAlias /fedocal /var/www/wsgi/fedocal.wsgi
+<Directory /var/www/wsgi/>
+ Order deny,allow
+ Allow from all
+</Directory>
+</pre>
+<p>Then create the file /var/www/wsgi/fedocal.wsgi with:</p>
+<pre class="literal-block">
+import sys
+sys.path.insert(0, '/mnt/fedocal/')
+
+import fedocal
+application = fedocal.APP
+</pre>
+<p>Then restart apache and you should be able to access the website on
+<a class="reference external" href="http://localhost/fedocal">http://localhost/fedocal</a></p>
+</div>
+<div class="section" id="testing">
+<h1>Testing:</h1>
+<p>This project contains unit-tests allowing you to check if your server
+has all the dependencies correctly set.</p>
+<p>To run them:</p>
+<pre class="literal-block">
+./run_tests.sh
+</pre>
+</div>
+<div class="section" id="license">
+<h1>License:</h1>
+<p>This project is licensed GPLv3+.</p>
+</div>
+</div>
+</body>
+</html>
diff --git a/fedocal/__init__.py b/fedocal/__init__.py
index 6c2adfe..cb624fe 100644
--- a/fedocal/__init__.py
+++ b/fedocal/__init__.py
@@ -122,7 +122,7 @@ def calendar_fullday(calendar_name, year, month, day):
week_start.month, week_start.day)
auth_form = forms.LoginForm()
admin = is_admin()
- month_name = fedocallib.MONTH[week_start.month - 1]
+ month_name = week_start.strftime('%B')
curmonth_cal = fedocallib.get_html_monthly_cal(year=year,
month=month, calendar_name=calendar_name)
return flask.render_template('agenda.html',
diff --git a/fedocal/fedocallib/__init__.py b/fedocal/fedocallib/__init__.py
index 5f1d09d..c4b1c6b 100644
--- a/fedocal/fedocallib/__init__.py
+++ b/fedocal/fedocallib/__init__.py
@@ -30,11 +30,6 @@ from model import Calendar, Reminder, Meeting
from fedora_calendar import FedocalCalendar
-MONTH = ['January', 'February', 'March', 'April', 'May', 'June', 'July',
- 'August', 'September', 'October', 'November', 'December']
-
-WEEK = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday',
- 'Saturday', 'Sunday']
HOURS = ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09',
'10', '11', '12', '13', '14', '15', '16', '17', '18', '19',
@@ -160,6 +155,7 @@ def get_week_days(year=None, month=None, day=None):
This function provides the 'Day date' string used at the header of
the agenda table.
+
:kwarg year: year to consider when searching a week.
:kwarg month: month to consider when searching a week.
:kwarg day: day to consider when searching a week.
@@ -171,11 +167,34 @@ def get_week_days(year=None, month=None, day=None):
weekdays = []
for i in range(0, 7):
curday = week_start + timedelta(days=i)
- curday_txt = "%s %s" % (WEEK[curday.weekday()], curday.day)
+ curday_txt = curday.strftime('%A %d')
weekdays.append(curday_txt)
return weekdays
+def get_week_day_index(year=None, month=None, day=None):
+ """ For a specified date, find the index of this day in the week.
+
+ This function provides the 'Day index' string used to highlight the
+ current day in the calendar view.
+
+ :kwarg year: year to consider when searching a week.
+ :kwarg month: month to consider when searching a week.
+ :kwarg day: day to consider when searching a week.
+ :return a list of 'Day date' string corresponding to the week asked
+ either based on the current utc date or based on the information
+ specified.
+ """
+ today = date.today()
+ if not year:
+ year = today.year
+ if not month:
+ month = today.month
+ if not day:
+ day = today.day
+ return date(year, month, day).isoweekday()
+
+
def get_meetings(session, calendar, year=None, month=None, day=None):
""" Return a hash of {time: [meeting]} for the asked week. The week
is returned based either on the current utc week or based on the
diff --git a/fedocal/tests/test_fedocallib.py b/fedocal/tests/test_fedocallib.py
index 8cf02c7..39e0c55 100644
--- a/fedocal/tests/test_fedocallib.py
+++ b/fedocal/tests/test_fedocallib.py
@@ -170,8 +170,8 @@ class Fedocallibtests(Modeltests):
def test_get_week_days(self):
""" Test the get_week_days function. """
- expectdays = ['Monday 1', 'Tuesday 2', 'Wednesday 3',
- 'Thursday 4', 'Friday 5', 'Saturday 6', 'Sunday 7']
+ expectdays = ['Monday 01', 'Tuesday 02', 'Wednesday 03',
+ 'Thursday 04', 'Friday 05', 'Saturday 06', 'Sunday 07']
days = fedocallib.get_week_days(2012, 10, 3)
self.assertNotEqual(days, None)
self.assertEqual(days, expectdays)
@@ -569,6 +569,15 @@ class Fedocallibtests(Modeltests):
self.assertEqual(output.strip(),
"\n".join(expected_output).strip())
+ def test_get_week_day_index(self):
+ """ Test the get_week_day_index function. """
+ output = fedocallib.get_week_day_index(year=2012, month=11,
+ day=6)
+ self.assertEqual(output, 2)
+ today = date.today()
+ output = fedocallib.get_week_day_index()
+ self.assertEqual(output, today.isoweekday())
+
if __name__ == '__main__':
SUITE = unittest.TestLoader().loadTestsFromTestCase(Fedocallibtests)
10 years, 11 months
[fedocal] master: Fix the test test_get_html_monthly_cal for the latest changes (2ebadfc)
by Pierre-YvesChibon
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 2ebadfc41e2754c3bc8047f669e25d7f6d678c3b
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Nov 6 10:03:01 2012 +0100
Fix the test test_get_html_monthly_cal for the latest changes
>---------------------------------------------------------------
fedocal/tests/test_fedocallib.py | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/fedocal/tests/test_fedocallib.py b/fedocal/tests/test_fedocallib.py
index deb28cf..8cf02c7 100644
--- a/fedocal/tests/test_fedocallib.py
+++ b/fedocal/tests/test_fedocallib.py
@@ -547,15 +547,27 @@ class Fedocallibtests(Modeltests):
def test_get_html_monthly_cal(self):
""" Test the get_html_monthly_call function. """
today = date.today()
- output = fedocallib.get_html_monthly_cal(today.month, today.year)
+ output = fedocallib.get_html_monthly_cal(today.day,today.month,
+ today.year)
+ # Handle the today css class
expected_output = RESULT_CALENDAR_HTML.replace(
'class="%s">%s' % (today.strftime('%a').lower(), today.day),
'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'),
today.year))
- self.assertEqual(output.strip(), expected_output.strip())
+ # Handle the current_week css class
+ expected_output = expected_output.split('\n')
+ cnt = 0
+ while cnt < len(expected_output):
+ if '>%s</td>' % today.day in expected_output[cnt]:
+ expected_output[cnt] = expected_output[cnt].replace(
+ '<tr>', '<tr class="current_week">')
+ cnt = cnt + 1
+ self.assertEqual(output.strip(),
+ "\n".join(expected_output).strip())
if __name__ == '__main__':
10 years, 11 months
[fedocal] master: Give the day to FedoraCalendar as well so that we can pin point the current week. (12007cc)
by Pierre-YvesChibon
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')
10 years, 11 months
[fedocal] master: Fix event display ajax call (c238f3d)
by trasher@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit c238f3dcd4ef8e00dc918762bcad90257db442a7
Author: Johan Cwiklinski <johan(a)x-tnd.be>
Date: Tue Nov 6 09:36:58 2012 +0100
Fix event display ajax call
>---------------------------------------------------------------
fedocal/templates/agenda.html | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/fedocal/templates/agenda.html b/fedocal/templates/agenda.html
index 812202a..9a77a59 100644
--- a/fedocal/templates/agenda.html
+++ b/fedocal/templates/agenda.html
@@ -47,7 +47,7 @@
{% if meeting_list %}
<td>
{% for meeting in meeting_list %}
- <a class="event" href="{{ url_for('view_meeting',
+ <a class="event meeting_{{ meeting.meeting_id }}" href="{{ url_for('view_meeting',
meeting_id=meeting.meeting_id) }}">
{{ meeting.meeting_name }}
</a>
@@ -72,8 +72,8 @@
<script type="text/javascript">
$(function(){
$('.event').click(function(){
- var _id = $(this).attr('id');
- var _meetId = _id.replace('meeting_', '');
+ var _cls = $(this).attr('class');
+ var _meetId = _cls.replace('event meeting_', '');
var _url = "{{ url_for('view_meeting', meeting_id=0) }}".replace('/0/','/');
$.ajax({
url: _url + _meetId + '/0/',
10 years, 11 months
[fedocal] master: Fix "today" cell borders (well... hope so :p) (d69fc6b)
by trasher@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit d69fc6b7d99e260a52e4cd66056c5f10d2685df1
Author: Johan Cwiklinski <johan(a)x-tnd.be>
Date: Tue Nov 6 09:21:05 2012 +0100
Fix "today" cell borders (well... hope so :p)
>---------------------------------------------------------------
fedocal/static/fedocal.css | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/fedocal/static/fedocal.css b/fedocal/static/fedocal.css
index 1601415..b9bb805 100644
--- a/fedocal/static/fedocal.css
+++ b/fedocal/static/fedocal.css
@@ -252,6 +252,9 @@ table.month td.noday {
table.month td.today{
background-color: #fff7da;
- border: 1px solid #000;
+ border-color: #000;
+ border-width: 1px;
+ /* ugly hack to work with table collapsed borders */
+ border-style: double solid solid double;
color: #000;
}
10 years, 11 months
[fedocal] master: No comma between css class said the boss (f46501b)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit f46501b6b68b84d0b7c96b7362b72302435cb3b6
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Nov 6 09:04:11 2012 +0100
No comma between css class said the boss
>---------------------------------------------------------------
fedocal/tests/test_fedocallib.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fedocal/tests/test_fedocallib.py b/fedocal/tests/test_fedocallib.py
index abcfc37..deb28cf 100644
--- a/fedocal/tests/test_fedocallib.py
+++ b/fedocal/tests/test_fedocallib.py
@@ -550,7 +550,7 @@ class Fedocallibtests(Modeltests):
output = fedocallib.get_html_monthly_cal(today.month, today.year)
expected_output = RESULT_CALENDAR_HTML.replace(
'class="%s">%s' % (today.strftime('%a').lower(), today.day),
- 'class="%s, today">%s'% (today.strftime('%a').lower(), today.day))
+ 'class="%s today">%s'% (today.strftime('%a').lower(), today.day))
expected_output = expected_output.replace(
'class="month">November 2012</th>',
'class="month">%s %s</th>' % (today.strftime('%B'),
10 years, 11 months
[fedocal] master: Fix the test test_get_html_monthly_cal, it should now works whenever run (1d112fc)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 1d112fc79df02e0df51fbd003b5ae1a84bd03ecc
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Nov 6 09:03:22 2012 +0100
Fix the test test_get_html_monthly_cal, it should now works whenever run
>---------------------------------------------------------------
fedocal/tests/test_fedocallib.py | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/fedocal/tests/test_fedocallib.py b/fedocal/tests/test_fedocallib.py
index 8451add..abcfc37 100644
--- a/fedocal/tests/test_fedocallib.py
+++ b/fedocal/tests/test_fedocallib.py
@@ -48,7 +48,7 @@ import fedocallib
from fedocallib import model
from tests import Modeltests, TODAY
-RESULT_201211_HTML = """
+RESULT_CALENDAR_HTML = """
<table class="month">
<tr><th colspan="7" class="month">November 2012</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>
@@ -546,8 +546,16 @@ class Fedocallibtests(Modeltests):
def test_get_html_monthly_cal(self):
""" Test the get_html_monthly_call function. """
- output = fedocallib.get_html_monthly_cal(11, 2012)
- self.assertEqual(output.strip(), RESULT_201211_HTML.strip())
+ today = date.today()
+ output = fedocallib.get_html_monthly_cal(today.month, today.year)
+ expected_output = RESULT_CALENDAR_HTML.replace(
+ 'class="%s">%s' % (today.strftime('%a').lower(), today.day),
+ 'class="%s, today">%s'% (today.strftime('%a').lower(), today.day))
+ expected_output = expected_output.replace(
+ 'class="month">November 2012</th>',
+ 'class="month">%s %s</th>' % (today.strftime('%B'),
+ today.year))
+ self.assertEqual(output.strip(), expected_output.strip())
if __name__ == '__main__':
10 years, 11 months
[fedocal] master: Remove TODO, now done (b9d3515)
by pingou@fedorahosted.org
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
10 years, 11 months
[fedocal] master: HTML id was duplicated and is not really usefull (fa76a2b)
by trasher@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit fa76a2b400cc4224070c10c69fd1eafcd77e70e3
Author: Johan Cwiklinski <johan(a)x-tnd.be>
Date: Tue Nov 6 09:04:11 2012 +0100
HTML id was duplicated and is not really usefull
>---------------------------------------------------------------
fedocal/templates/agenda.html | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/fedocal/templates/agenda.html b/fedocal/templates/agenda.html
index fec9462..812202a 100644
--- a/fedocal/templates/agenda.html
+++ b/fedocal/templates/agenda.html
@@ -48,8 +48,7 @@
<td>
{% for meeting in meeting_list %}
<a class="event" href="{{ url_for('view_meeting',
- meeting_id=meeting.meeting_id) }}"
- id="meeting_{{ meeting.meeting_id }}">
+ meeting_id=meeting.meeting_id) }}">
{{ meeting.meeting_name }}
</a>
{% if not loop.last %}
10 years, 11 months