[fedocal] master: Update the dependency list in the README (85a7c31)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 85a7c31c6049a3478545e22a0ac87a909fc6832e
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 8 19:26:44 2012 +0100
Update the dependency list in the README
>---------------------------------------------------------------
README.rst | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/README.rst b/README.rst
index dbd9550..8121773 100644
--- a/README.rst
+++ b/README.rst
@@ -27,12 +27,14 @@ Dependencies:
.. _python-kitchen: http://packages.python.org/kitchen/
.. _alembic: https://bitbucket.org/zzzeek/alembic
.. _python-alembic: http://pypi.python.org/pypi/alembic
+.. _pytz: http://pytz.sourceforge.net/
This project is a `Flask`_ application. The calendars and meetings are
stored into a relational database using `SQLAlchemy`_ as Object Relational
Mapper (ORM) and `alembic`_ to handle database scheme changes.
fedocal provides an `iCal`_ feed for each calendar and relies on
-`python-vobject`_ for this.
+`python-vobject`_ for this. Finally, `pytz`_ is used to handle the timezone
+changes.
The dependency list is therefore:
@@ -45,6 +47,7 @@ The dependency list is therefore:
- `python-vobject`_
- `python-kitchen`_
- `python-alembic`_
+- `pytz`_
Running a development instance:
11 years
[fedocal] master: Update requirements.txt with the latest dependencies (51e2d1e)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 51e2d1eb143071dbf6e24c3ef18265ff77f47c72
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 8 19:02:07 2012 +0100
Update requirements.txt with the latest dependencies
>---------------------------------------------------------------
requirements.txt | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/requirements.txt b/requirements.txt
index 62d5ab5..56e8a6e 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -7,3 +7,5 @@ Flask-wtf
vobject
kitchen
python-fedora
+pyzt
+python-alembic
11 years
[fedocal] master: Fix unit-test for changes in agenda layout (809477a)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 809477a2eaee7d3aec5b15198da41f2a33ac8ad8
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 8 17:27:52 2012 +0100
Fix unit-test for changes in agenda layout
>---------------------------------------------------------------
fedocal/tests/test_fedocallib.py | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/fedocal/tests/test_fedocallib.py b/fedocal/tests/test_fedocallib.py
index 2c472d5..c71d329 100644
--- a/fedocal/tests/test_fedocallib.py
+++ b/fedocal/tests/test_fedocallib.py
@@ -184,7 +184,7 @@ class Fedocallibtests(Modeltests):
meetings = fedocallib.get_meetings(self.session, calendar)
self.assertNotEqual(meetings, None)
cnt = 0
- for meeting in meetings['19h - 20h']:
+ for meeting in meetings['19h00']:
if meeting is not None:
for meet in meeting:
self.assertTrue(meet.meeting_name in
@@ -193,14 +193,14 @@ class Fedocallibtests(Modeltests):
else:
cnt = cnt + 1
self.assertEqual(cnt, 6)
- self.assertEqual(meetings['15h - 16h'][0], None)
+ self.assertEqual(meetings['15h00'][0], None)
new_day = TODAY + timedelta(days=10)
meetings = fedocallib.get_meetings(self.session, calendar,
new_day.year, new_day.month, new_day.day)
self.assertNotEqual(meetings, None)
cnt = 0
- for meeting in meetings['14h - 15h']:
+ for meeting in meetings['14h00']:
if meeting is not None:
for meet in meeting:
self.assertEqual(meet.meeting_name, 'test-meeting2')
@@ -208,7 +208,7 @@ class Fedocallibtests(Modeltests):
cnt = cnt + 1
self.assertEqual(cnt, 6)
cnt = 0
- for meeting in meetings['15h - 16h']:
+ for meeting in meetings['15h00']:
if meeting is not None:
for meet in meeting:
self.assertEqual(meet.meeting_name, 'test-meeting2')
@@ -216,7 +216,7 @@ class Fedocallibtests(Modeltests):
cnt = cnt + 1
self.assertEqual(cnt, 6)
cnt = 0
- for meeting in meetings['02h - 03h']:
+ for meeting in meetings['02h00']:
if meeting is not None:
for meet in meeting:
self.assertEqual(meet.meeting_name,
@@ -224,7 +224,7 @@ class Fedocallibtests(Modeltests):
else:
cnt = cnt + 1
self.assertEqual(cnt, 6)
- self.assertEqual(meetings['19h - 20h'][0], None)
+ self.assertEqual(meetings['19h00'][0], None)
def test_get_meetings_with_multiple_same_time(self):
""" Test the get_meetings function when there are several
@@ -233,7 +233,7 @@ class Fedocallibtests(Modeltests):
calendar = model.Calendar.by_id(self.session, 'test_calendar4')
meetings = fedocallib.get_meetings(self.session, calendar)
cnt = 0
- for meeting in meetings['14h - 15h']:
+ for meeting in meetings['14h00']:
if meeting is not None:
for meet in meeting:
self.assertTrue(meet.meeting_name in
@@ -242,7 +242,7 @@ class Fedocallibtests(Modeltests):
cnt = cnt + 1
self.assertEqual(cnt, 6)
cnt = 0
- for meeting in meetings['15h - 16h']:
+ for meeting in meetings['15h00']:
if meeting is not None:
for meet in meeting:
self.assertTrue(meet.meeting_name in
11 years
[fedocal] master: Start implementing the user's timezone for logged user (fe70a4e)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit fe70a4e1a8354d7813c01e9de56de90641c81fd9
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 8 17:23:03 2012 +0100
Start implementing the user's timezone for logged user
>---------------------------------------------------------------
fedocal/__init__.py | 55 +++++++++++++++++++++++++++--------
fedocal/fedocallib/__init__.py | 36 +++++++++++++++++------
fedocal/templates/add_meeting.html | 4 +-
fedocal/templates/agenda.html | 2 +-
4 files changed, 71 insertions(+), 26 deletions(-)
diff --git a/fedocal/__init__.py b/fedocal/__init__.py
index e67c86c..c73b9db 100644
--- a/fedocal/__init__.py
+++ b/fedocal/__init__.py
@@ -59,6 +59,10 @@ SESSION = fedocallib.create_session(CONFIG.get('fedocal', 'db_url'))
@APP.context_processor
def inject_calendars():
+ """ With this decorator we add the list of all the calendars
+ available to all the function, so the variable calendars is available
+ in all templates.
+ """
calendars = Calendar.get_all(SESSION)
return dict(calendars=calendars)
@@ -75,8 +79,11 @@ def reverse_filter(weekdays):
@APP.teardown_request
def shutdown_session(exception=None):
+ """ Remove the DB session at the end of each request. """
SESSION.remove()
+
+## Local function
def is_admin():
""" Return wether the user is admin for this application or not. """
if not flask.g.fas_user:
@@ -87,6 +94,16 @@ def is_admin():
return False
+def get_timezone():
+ """ Return the user's timezone, default to UTC. """
+ tzone = 'UTC'
+ if flask.g.fas_user:
+ if flask.g.fas_user['timezone']:
+ tzone = flask.g.fas_user['timezone']
+ return tzone
+
+
+## Flask application
@APP.route('/')
def index():
""" Displays the index page with containing the first calendar (by
@@ -129,8 +146,9 @@ def calendar_fullday(calendar_name, year, month, day):
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)
+ tzone = get_timezone()
meetings = fedocallib.get_meetings(SESSION, calendarobj, year,
- month, day)
+ month, day, tzone=tzone)
next_week = fedocallib.get_next_week(week_start.year,
week_start.month, week_start.day)
prev_week = fedocallib.get_previous_week(week_start.year,
@@ -146,6 +164,7 @@ def calendar_fullday(calendar_name, year, month, day):
weekdays=weekdays,
day_index=day_index,
meetings=meetings,
+ tzone=tzone,
next_week=next_week,
prev_week=prev_week,
auth_form=auth_form,
@@ -260,6 +279,7 @@ def add_meeting(calendar_name):
if not flask.g.fas_user:
return flask.redirect(flask.url_for('index'))
form = forms.AddMeetingForm()
+ tzone = get_timezone()
calendarobj = Calendar.by_id(SESSION, calendar_name)
if form.validate_on_submit():
if not fedocallib.is_user_managing_in_calendar(SESSION,
@@ -271,13 +291,14 @@ def add_meeting(calendar_name):
form.meeting_time_start.data):
flask.flash('The date you entered is in the past')
return flask.redirect(flask.url_for('add_meeting',
- calendar_name=calendarobj.calendar_name))
+ calendar_name=calendarobj.calendar_name, form=form,
+ tzone=tzone))
elif int(form.meeting_time_start.data) > \
int(form.meeting_time_stop.data):
flask.flash('The start time you have entered is later than'\
' the stop time.')
flask.render_template('add_meeting.html',
- calendar=calendarobj, form=form)
+ calendar=calendarobj, form=form, tzone=tzone)
elif bool(calendarobj.calendar_multiple_meetings) or \
(not bool(calendarobj.calendar_multiple_meetings) and \
fedocallib.agenda_is_free(SESSION,
@@ -299,16 +320,24 @@ def add_meeting(calendar_name):
region = None
meeting_end_date = form.meeting_date_end.data
if not meeting_end_date:
- meeting_end_date = form.meeting_date.date
+ meeting_end_date = form.meeting_date.data
+
+ tzone = get_timezone()
+ meeting_time_start = fedocallib.convert_time(
+ datetime.datetime(2000, 1, 1,
+ int(form.meeting_time_start.data), 0),
+ tzone, 'UTC')
+ meeting_time_stop = fedocallib.convert_time(
+ datetime.datetime(2000, 1, 1,
+ int(form.meeting_time_stop.data), 0),
+ tzone, 'UTC')
meeting = Meeting(
meeting_name=form.meeting_name.data,
meeting_manager=manager,
meeting_date=form.meeting_date.data,
meeting_date_end=meeting_end_date,
- meeting_time_start=datetime.time(int(
- form.meeting_time_start.data)),
- meeting_time_stop=datetime.time(int(
- form.meeting_time_stop.data)),
+ meeting_time_start=meeting_time_start.time(),
+ meeting_time_stop=meeting_time_stop.time(),
meeting_information=form.information.data,
calendar_name=calendarobj.calendar_name,
reminder_id=None,
@@ -322,7 +351,7 @@ def add_meeting(calendar_name):
print 'add_meeting:', err
flask.flash('Could not add this meeting to this calendar')
return flask.render_template('add_meeting.html',
- calendar=calendarobj, form=form)
+ calendar=calendarobj, form=form, tzone=tzone)
if form.remind_when.data and form.remind_who.data:
reminder = Reminder(form.remind_when.data,
@@ -337,7 +366,7 @@ def add_meeting(calendar_name):
print 'add_meeting:', err
flask.flash('Could not add this reminder to this meeting')
return flask.render_template('add_meeting.html',
- calendar=calendarobj, form=form)
+ calendar=calendarobj, form=form, tzone=tzone)
try:
SESSION.commit()
@@ -345,7 +374,7 @@ def add_meeting(calendar_name):
flask.flash(
'Something went wrong while commiting to the DB.')
flask.render_template('add_meeting.html',
- calendar=calendarobj, form=form)
+ calendar=calendarobj, form=form, tzone=tzone)
flask.flash('Meeting added')
return flask.redirect(flask.url_for('calendar',
@@ -354,9 +383,9 @@ def add_meeting(calendar_name):
flask.flash(
'The start time you have entered is already occupied.')
return flask.render_template('add_meeting.html',
- calendar=calendarobj, form=form)
+ calendar=calendarobj, form=form, tzone=tzone)
return flask.render_template('add_meeting.html',
- calendar=calendarobj, form=form)
+ calendar=calendarobj, form=form, tzone=tzone)
# CLA + 1
diff --git a/fedocal/fedocallib/__init__.py b/fedocal/fedocallib/__init__.py
index 220fe5b..d69cbe0 100644
--- a/fedocal/fedocallib/__init__.py
+++ b/fedocal/fedocallib/__init__.py
@@ -15,6 +15,7 @@ license.
"""
import vobject
+import pytz
from datetime import datetime
from datetime import date
@@ -36,6 +37,21 @@ HOURS = ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09',
'20', '21', '22', '23', '24']
+def convert_time(timeobj, tzfrom, tzto):
+ """ Convert a given datetime object from a specified timezone to
+ the other specified.
+
+ :arg timeobj: a datetime object to convert
+ :arg tzfrom: the timezone from which to convert
+ :arg tzto: the timezone to which to convert
+ """
+ timez_from = pytz.timezone(tzfrom)
+ timez_to = pytz.timezone(tzto)
+ timeobj_from = timez_from.localize(timeobj)
+ timeobj_to = timeobj_from.astimezone(timez_to)
+ return timeobj_to
+
+
def create_session(db_url, debug=False, pool_recycle=3600):
""" Create the Session object to use to query the database.
@@ -193,7 +209,8 @@ def get_week_day_index(year=None, month=None, day=None):
return date(year, month, day).isoweekday()
-def get_meetings(session, calendar, year=None, month=None, day=None):
+def get_meetings(session, calendar, year=None, month=None, day=None,
+ tzone='UTC'):
""" 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
information provided.
@@ -203,14 +220,15 @@ def get_meetings(session, calendar, year=None, month=None, day=None):
: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.
+ :kwarg tzone: the timezone in which the meetings should be displayed
+ defaults to UTC.
"""
week = get_week(session, calendar, year, month, day)
meetings = {}
- cnt = 1
+ fmt = '%Hh%M'
for hour in HOURS[:-1]:
- key = '%sh - %sh' % (hour, HOURS[cnt])
+ key = '%sh00' % (hour)
meetings[key] = [None for cnt2 in range(0, 7)]
- cnt = cnt + 1
for meeting in week.meetings:
start = meeting.meeting_time_start.hour
stop = meeting.meeting_time_stop.hour
@@ -220,12 +238,10 @@ def get_meetings(session, calendar, year=None, month=None, day=None):
cnt = 0
for item in order:
start_time = start + item
- stop_time = stop - invorder[cnt]
- if len(str(start_time)) == 1:
- start_time = '0%i' % start_time
- if len(str(stop_time)) == 1:
- stop_time = '0%i' % stop_time
- key = '%sh - %sh' % (start_time, stop_time)
+ key = convert_time(
+ datetime(2000, 01, 01, int(start_time), 0, 0),
+ 'UTC',
+ tzone).strftime(fmt)
day = meeting.meeting_date.weekday()
if key in meetings:
if meetings[key][day]:
diff --git a/fedocal/templates/add_meeting.html b/fedocal/templates/add_meeting.html
index c5b2b07..10043ee 100644
--- a/fedocal/templates/add_meeting.html
+++ b/fedocal/templates/add_meeting.html
@@ -14,8 +14,8 @@
<table>
{{ render_field_in_row(form.meeting_name) }}
{{ render_field_in_row(form.meeting_date) }}
- {{ render_field_in_row(form.meeting_time_start) }}
- {{ render_field_in_row(form.meeting_time_stop) }}
+ {{ render_field_in_row(form.meeting_time_start, after="%s time" % tzone) }}
+ {{ render_field_in_row(form.meeting_time_stop, after="%s time" % tzone) }}
{{ render_field_in_row(form.information) }}
{% if calendar.calendar_regional_meetings %}
{{ render_field_in_row(form.meeting_region) }}
diff --git a/fedocal/templates/agenda.html b/fedocal/templates/agenda.html
index a22d63b..42d5b50 100644
--- a/fedocal/templates/agenda.html
+++ b/fedocal/templates/agenda.html
@@ -33,7 +33,7 @@
<div id='agenda'>
<table>
<tr>
- <th></th>
+ <th>{{ tzone }} time</th>
{% for day in weekdays %}
<th> {{ day.strftime('%A %d') }}</th>
{% endfor %}
11 years
[fedocal] master: Add unit-test for the fedora_calendar file (93afa39)
by Pierre-YvesChibon
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 93afa39df301e38d0f907fbb9338faf78fd9bd67
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 8 16:13:15 2012 +0100
Add unit-test for the fedora_calendar file
>---------------------------------------------------------------
fedocal/tests/test_fedora_calendar.py | 149 +++++++++++++++++++++++++++++++++
1 files changed, 149 insertions(+), 0 deletions(-)
diff --git a/fedocal/tests/test_fedora_calendar.py b/fedocal/tests/test_fedora_calendar.py
new file mode 100644
index 0000000..5209f2d
--- /dev/null
+++ b/fedocal/tests/test_fedora_calendar.py
@@ -0,0 +1,149 @@
+#!/usr/bin/python
+#-*- coding: utf-8 -*-
+
+"""
+ (c) 2012 - Copyright Pierre-Yves Chibon
+ Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
+
+ Distributed under License GPLv3 or later
+ You can find a copy of this license on the website
+ http://www.gnu.org/licenses/gpl.html
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ fedocal.model test script
+"""
+
+__requires__ = ['SQLAlchemy >= 0.7']
+import pkg_resources
+
+import unittest
+import sys
+import os
+
+from datetime import date
+
+sys.path.insert(0, os.path.join(os.path.dirname(
+ os.path.abspath(__file__)), '..'))
+
+from fedocallib.fedora_calendar import FedocalCalendar
+from tests import Modeltests, DB_PATH
+
+
+class FedocalCalendartests(Modeltests):
+ """ fedora_calendar application tests. """
+
+
+ def test_formatday(self):
+ """ Test the formatday function. """
+ today = date.today()
+ cal = FedocalCalendar(today.year, today.month, today.day)
+ self.assertEqual(cal.formatday(6, 1),
+ '<td class="tue">6</td>')
+ self.assertEqual(cal.formatday(7, 3),
+ '<td class="thu">7</td>')
+ self.assertEqual(cal.formatday(today.day, today.isoweekday() - 1),
+ '<td class="%s today">%s</td>' % (
+ today.strftime('%a').lower(), today.day)
+ )
+
+ def test_formatweek(self):
+ """ Test the formatweek function. """
+ today = date.today()
+ cal = FedocalCalendar(today.year, today.month, today.day)
+ self.assertEqual(cal.formatweek([(1, 1), (2, 2)]),
+ '<tr><td class="tue">1</td><td class="wed">2</td></tr>')
+ self.assertEqual(cal.formatweek([(0, 1), (1, 2)]),
+ '<tr><td class="noday"> </td><td class="wed">1</td></tr>')
+ self.assertEqual(cal.formatweek([(1, 1), (2, 2)], True),
+ '<tr class="current_week"><td class="tue">1</td><td '\
+ 'class="wed">2</td></tr>')
+
+ def test_formatmonthname(self):
+ """ Test the formatmonthname function. """
+ today = date.today()
+ cal = FedocalCalendar(today.year, today.month, today.day)
+ self.assertEqual(cal.formatmonthname(2012, 4),
+ '<tr><th colspan="7" class="month"><a class="button" '\
+ 'href="#"><</a> April 2012 <a class="button" href="#">>'\
+ '</a></th></tr>')
+ self.assertEqual(cal.formatmonthname(2012, 4, False),
+ '<tr><th colspan="7" class="month"><a class="button" '\
+ 'href="#"><</a> April <a class="button" href="#">>'\
+ '</a></th></tr>')
+
+ def test_formatmonth(self):
+ """ Test the formatmonth function. """
+ today = date.today()
+ cal = FedocalCalendar(2012, 1, 10)
+ self.assertEqual(cal.formatmonth(),
+ '<table class="month">\n<tr><th colspan="7" class="month">'\
+ '<a class="button" href="#"><</a> January 2012 <a '\
+ 'class="button" href="#">></a></th></tr>\n<tr><td '\
+ 'class="noday"> </td><td class="noday"> '\
+ '</td><td class="noday"> </td><td class="noday">'\
+ ' </td><td class="noday"> </td><td class="noday">'\
+ ' </td><td class="sun">1</td></tr>\n<tr><td '\
+ 'class="mon">2</td><td class="tue">3</td><td class="wed">'\
+ '4</td><td class="thu">5</td><td class="fri">6</td><td '\
+ 'class="sat">7</td><td class="sun">8</td></tr>\n<tr '\
+ 'class="current_week"><td class="mon">9</td><td '\
+ 'class="tue">10</td><td class="wed">11</td><td '\
+ 'class="thu">12</td><td class="fri">13</td><td '\
+ 'class="sat">14</td><td class="sun">15</td></tr>\n<tr><td'\
+ ' class="mon">16</td><td class="tue">17</td><td '\
+ 'class="wed">18</td><td class="thu">19</td><td '\
+ 'class="fri">20</td><td class="sat">21</td><td '\
+ 'class="sun">22</td></tr>\n<tr><td class="mon">23</td>'\
+ '<td class="tue">24</td><td class="wed">25</td><td '\
+ 'class="thu">26</td><td class="fri">27</td><td '\
+ 'class="sat">28</td><td class="sun">29</td></tr>\n<tr>'\
+ '<td class="mon">30</td><td class="tue">31</td><td '\
+ 'class="noday"> </td><td class="noday"> </td>'\
+ '<td class="noday"> </td><td class="noday"> </td>'\
+ '<td class="noday"> </td></tr>\n</table>\n')
+
+ self.assertEqual(cal.formatmonth(False),
+ '<table class="month">\n<tr><th colspan="7" class="month">'\
+ '<a class="button" href="#"><</a> January <a '\
+ 'class="button" href="#">></a></th></tr>\n<tr><td '\
+ 'class="noday"> </td><td class="noday"> '\
+ '</td><td class="noday"> </td><td class="noday">'\
+ ' </td><td class="noday"> </td><td class="noday">'\
+ ' </td><td class="sun">1</td></tr>\n<tr><td '\
+ 'class="mon">2</td><td class="tue">3</td><td class="wed">'\
+ '4</td><td class="thu">5</td><td class="fri">6</td><td '\
+ 'class="sat">7</td><td class="sun">8</td></tr>\n<tr '\
+ 'class="current_week"><td class="mon">9</td><td '\
+ 'class="tue">10</td><td class="wed">11</td><td '\
+ 'class="thu">12</td><td class="fri">13</td><td '\
+ 'class="sat">14</td><td class="sun">15</td></tr>\n<tr><td'\
+ ' class="mon">16</td><td class="tue">17</td><td '\
+ 'class="wed">18</td><td class="thu">19</td><td '\
+ 'class="fri">20</td><td class="sat">21</td><td '\
+ 'class="sun">22</td></tr>\n<tr><td class="mon">23</td>'\
+ '<td class="tue">24</td><td class="wed">25</td><td '\
+ 'class="thu">26</td><td class="fri">27</td><td '\
+ 'class="sat">28</td><td class="sun">29</td></tr>\n<tr>'\
+ '<td class="mon">30</td><td class="tue">31</td><td '\
+ 'class="noday"> </td><td class="noday"> </td>'\
+ '<td class="noday"> </td><td class="noday"> </td>'\
+ '<td class="noday"> </td></tr>\n</table>\n')
+
+
+if __name__ == '__main__':
+ SUITE = unittest.TestLoader().loadTestsFromTestCase(FedocalCalendartests)
+ unittest.TextTestRunner(verbosity=2).run(SUITE)
11 years
[fedocal] master: Fix typo in the version script (Note:version script should be tested...) (ea48d6f)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit ea48d6f92cc0adb81d58c8137874aaf6a5787216
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 8 10:00:46 2012 +0100
Fix typo in the version script (Note:version script should be tested...)
>---------------------------------------------------------------
.../versions/2c5c36431061_add_the_meeting_date.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/alembic/versions/2c5c36431061_add_the_meeting_date.py b/alembic/versions/2c5c36431061_add_the_meeting_date.py
index 5df6670..747cc6f 100644
--- a/alembic/versions/2c5c36431061_add_the_meeting_date.py
+++ b/alembic/versions/2c5c36431061_add_the_meeting_date.py
@@ -12,7 +12,7 @@ down_revision = None
from alembic import op
import sqlalchemy as sa
-import datetime
+from datetime import datetime
def upgrade():
11 years
[fedocal] master: Fix typo in the version script (ce6560a)
by Pierre-YvesChibon
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit ce6560ae39f615f6e4e901e0d7e2c665355a2ecd
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 8 09:59:26 2012 +0100
Fix typo in the version script
>---------------------------------------------------------------
.../versions/2c5c36431061_add_the_meeting_date.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/alembic/versions/2c5c36431061_add_the_meeting_date.py b/alembic/versions/2c5c36431061_add_the_meeting_date.py
index 96c7877..5df6670 100644
--- a/alembic/versions/2c5c36431061_add_the_meeting_date.py
+++ b/alembic/versions/2c5c36431061_add_the_meeting_date.py
@@ -18,7 +18,7 @@ import datetime
def upgrade():
''' Add the meeting_date_end column to the meetings table '''
op.add_column('meetings', sa.Column('meeting_date_end', sa.Date,
- default=datetime.utcnow().date())
+ default=datetime.utcnow().date()))
def downgrade():
11 years
[fedocal] master: The session should be remove when the application is teardown (b6c1e98)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit b6c1e983eb5dd2f24350b44c010185048af587eb
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 8 09:53:30 2012 +0100
The session should be remove when the application is teardown
>---------------------------------------------------------------
fedocal/__init__.py | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/fedocal/__init__.py b/fedocal/__init__.py
index 7e67688..e67c86c 100644
--- a/fedocal/__init__.py
+++ b/fedocal/__init__.py
@@ -73,6 +73,10 @@ def reverse_filter(weekdays):
weekdays[-1].strftime('%d %b %Y'))
+(a)APP.teardown_request
+def shutdown_session(exception=None):
+ SESSION.remove()
+
def is_admin():
""" Return wether the user is admin for this application or not. """
if not flask.g.fas_user:
11 years
[fedocal] master: Rework the create_session method so that it returns a scopedsession (92dcb2c)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 92dcb2cf1be3ea9f60bea4f71bc44a7a3fcb1b69
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 8 09:53:15 2012 +0100
Rework the create_session method so that it returns a scopedsession
>---------------------------------------------------------------
fedocal/fedocallib/__init__.py | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/fedocal/fedocallib/__init__.py b/fedocal/fedocallib/__init__.py
index e050e54..220fe5b 100644
--- a/fedocal/fedocallib/__init__.py
+++ b/fedocal/fedocallib/__init__.py
@@ -48,9 +48,8 @@ def create_session(db_url, debug=False, pool_recycle=3600):
:return a Session that can be used to query the database.
"""
engine = create_engine(db_url, echo=debug, pool_recycle=pool_recycle)
- session = sessionmaker(bind=engine)
- scopedsession = scoped_session(session)
- return scopedsession()
+ scopedsession = scoped_session(sessionmaker(bind=engine))
+ return scopedsession
def get_calendars(session):
11 years
[fedocal] master: Fix unit-tests, there were more meeting created than I previously fixed (61bdca1)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 61bdca131b2515fd44746e4be11b5edcece35758
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 8 09:00:39 2012 +0100
Fix unit-tests, there were more meeting created than I previously fixed
>---------------------------------------------------------------
fedocal/tests/test_fedocallib.py | 27 +++++++++++++++++----------
1 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/fedocal/tests/test_fedocallib.py b/fedocal/tests/test_fedocallib.py
index 558550f..2c472d5 100644
--- a/fedocal/tests/test_fedocallib.py
+++ b/fedocal/tests/test_fedocallib.py
@@ -281,10 +281,14 @@ class Fedocallibtests(Modeltests):
self.assertEqual(meetings, [])
obj = model.Meeting(
- 'A past test meeting', 'pingou',
- TODAY - timedelta(days=1), time(12, 00), time(13, 00),
- 'This is a past test meeting',
- 'test_calendar', None, None)
+ meeting_name='A past test meeting',
+ meeting_manager='pingou',
+ meeting_date=TODAY - timedelta(days=1),
+ meeting_date_end=TODAY - timedelta(days=1),
+ meeting_time_start=time(12, 00),
+ meeting_time_stop=time(13, 00),
+ meeting_information='This is a past test meeting',
+ calendar_name='test_calendar')
obj.save(self.session)
self.session.commit()
meetings = fedocallib.get_past_meeting_of_user(self.session,
@@ -438,12 +442,15 @@ class Fedocallibtests(Modeltests):
time_start = datetime.utcnow() + timedelta(hours=12)
time_end = datetime.utcnow() + timedelta(hours=13)
meeting = model.Meeting(
- 'Test meeting with reminder', 'pingou',
- time_start.date(),
- time(time_start.hour, 00), time(time_end.hour, 00),
- 'This is a test meeting with reminder',
- 'test_calendar',
- remobj.reminder_id, None)
+ meeting_name='Test meeting with reminder',
+ meeting_manager='pingou',
+ meeting_date=time_start.date(),
+ meeting_date_end=time_start.date(),
+ meeting_time_start=time(time_start.hour, 00),
+ meeting_time_stop=time(time_end.hour, 00),
+ meeting_information='This is a test meeting with reminder',
+ calendar_name='test_calendar',
+ reminder_id=remobj.reminder_id)
meeting.save(self.session)
self.session.commit()
11 years