[fedocal] master: Add help script to create the database and run the server from the sources (5f9af7d)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 5f9af7d4c9389be31c8db9c2cbef095fce842854
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Sat Nov 17 19:47:38 2012 +0100
Add help script to create the database and run the server from the sources
Simply call createdb to create the database or runserver to run a development server.
>---------------------------------------------------------------
createdb | 1 +
createdb.py | 6 ++++++
runserver | 2 ++
runserver.py | 5 +++++
4 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/createdb b/createdb
new file mode 100755
index 0000000..5e654d4
--- /dev/null
+++ b/createdb
@@ -0,0 +1 @@
+FEDOCAL_CONFIG=../fedocal.cfg python createdb.py
diff --git a/createdb.py b/createdb.py
new file mode 100644
index 0000000..bccd5ac
--- /dev/null
+++ b/createdb.py
@@ -0,0 +1,6 @@
+#!/usr/bin/python
+
+from fedocal import APP
+from fedocal.fedocallib import model
+
+model.create_tables(APP.config['DB_URL'], True)
diff --git a/runserver b/runserver
new file mode 100755
index 0000000..70b7332
--- /dev/null
+++ b/runserver
@@ -0,0 +1,2 @@
+
+FEDOCAL_CONFIG=../fedocal.cfg python runserver.py
diff --git a/runserver.py b/runserver.py
new file mode 100644
index 0000000..2802474
--- /dev/null
+++ b/runserver.py
@@ -0,0 +1,5 @@
+#!/usr/bin/python
+
+from fedocal import APP
+APP.debug=True
+APP.run()
10 years, 6 months
[fedocal] master: Add an example wsgi file for fedocal (4198e7c)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 4198e7ca03b8725d20ac66e2d19be8c152c4fc92
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Sat Nov 17 19:46:43 2012 +0100
Add an example wsgi file for fedocal
>---------------------------------------------------------------
fedocal.wsgi | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/fedocal.wsgi b/fedocal.wsgi
new file mode 100644
index 0000000..b04ebe4
--- /dev/null
+++ b/fedocal.wsgi
@@ -0,0 +1,12 @@
+#-*- coding: UTF-8 -*-
+
+import os
+## Set the environment variable pointing to the configuration file
+os.environ['FEDOCAL_CONFIG'] = '/path/to/your/own/fedocal.cfg'
+
+## The following is only needed if you did not install fedocal
+## as a python module (for example if you run it from a git clone).
+#import sys
+#sys.path.insert(0, '/path/to/fedocal/')
+
+from fedocal import APP as application
10 years, 6 months
[fedocal] master: Move the configuration to the Flask configuration model (ceead16)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit ceead1674c08583cf8a92e743ac56088529824ab
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Sat Nov 17 19:46:26 2012 +0100
Move the configuration to the Flask configuration model
Flask recommands to use an environment variable to point to the actual configuration
file which overloads the defaults present in the default_config.py within the application.
This commits does this change.
The run_tests.sh shell script points to its own (new) configuration file.
Fixes #8
>---------------------------------------------------------------
fedocal.cfg.sample | 12 ++++++++++++
fedocal/__init__.py | 15 ++++-----------
fedocal/default_config.py | 31 +++++++++++++++++++++++++++++++
fedocal/fedocal.cfg.sample | 9 ---------
fedocal/tests/fedocal_test.cfg | 8 ++++++++
fedocal/tests/test_flask.py | 6 ++----
run_tests.sh | 2 +-
7 files changed, 58 insertions(+), 25 deletions(-)
diff --git a/fedocal.cfg.sample b/fedocal.cfg.sample
new file mode 100644
index 0000000..d68897d
--- /dev/null
+++ b/fedocal.cfg.sample
@@ -0,0 +1,12 @@
+# Beware that the quotes around the values are mandatory
+
+### Secret key for the Flask application
+SECRET_KEY='<The web application secret key>'
+
+### url to the database server:
+#DB_URL=mysql://user:pass@host/db_name
+#DB_URL=postgres://user:pass@host/db_name
+DB_URL='sqlite:////tmp/fedocal_dev.sqlite'
+
+### The FAS group in which the admin of fedocal are
+ADMIN_GROUP='fedocal_admin'
diff --git a/fedocal/__init__.py b/fedocal/__init__.py
index a24fc10..ac0b947 100644
--- a/fedocal/__init__.py
+++ b/fedocal/__init__.py
@@ -45,20 +45,13 @@ import fedocallib.dbaction
from fedocallib.exceptions import FedocalException
from fedocallib.model import (Calendar, Meeting, Reminder)
-CONFIG = ConfigParser.ConfigParser()
-if os.path.exists('/etc/fedocal.cfg'): # pragma: no cover
- CONFIG.readfp(open('/etc/fedocal.cfg'))
-else:
- CONFIG.readfp(open(os.path.join(os.path.dirname(
- os.path.abspath(__file__)),
- 'fedocal.cfg')))
-
# Create the application.
APP = flask.Flask(__name__)
# set up FAS
FAS = FAS(APP)
-APP.secret_key = CONFIG.get('fedocal', 'secret_key')
-SESSION = fedocallib.create_session(CONFIG.get('fedocal', 'db_url'))
+APP.config.from_object('fedocal.default_config')
+APP.config.from_envvar('FEDOCAL_CONFIG')
+SESSION = fedocallib.create_session(APP.config['DB_URL'])
@APP.context_processor
@@ -94,7 +87,7 @@ def is_admin():
if not flask.g.fas_user:
return False
else:
- if CONFIG.get('fedocal', 'admin_group') in flask.g.fas_user.groups:
+ if APP.config['ADMIN_GROUP'] in flask.g.fas_user.groups:
return True
diff --git a/fedocal/default_config.py b/fedocal/default_config.py
new file mode 100644
index 0000000..7648448
--- /dev/null
+++ b/fedocal/default_config.py
@@ -0,0 +1,31 @@
+#-*- coding: UTF-8 -*-
+
+"""
+ (c) 2012 - Copyright 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.
+"""
+
+
+# url to the database server:
+DB_URL='sqlite:////tmp/fedocal_dev.sqlite'
+
+# The FAS group in which the admin of fedocal are
+ADMIN_GROUP='fedocal_admin'
diff --git a/fedocal/fedocal.cfg.sample b/fedocal/fedocal.cfg.sample
deleted file mode 100644
index 8893e9e..0000000
--- a/fedocal/fedocal.cfg.sample
+++ /dev/null
@@ -1,9 +0,0 @@
-[fedocal]
-# Secret key for the Flask application
-secret_key=<The web application secret key>
-# url to the database server:
-;db_url=mysql://user:pass@host/db_name
-;db_url=postgres://user:pass@host/db_name
-db_url=sqlite:////tmp/fedocal_dev.sqlite
-# The FAS group in which the admin of fedocal are
-admin_group=fedocal_admin
diff --git a/fedocal/tests/fedocal_test.cfg b/fedocal/tests/fedocal_test.cfg
new file mode 100644
index 0000000..7a8406d
--- /dev/null
+++ b/fedocal/tests/fedocal_test.cfg
@@ -0,0 +1,8 @@
+### Secret key for the Flask application
+SECRET_KEY='<The web application secret key>'
+
+### url to the database server:
+DB_URL='sqlite:////tmp/fedocal_dev.sqlite'
+
+### The FAS group in which the admin of fedocal are
+ADMIN_GROUP='packager'
diff --git a/fedocal/tests/test_flask.py b/fedocal/tests/test_flask.py
index 677db15..4f446dd 100644
--- a/fedocal/tests/test_flask.py
+++ b/fedocal/tests/test_flask.py
@@ -193,8 +193,7 @@ class Flasktests(Modeltests):
with app.test_request_context():
flask.g.fas_user = None
self.assertFalse(fedocal.is_admin())
- flask.g.fas_user = FakeUser(fedocal.CONFIG.get('fedocal',
- 'admin_group'))
+ flask.g.fas_user = FakeUser(fedocal.APP.config['ADMIN_GROUP'])
self.assertTrue(fedocal.is_admin())
def test_get_timezone(self):
@@ -202,8 +201,7 @@ class Flasktests(Modeltests):
app = flask.Flask('fedocal')
with app.test_request_context():
- flask.g.fas_user = FakeUser(fedocal.CONFIG.get('fedocal',
- 'admin_group'))
+ flask.g.fas_user = FakeUser(fedocal.APP.config['ADMIN_GROUP'])
self.assertEqual(fedocal.get_timezone(), 'Europe/Paris')
diff --git a/run_tests.sh b/run_tests.sh
index adf2b09..101b71c 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -1,2 +1,2 @@
#!/bin/bash
-PYTHONPATH=fedocal nosetests --with-coverage --cover-package=fedocal
+FEDOCAL_CONFIG=tests/fedocal_test.cfg PYTHONPATH=fedocal nosetests --with-coverage --cover-package=fedocal
10 years, 6 months
[fedocal] master: Couple more of Flask tests (dfdc1b4)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit dfdc1b43fa776c13935189a2b311ca77bff41b47
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Sat Nov 17 16:58:38 2012 +0100
Couple more of Flask tests
>---------------------------------------------------------------
fedocal/tests/test_flask.py | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/fedocal/tests/test_flask.py b/fedocal/tests/test_flask.py
index 0438a9d..677db15 100644
--- a/fedocal/tests/test_flask.py
+++ b/fedocal/tests/test_flask.py
@@ -30,6 +30,7 @@
__requires__ = ['SQLAlchemy >= 0.7']
import pkg_resources
+import flask
import unittest
import sys
import os
@@ -41,7 +42,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(
import fedocal
import fedocal.fedocallib as fedocallib
-from fedocal.tests import Modeltests, DB_PATH
+from fedocal.tests import Modeltests, DB_PATH, FakeUser
# pylint: disable=E1103
@@ -185,6 +186,26 @@ class Flasktests(Modeltests):
self.assertTrue('This is a test meeting at the same time' in
output.data)
+ def test_is_admin(self):
+ """ Test the is_admin function. """
+ app = flask.Flask('fedocal')
+
+ with app.test_request_context():
+ flask.g.fas_user = None
+ self.assertFalse(fedocal.is_admin())
+ flask.g.fas_user = FakeUser(fedocal.CONFIG.get('fedocal',
+ 'admin_group'))
+ self.assertTrue(fedocal.is_admin())
+
+ def test_get_timezone(self):
+ """ Test the get_timezone. """
+ app = flask.Flask('fedocal')
+
+ with app.test_request_context():
+ flask.g.fas_user = FakeUser(fedocal.CONFIG.get('fedocal',
+ 'admin_group'))
+ self.assertEqual(fedocal.get_timezone(), 'Europe/Paris')
+
if __name__ == '__main__':
SUITE = unittest.TestLoader().loadTestsFromTestCase(Flasktests)
10 years, 6 months
[fedocal] master: Move the FakeUser to the top level of the tests as we need it in more place than just test_fedocallib (1192e3a)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 1192e3aab122029c21d54da01cba98560209e005
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Sat Nov 17 16:58:17 2012 +0100
Move the FakeUser to the top level of the tests as we need it in more place than just
test_fedocallib
>---------------------------------------------------------------
fedocal/tests/__init__.py | 34 ++++++++++++++++++++++++++++++++++
fedocal/tests/test_fedocallib.py | 15 +--------------
2 files changed, 35 insertions(+), 14 deletions(-)
diff --git a/fedocal/tests/__init__.py b/fedocal/tests/__init__.py
index 75d3197..a95652a 100644
--- a/fedocal/tests/__init__.py
+++ b/fedocal/tests/__init__.py
@@ -70,6 +70,40 @@ class Modeltests(unittest.TestCase):
os.unlink(DB_PATH)
+class FakeGroup(object):
+ """ Fake object used to make the FakeUser object closer to the
+ expectations.
+ """
+
+ def __init__(self, name):
+ """ Constructor.
+ :arg name: the name given to the name attribute of this object.
+ """
+ self.name = name
+ self.group_type = 'cla'
+
+
+# pylint: disable=R0903
+class FakeUser(object):
+ """ Fake user used to test the fedocallib library. """
+
+ def __init__(self, groups, username='username'):
+ """ Constructor.
+ :arg groups: list of the groups in which this fake user is
+ supposed to be.
+ """
+ self.groups = groups
+ self.username = username
+ self.name = username
+ self.approved_memberships = [FakeGroup('packager'),
+ FakeGroup('cla_done')]
+ self.dic = {}
+ self.dic['timezone'] = 'Europe/Paris'
+
+ def __getitem__(self, key):
+ return self.dic[key]
+
+
if __name__ == '__main__':
SUITE = unittest.TestLoader().loadTestsFromTestCase(Modeltests)
unittest.TextTestRunner(verbosity=2).run(SUITE)
diff --git a/fedocal/tests/test_fedocallib.py b/fedocal/tests/test_fedocallib.py
index d372b1e..0227e45 100644
--- a/fedocal/tests/test_fedocallib.py
+++ b/fedocal/tests/test_fedocallib.py
@@ -47,7 +47,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(
import fedocallib
from fedocallib import model
from fedocallib.exceptions import UserNotAllowed, InvalidMeeting
-from tests import Modeltests, TODAY
+from tests import Modeltests, TODAY, FakeUser
RESULT_CALENDAR_HTML = '<table class="month">\n'\
'<tr><th colspan="7" class="month"> November 2012 </th></tr>\n'\
@@ -69,19 +69,6 @@ RESULT_CALENDAR_HTML = '<table class="month">\n'\
'</table>'
-# pylint: disable=R0903
-class FakeUser(object):
- """ Fake user used to test the fedocallib library. """
-
- def __init__(self, groups):
- """ Constructor.
- :arg groups: list of the groups in which this fake user is
- supposed to be.
- """
- self.groups = groups
- self.username = 'username'
-
-
# pylint: disable=R0904
class Fedocallibtests(Modeltests):
""" Fedocallib tests. """
10 years, 6 months
[fedocal] master: Remove a return which is actually never used... (c8853e4)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit c8853e452dc64117b39673160e297f482050dd72
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Sat Nov 17 16:57:29 2012 +0100
Remove a return which is actually never used...
>---------------------------------------------------------------
fedocal/__init__.py | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/fedocal/__init__.py b/fedocal/__init__.py
index 3eb9b4f..a24fc10 100644
--- a/fedocal/__init__.py
+++ b/fedocal/__init__.py
@@ -96,7 +96,6 @@ def is_admin():
else:
if CONFIG.get('fedocal', 'admin_group') in flask.g.fas_user.groups:
return True
- return False
def get_timezone():
10 years, 6 months
[fedocal] master: Fix unit-tests to adapt to the latest changes and keep the coverage at 100% (28a114d)
by Pierre-YvesChibon
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 28a114d339d0f410772e9f425dd50596a5c35d93
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Sat Nov 17 13:45:13 2012 +0100
Fix unit-tests to adapt to the latest changes and keep the coverage at 100%
>---------------------------------------------------------------
fedocal/tests/test_fedocallib.py | 47 ++++++++++++++++++-------------------
fedocal/tests/test_meeting.py | 16 ++++++------
2 files changed, 31 insertions(+), 32 deletions(-)
diff --git a/fedocal/tests/test_fedocallib.py b/fedocal/tests/test_fedocallib.py
index ad36bb8..d372b1e 100644
--- a/fedocal/tests/test_fedocallib.py
+++ b/fedocal/tests/test_fedocallib.py
@@ -199,12 +199,11 @@ class Fedocallibtests(Modeltests):
meetings = fedocallib.get_meetings(self.session, calendar)
self.assertNotEqual(meetings, None)
cnt = 0
- for meeting in meetings['19h00']:
+ for meeting in meetings['20h00']:
if meeting is not None:
for meet in meeting:
- self.assertTrue(meet.meeting_name in
- ['Fedora-fr-test-meeting',
- 'Another test meeting2'])
+ self.assertEqual(meet.meeting_name,
+ 'Fedora-fr-test-meeting')
else:
cnt = cnt + 1
self.assertEqual(cnt, 6)
@@ -432,16 +431,16 @@ class Fedocallibtests(Modeltests):
self.__setup_meeting()
cal = model.Calendar.by_id(self.session, 'test_calendar')
self.assertTrue(fedocallib.agenda_is_free(self.session, cal,
- TODAY, 10, 11))
+ TODAY, time(10, 0), time(11, 0)))
self.assertFalse(fedocallib.agenda_is_free(self.session, cal,
- TODAY, 19, 20))
+ TODAY, time(20, 0), time(21, 0)))
def test_agenda_is_free_empty(self):
""" Test the agenda_is_free function. """
self.__setup_calendar()
cal = model.Calendar.by_id(self.session, 'test_calendar')
self.assertTrue(fedocallib.agenda_is_free(self.session, cal,
- TODAY, 10, 11))
+ TODAY, time(10, 0), time(11, 0)))
# pylint: disable=C0103
def test_is_user_managing_in_calendar(self):
@@ -639,7 +638,7 @@ class Fedocallibtests(Modeltests):
self.assertRaises(AttributeError, fedocallib.add_meeting,
self.session, calendarobj, None,
None, None,
- 9, 10, None,
+ time(9, 0), time(10, 0), None,
None, None, None,
None, None,
None, None)
@@ -648,7 +647,7 @@ class Fedocallibtests(Modeltests):
self.assertRaises(UserNotAllowed, fedocallib.add_meeting,
self.session, calendarobj, fasuser,
None, None,
- 9, 10, None,
+ time(9, 0), time(10, 0), None,
None, None, None,
None, None,
None, None)
@@ -657,7 +656,7 @@ class Fedocallibtests(Modeltests):
self.assertRaises(TypeError, fedocallib.add_meeting,
self.session, calendarobj, fasuser,
None, None,
- 9, 10, None,
+ time(9, 0), time(10, 0), None,
None, None, None,
None, None,
None, None)
@@ -665,7 +664,7 @@ class Fedocallibtests(Modeltests):
self.assertRaises(InvalidMeeting, fedocallib.add_meeting,
self.session, calendarobj, fasuser,
None, TODAY - timedelta(days=4),
- 9, 10, None,
+ time(9, 0), time(10, 0), None,
None, None, None,
None, None,
None, None)
@@ -673,7 +672,7 @@ class Fedocallibtests(Modeltests):
self.assertRaises(IntegrityError, fedocallib.add_meeting,
self.session, calendarobj, fasuser,
None, date.today() + timedelta(days=1),
- 9, 10, None,
+ time(9, 0), time(10, 0), None,
None, None, 'Europe/Paris',
None, None,
None, None)
@@ -682,7 +681,7 @@ class Fedocallibtests(Modeltests):
self.assertRaises(InvalidMeeting, fedocallib.add_meeting,
self.session, calendarobj, fasuser,
'Name', date.today() + timedelta(days=1),
- 10, 9, None,
+ time(10, 0), time(9, 0), None,
None, None, 'Europe/Paris',
None, None,
None, None)
@@ -691,7 +690,7 @@ class Fedocallibtests(Modeltests):
fedocallib.add_meeting(
self.session, calendarobj, fasuser,
'Name', date.today() + timedelta(days=1),
- 9, 10, None,
+ time(9, 0), time(10, 0), None,
None, None, 'Europe/Paris',
None, None,
None, None)
@@ -708,7 +707,7 @@ class Fedocallibtests(Modeltests):
self.assertRaises(InvalidMeeting, fedocallib.add_meeting,
self.session, calendarobj, fasuser,
'Name', date.today() + timedelta(days=1),
- 9, 10, None,
+ time(9, 0), time(10, 0), None,
None, None, 'Europe/Paris',
None, None,
None, None)
@@ -716,7 +715,7 @@ class Fedocallibtests(Modeltests):
fedocallib.add_meeting(
self.session, calendarobj, fasuser,
'Name', date.today() + timedelta(days=1),
- 10, 11, 'pingou',
+ time(10, 0), time(11, 0), 'pingou',
None, None, 'Europe/Paris',
None, None,
None, None)
@@ -733,7 +732,7 @@ class Fedocallibtests(Modeltests):
fedocallib.add_meeting(
self.session, calendarobj, fasuser,
'Name', date.today() + timedelta(days=1),
- 11, 12, 'pingou',
+ time(11, 00), time(12, 0), 'pingou',
'Information', None, 'Europe/Paris',
None, None,
None, None)
@@ -746,7 +745,7 @@ class Fedocallibtests(Modeltests):
fedocallib.add_meeting(
self.session, calendarobj, fasuser,
'Name', date.today() + timedelta(days=1),
- 13, 14, 'pingou',
+ time(13, 0), time(14, 0), 'pingou',
'Information', 'EMEA', 'Europe/Paris',
None, None,
None, None)
@@ -763,7 +762,7 @@ class Fedocallibtests(Modeltests):
fedocallib.add_meeting(
self.session, calendarobj, fasuser,
'Name', date.today() + timedelta(days=1),
- 9, 10, 'pingou',
+ time(9, 0), time(10, 0), 'pingou',
'Information', 'EMEA', 'Europe/Paris',
None, None,
None, None)
@@ -777,7 +776,7 @@ class Fedocallibtests(Modeltests):
fedocallib.add_meeting(
self.session, calendarobj, fasuser,
'Name', date.today() + timedelta(days=1),
- 10, 11, 'pingou',
+ time(10, 0), time(11, 0), 'pingou',
'Information', 'EMEA', 'Europe/Paris',
7, None,
None, None)
@@ -792,7 +791,7 @@ class Fedocallibtests(Modeltests):
fedocallib.add_meeting(
self.session, calendarobj, fasuser,
'Name', date.today() + timedelta(days=1),
- 11, 12, 'pingou',
+ time(11, 0), time(12, 0), 'pingou',
'Information', 'EMEA', 'Europe/Paris',
7, date.today() + timedelta(days=28),
None, None)
@@ -809,7 +808,7 @@ class Fedocallibtests(Modeltests):
fedocallib.add_meeting(
self.session, calendarobj, fasuser,
'Name', date.today() + timedelta(days=1),
- 12, 13, 'pingou',
+ time(12, 0), time(13, 0), 'pingou',
'Information', 'EMEA', 'Europe/Paris',
7, date.today() + timedelta(days=28),
'', 'test(a)example.org')
@@ -825,7 +824,7 @@ class Fedocallibtests(Modeltests):
fedocallib.add_meeting(
self.session, calendarobj, fasuser,
'Name', date.today() + timedelta(days=1),
- 13, 14, 'pingou',
+ time(13, 0), time(14, 0), 'pingou',
'Information', 'EMEA', 'Europe/Paris',
7, date.today() + timedelta(days=28),
'H-12', 'test(a)example.org')
@@ -842,7 +841,7 @@ class Fedocallibtests(Modeltests):
fedocallib.add_meeting(
self.session, calendarobj, fasuser,
'Name23h59', date.today() + timedelta(days=1),
- 23, 24, None,
+ time(23, 0), time(23, 59), None,
'Information', 'EMEA', 'Europe/Paris',
None, None,
None, None)
diff --git a/fedocal/tests/test_meeting.py b/fedocal/tests/test_meeting.py
index 0fa6fe2..b986d60 100644
--- a/fedocal/tests/test_meeting.py
+++ b/fedocal/tests/test_meeting.py
@@ -61,8 +61,8 @@ class Meetingtests(Modeltests):
meeting_manager='pingou, shaiton,',
meeting_date=TODAY,
meeting_date_end=TODAY,
- meeting_time_start=time(19, 00),
- meeting_time_stop=time(20, 00),
+ meeting_time_start=time(19, 45),
+ meeting_time_stop=time(20, 45),
meeting_information='This is a test meeting',
calendar_name='test_calendar')
obj.save(self.session)
@@ -74,8 +74,8 @@ class Meetingtests(Modeltests):
meeting_manager='pingou,',
meeting_date=TODAY + timedelta(days=10),
meeting_date_end=TODAY + timedelta(days=10),
- meeting_time_start=time(14, 00),
- meeting_time_stop=time(16, 00),
+ meeting_time_start=time(14, 15),
+ meeting_time_stop=time(16, 15),
meeting_information='This is another test meeting',
calendar_name='test_calendar')
obj.save(self.session)
@@ -101,8 +101,8 @@ class Meetingtests(Modeltests):
meeting_manager='test2,',
meeting_date=TODAY - timedelta(days=16),
meeting_date_end=TODAY - timedelta(days=16),
- meeting_time_start=time(14, 00),
- meeting_time_stop=time(16, 00),
+ meeting_time_start=time(14, 45),
+ meeting_time_stop=time(16, 35),
meeting_information='Test meeting with past end_recursion.',
calendar_name='test_calendar3',
recursion_frequency=7,
@@ -300,8 +300,8 @@ class Meetingtests(Modeltests):
'"meeting_manager": "pingou, shaiton,",\n '\
'"meeting_date": "%s",\n '\
'"meeting_date_end": "%s",\n '\
- '"meeting_time_start": "19:00:00",\n '\
- '"meeting_time_stop": "20:00:00",\n '\
+ '"meeting_time_start": "19:45:00",\n '\
+ '"meeting_time_stop": "20:45:00",\n '\
'"meeting_information": "This is a test meeting",\n '\
'"meeting_region": "None",\n '\
'"calendar_name": "test_calendar"\n'\
10 years, 6 months
[fedocal] master: Improve the agenda_is_free function (74b6823)
by Pierre-YvesChibon
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 74b6823669125acecf195d4eabce360176d3fd32
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Sat Nov 17 13:44:32 2012 +0100
Improve the agenda_is_free function
When adding a meeting, re should check that there are no meetings already running for
both the start and the end time.
>---------------------------------------------------------------
fedocal/fedocallib/__init__.py | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/fedocal/fedocallib/__init__.py b/fedocal/fedocallib/__init__.py
index 30b6fe2..1863c85 100644
--- a/fedocal/fedocallib/__init__.py
+++ b/fedocal/fedocallib/__init__.py
@@ -369,7 +369,7 @@ def get_future_regular_meeting_of_user(session, username,
def agenda_is_free(session, calendar, meeting_date,
- time_start):
+ time_start, time_stop):
"""Check if there is already someting planned in this agenda at that
time.
@@ -377,9 +377,12 @@ def agenda_is_free(session, calendar, meeting_date,
:arg calendar: the name of the calendar of interest.
:arg meeting_date: the date of the meeting (as Datetime object)
:arg time_start: the time at which the meeting starts (as int)
+ :arg time_stop: the time at which the meeting stops (as int)
"""
- meetings = Meeting.get_by_time(session, calendar, meeting_date,
+ meetings = Meeting.at_time(session, calendar, meeting_date,
time_start)
+ meetings.extend(Meeting.at_time(session, calendar, meeting_date,
+ time_stop))
if not meetings:
return True
else:
@@ -567,12 +570,13 @@ def add_meeting(session, calendarobj, fas_user,
tzone, 'UTC')
free_time = agenda_is_free(session, calendarobj,
- meeting_date, meeting_time_start.time())
+ meeting_date, meeting_time_start.time(),
+ meeting_time_stop.time())
if not bool(calendarobj.calendar_multiple_meetings) and \
not bool(free_time):
raise InvalidMeeting(
- 'The start time you have entered is already occupied.')
+ 'The start or end time you have entered is already occupied.')
reminder = None
if remind_when and remind_who:
10 years, 6 months
[fedocal] master: Change back the get_by_time functions as it was and add a at_time function (a88f19e)
by Pierre-YvesChibon
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit a88f19e9707386700f4f2e99cdd3bb854258e38b
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Sat Nov 17 13:42:09 2012 +0100
Change back the get_by_time functions as it was and add a at_time function
The get_by_time allows you to retrieve all the meetings within a time period while
the at_time function allows you to retrieve the meeting occuring at a given time.
This is used to check when adding a meeting if the time slot is free.
>---------------------------------------------------------------
fedocal/fedocallib/model.py | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/fedocal/fedocallib/model.py b/fedocal/fedocallib/model.py
index 510d002..f0e738d 100644
--- a/fedocal/fedocallib/model.py
+++ b/fedocal/fedocallib/model.py
@@ -298,15 +298,26 @@ class Meeting(BASE):
(Meeting.meeting_region == region)).all()
@classmethod
- def get_by_time(cls, session, calendar, meetingdate, start_time):
+ def get_by_time(cls, session, calendar, meetingdate, start_time,
+ stop_time):
""" Retrieve the list of meetings for a given date and between
two times.
"""
return session.query(cls).filter(and_
(Meeting.calendar == calendar),
(Meeting.meeting_date == meetingdate),
- (Meeting.meeting_time_start <= start_time),
- (Meeting.meeting_time_stop > start_time)).all()
+ (Meeting.meeting_time_start >= start_time),
+ (Meeting.meeting_time_stop <= stop_time)).all()
+
+ @classmethod
+ def at_time(cls, session, calendar, meetingdate, t_time):
+ """ Returns the meeting occuring at this specifict time point.
+ """
+ return session.query(cls).filter(and_
+ (Meeting.calendar == calendar),
+ (Meeting.meeting_date == meetingdate),
+ (Meeting.meeting_time_start <= t_time),
+ (Meeting.meeting_time_stop > t_time)).all()
@classmethod
def get_past_meeting_of_user(cls, session, username, start_date):
10 years, 6 months