[fedocal] master: Add a list view (3dcce5e)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 3dcce5ef32f564c1797cf07d7da6f678dad278a7
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Dec 11 19:42:52 2012 +0100
Add a list view
In the main menu there is now an entry to see all the meetings of the year, year/month or
even year/month/day for a given calendar.
Update the documentation accordingly to reflect these possibilities.
This commit adds a new dependency to python-dateutil (version 1.5 or lower).
The recursive meetings should be added as if they were individuals.
>---------------------------------------------------------------
doc/usage.rst | 25 +++++++
fedocal/__init__.py | 72 ++++++++++++++++++++
fedocal/templates/master.html | 6 ++
.../templates/{agenda.html => meeting_list.html} | 55 ++++++++-------
requirements.txt | 1 +
5 files changed, 132 insertions(+), 27 deletions(-)
diff --git a/doc/usage.rst b/doc/usage.rst
index bf289e6..91a8184 100644
--- a/doc/usage.rst
+++ b/doc/usage.rst
@@ -9,6 +9,7 @@ Fedocal has basically two levels for the users:
- administrators
- users
+
Administrators
~~~~~~~~~~~~~~
@@ -233,6 +234,30 @@ This iCal is read-only and can be found at::
+List view
+---------
+
+Sometime it is interesting to have an overview of all the meetings over
+a given time period. The easiest way to achieve this is simply to have a
+list of all the meetings in this period.
+
+This list view can be found at::
+
+ http://<url to fedocal>/list/<calendar name>/
+
+This page can also be accessed from the main menu, for each calendar
+under the `List view` link.
+
+By default this will show you the list of all the meetings in the current
+year, but you can restrict or change the period by specifying a year or
+a year and a month or even a year, a month and a day::
+
+ http://<url to fedocal>/list/<calendar name>/<year>/
+ http://<url to fedocal>/list/<calendar name>/<year>/<month>/
+ http://<url to fedocal>/list/<calendar name>/<year>/<month>/<day>/
+
+
+
.. _reminders:
Reminders
diff --git a/fedocal/__init__.py b/fedocal/__init__.py
index 4cf3006..ea2f80b 100644
--- a/fedocal/__init__.py
+++ b/fedocal/__init__.py
@@ -32,6 +32,7 @@ import pkg_resources
import ConfigParser
import os
import datetime
+from dateutil.relativedelta import relativedelta
from urlparse import urljoin, urlparse
import vobject
from sqlalchemy.exc import SQLAlchemyError
@@ -171,6 +172,77 @@ def calendar(calendar_name, year, month, day):
admin=admin)
+(a)APP.route('/list/<calendar_name>/',
+ defaults={'year': None, 'month': None, 'day': None})
+(a)APP.route('/list/<calendar_name>/<int:year>/',
+ defaults={'month': None, 'day': None})
+(a)APP.route('/list/<calendar_name>/<int:year>/<int:month>/',
+ defaults={'day': None})
+(a)APP.route('/list/<calendar_name>/<int:year>/<int:month>/<int:day>/')
+def calendar_list(calendar_name, year, month, day):
+ """ Display in a list form all the meetings of a given calendar.
+ By default it displays all the meetings of the current year but this
+ can be more restricted to a month or even a day.
+
+ :arg calendar_name: the name of the calendar that one would like to
+ consult.
+ :arg year: the year of the date one would like to consult.
+ :arg month: the month of the date one would like to consult.
+ :arg day: the day of the date one would like to consult.
+ """
+ if not year:
+ inyear = datetime.date.today().year
+ else:
+ inyear = year
+ if not month:
+ inmonth = 1
+ else:
+ inmonth = month
+ if not day:
+ inday = 1
+ else:
+ inday = day
+ start_date = datetime.date(inyear, inmonth, inday)
+ if not month and not day:
+ end_date = start_date + relativedelta(years=+1)
+ elif not day:
+ end_date = start_date + relativedelta(months=+1)
+ else:
+ end_date = start_date + relativedelta(days=+1)
+
+ calendarobj = Calendar.by_id(SESSION, calendar_name)
+ tzone = get_timezone()
+ meetings_utc = Meeting.get_by_date(SESSION, calendarobj, start_date,
+ end_date)
+ meetings = [fedocallib.convert_meeting_timezone(meeting, 'UTC', tzone)
+ for meeting in meetings_utc]
+ week_start = fedocallib.get_start_week(inyear, inmonth, inday)
+ weekdays = fedocallib.get_week_days(inyear, inmonth, inday)
+ next_week = fedocallib.get_next_week(week_start.year,
+ week_start.month, week_start.day)
+ prev_week = fedocallib.get_previous_week(week_start.year,
+ week_start.month, week_start.day)
+ month_name = datetime.date.today().strftime('%B')
+ auth_form = forms.LoginForm()
+ admin = is_admin()
+
+ today = datetime.date.today()
+
+ curmonth_cal = fedocallib.get_html_monthly_cal(year=year,
+ month=month, day=day, calendar_name=calendar_name)
+ return flask.render_template('meeting_list.html',
+ calendar=calendarobj,
+ month=month_name,
+ meetings=meetings,
+ tzone=tzone,
+ weekdays=weekdays,
+ next_week=next_week,
+ prev_week=prev_week,
+ auth_form=auth_form,
+ curmonth_cal=curmonth_cal,
+ admin=admin)
+
+
@APP.route('/ical/<calendar_name>/')
def ical_out(calendar_name):
""" Returns a iCal feed of the calendar from today - 1 month to
diff --git a/fedocal/templates/master.html b/fedocal/templates/master.html
index ec6039a..5ec1459 100644
--- a/fedocal/templates/master.html
+++ b/fedocal/templates/master.html
@@ -58,6 +58,12 @@
</li>
{% endif %}
<li>
+ <a href="{{ url_for('calendar_list',
+ calendar_name=calendar.calendar_name) }}">
+ List view
+ </a>
+ </li>
+ <li>
<a href="{{url_for('ical_out',
calendar_name=calendar.calendar_name)}}"
title="Add this calendar to your agenda">iCal export</a>
diff --git a/fedocal/templates/agenda.html b/fedocal/templates/meeting_list.html
similarity index 70%
copy from fedocal/templates/agenda.html
copy to fedocal/templates/meeting_list.html
index 2dd50be..146b359 100644
--- a/fedocal/templates/agenda.html
+++ b/fedocal/templates/meeting_list.html
@@ -30,41 +30,42 @@
</a>
</nav>
{% endif %}
-<div id='agenda'>
+
+<div id='meeting_list'>
+ <p> Time are expressed in the {{ tzone }} time zone.</p>
<table>
<tr>
- <th>{{ tzone }} time</th>
- {% for day in weekdays %}
- <th> {{ day.strftime('%A %d') }}</th>
- {% endfor %}
+ <td>Date</td>
+ <td>Time</td>
+ <td>Meeting</td>
+ <td>Description</td>
+ {% if calendar.calendar_regional_meetings %}
+ <td>Region</td>
+ {% endif %}
</tr>
- {% for time_entry in meetings |sort %}
+ {% for meeting in meetings %}
<tr>
- {% if time_entry.endswith('00') %}
- <th class="time">{{ time_entry }}</th>
- {% else %}
- <th></th>
- {% endif %}
- {% for meeting_list in meetings[time_entry] %}
- {% if loop.index == day_index %}
- <td class="today">
- {% else %}
- <td>
+ <td>
+ {{ meeting.meeting_date }}
+ {% if meeting.meeting_date != meeting.meeting_date_end %}
+ to {{ meeting.meeting_date_end }}
{% endif %}
- {% if meeting_list %}
- {% for meeting in meeting_list %}
- <a class="event meeting_{{ meeting.meeting_id }}"
+ </td>
+ <td>
+ {{ meeting.meeting_time_start }} to
+ {{ meeting.meeting_time_stop }}
+ </td>
+ <td>
+ <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>
- {% endfor %}
+ </a>
+ </td>
+ <td> {{ meeting.meeting_information }} </td>
+ {% if calendar.calendar_regional_meetings %}
+ <td> {{ meeting.meeting_region }} </td>
+ {% endif %}
</tr>
{% endfor %}
</table>
diff --git a/requirements.txt b/requirements.txt
index 385570c..52a2ee1 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -9,3 +9,4 @@ kitchen
python-fedora
pytz
alembic
+python-dateutil <= 1.5
11 years, 4 months
[fedocal] master: Set the end date of the meeting according to the stop time. (42606bc)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 42606bc33ca01235414ec95c84515f4482333b6b
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Dec 11 19:13:11 2012 +0100
Set the end date of the meeting according to the stop time.
This is necessary to be able to handle meeting in a timezone going from 00:00 to 23:59
Ref #10
>---------------------------------------------------------------
fedocal/fedocallib/__init__.py | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/fedocal/fedocallib/__init__.py b/fedocal/fedocallib/__init__.py
index d46cb0a..f2ff36d 100644
--- a/fedocal/fedocallib/__init__.py
+++ b/fedocal/fedocallib/__init__.py
@@ -288,8 +288,9 @@ def get_meetings(session, calendar, year=None, month=None, day=None,
minutes=start_delta)
startdt = convert_time(startdt, 'UTC', tzone)
- stopdt = datetime(meeting.meeting_date.year,
- meeting.meeting_date.month, meeting.meeting_date.day,
+ stopdt = datetime(meeting.meeting_date_end.year,
+ meeting.meeting_date_end.month,
+ meeting.meeting_date_end.day,
meeting.meeting_time_stop.hour,
meeting.meeting_time_stop.minute, 0) + timedelta(
minutes=stop_delta)
@@ -733,7 +734,7 @@ def add_meeting(session, calendarobj, fas_user,
meeting_name=meeting_name,
meeting_manager=managers,
meeting_date=meeting_time_start.date(),
- meeting_date_end=None,
+ meeting_date_end=meeting_time_stop.date(),
meeting_time_start=meeting_time_start,
meeting_time_stop=meeting_time_stop,
meeting_information=meeting_information,
11 years, 4 months
[fedocal] master: Make the region in the forms a SelectionBox rather than a TextField (12b6a83)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 12b6a83241ecd26566a06058dd98a4fad4283797
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Dec 11 18:57:02 2012 +0100
Make the region in the forms a SelectionBox rather than a TextField
>---------------------------------------------------------------
fedocal/forms.py | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/fedocal/forms.py b/fedocal/forms.py
index 6ca86d3..b2512b3 100644
--- a/fedocal/forms.py
+++ b/fedocal/forms.py
@@ -97,7 +97,13 @@ class AddMeetingForm(wtf.Form):
information = wtf.TextAreaField('Information')
- meeting_region = wtf.TextField('Region')
+ meeting_region = wtf.SelectField('Region',
+ [wtf.validators.optional()],
+ choices=[('APAC', 'APAC'),
+ ('EMEA', 'EMEA'),
+ ('LATAM', 'LATAM'),
+ ('NA', 'NA')]
+ )
# Recursion
frequency = wtf.SelectField('Repeat every',
11 years, 4 months
[fedocal] master: Order the Meeting by meeting_date in get_by_date (456a007)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 456a007180cf894ef40714bf865980d53e66f8e4
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Dec 11 18:56:32 2012 +0100
Order the Meeting by meeting_date in get_by_date
>---------------------------------------------------------------
fedocal/fedocallib/model.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/fedocal/fedocallib/model.py b/fedocal/fedocallib/model.py
index 5404be5..ce75348 100644
--- a/fedocal/fedocallib/model.py
+++ b/fedocal/fedocallib/model.py
@@ -274,7 +274,8 @@ class Meeting(BASE):
return session.query(cls).filter(and_
(Meeting.calendar == calendar),
(Meeting.meeting_date >= start_date),
- (Meeting.meeting_date < stop_date)).all()
+ (Meeting.meeting_date < stop_date)
+ ).order_by(Meeting.meeting_date).all()
@classmethod
def get_active_regular_meeting(cls, session, calendar, end_date):
11 years, 4 months
[fedocal] master: When we update the timezone of a meeting update both start and end date. (d9519a4)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit d9519a468ebd67bf13bd03f25849f04aa2ee28f1
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Dec 11 18:55:58 2012 +0100
When we update the timezone of a meeting update both start and end date.
>---------------------------------------------------------------
fedocal/fedocallib/__init__.py | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/fedocal/fedocallib/__init__.py b/fedocal/fedocallib/__init__.py
index d5f02ea..d46cb0a 100644
--- a/fedocal/fedocallib/__init__.py
+++ b/fedocal/fedocallib/__init__.py
@@ -71,12 +71,14 @@ def convert_meeting_timezone(meeting, tzfrom, tzto):
meeting.meeting_time_start.minute),
tzfrom, tzto)
meeting_stop = convert_time(
- datetime(meeting.meeting_date.year, meeting.meeting_date.month,
- meeting.meeting_date.day,
+ datetime(meeting.meeting_date_end.year,
+ meeting.meeting_date_end.month,
+ meeting.meeting_date_end.day,
meeting.meeting_time_stop.hour,
meeting.meeting_time_stop.minute),
tzfrom, tzto)
meeting.meeting_date = meeting_start.date()
+ meeting.meeting_date_end = meeting_stop.date()
meeting.meeting_time_start = meeting_start.time()
meeting.meeting_time_stop = meeting_stop.time()
return meeting
11 years, 4 months
[fedocal] master: Hey look two routes for one function (52b2c71)
by pingou@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 52b2c71b6864e0f19a6342419f572b22ca6c2ccc
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Dec 11 08:52:47 2012 +0100
Hey look two routes for one function
We can simplify the routing by providing default values to that specific function. This
reduces the code and code complexity.
Templates were adjusted for to fix the link.
>---------------------------------------------------------------
fedocal/__init__.py | 18 +++++-------------
fedocal/fedocallib/fedora_calendar.py | 6 +++---
fedocal/templates/agenda.html | 4 ++--
3 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/fedocal/__init__.py b/fedocal/__init__.py
index 61fd7b0..4cf3006 100644
--- a/fedocal/__init__.py
+++ b/fedocal/__init__.py
@@ -111,7 +111,8 @@ def index():
"""
calendars = Calendar.get_all(SESSION)
if calendars:
- return calendar(calendars[0].calendar_name)
+ return calendar(calendars[0].calendar_name, None, None,
+ None)
else:
auth_form = forms.LoginForm()
admin = is_admin()
@@ -121,20 +122,11 @@ def index():
admin=admin)
-(a)APP.route('/<calendar_name>/')
-def calendar(calendar_name):
- """ Display the current week for a specific calendar.
-
- :arg calendar_name: the name of the calendar that one would like to
- consult.
- """
- return calendar_fullday(calendar_name, year=None, month=None,
- day=None)
-
-
# pylint: disable=R0914
+(a)APP.route('/<calendar_name>/',
+ defaults={'year': None, 'month': None, 'day': None})
@APP.route('/<calendar_name>/<int:year>/<int:month>/<int:day>/')
-def calendar_fullday(calendar_name, year, month, day):
+def calendar(calendar_name, year, month, day):
""" Display the week of a specific date for a specified calendar.
:arg calendar_name: the name of the calendar that one would like to
diff --git a/fedocal/fedocallib/fedora_calendar.py b/fedocal/fedocallib/fedora_calendar.py
index b62b495..5905bf4 100644
--- a/fedocal/fedocallib/fedora_calendar.py
+++ b/fedocal/fedocallib/fedora_calendar.py
@@ -46,7 +46,7 @@ class FedocalCalendar(HTMLCalendar):
link_day = day
if self.calendar_name:
link_day = '<a href="%s">%d</a>' % (flask.url_for(
- 'calendar_fullday',
+ 'calendar',
calendar_name=self.calendar_name, year=self.year,
month=self.month, day=day), day)
if day == cur_date.day \
@@ -91,7 +91,7 @@ class FedocalCalendar(HTMLCalendar):
if self.calendar_name:
prev_month_lnk = '<a class="button" href="%s"><</a>' % (
flask.url_for(
- 'calendar_fullday',
+ 'calendar',
calendar_name=self.calendar_name,
year=int(prev_year),
month=int(prev_month),
@@ -105,7 +105,7 @@ class FedocalCalendar(HTMLCalendar):
if self.calendar_name:
next_month_lnk = '<a class="button" href="%s">></a>' % (
flask.url_for(
- 'calendar_fullday',
+ 'calendar',
calendar_name=self.calendar_name,
year=int(next_year),
month=int(next_month),
diff --git a/fedocal/templates/agenda.html b/fedocal/templates/agenda.html
index 257c909..2dd50be 100644
--- a/fedocal/templates/agenda.html
+++ b/fedocal/templates/agenda.html
@@ -17,13 +17,13 @@
<p>{{ calendar.calendar_description }}</p>
</header>
<nav id="weeks">
- <a href="{{url_for('calendar_fullday',
+ <a href="{{url_for('calendar',
calendar_name=calendar.calendar_name, year=prev_week.year,
month=prev_week.month, day=prev_week.day)}}" class="button">
<
</a>
{{ weekdays | WeekHeading }}
- <a href="{{url_for('calendar_fullday',
+ <a href="{{url_for('calendar',
calendar_name=calendar.calendar_name, year=next_week.year,
month=next_week.month, day=next_week.day)}}" class="button">
>
11 years, 5 months
[fedocal] master: pep8 run on fedocallib/__init__.py (b3f0866)
by Pierre-YvesChibon
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit b3f086666d45efb0a28ec56671a59013aa8e44a9
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Mon Dec 10 21:48:46 2012 +0100
pep8 run on fedocallib/__init__.py
>---------------------------------------------------------------
fedocal/fedocallib/__init__.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/fedocal/fedocallib/__init__.py b/fedocal/fedocallib/__init__.py
index 1a37a04..d5f02ea 100644
--- a/fedocal/fedocallib/__init__.py
+++ b/fedocal/fedocallib/__init__.py
@@ -508,6 +508,7 @@ def agenda_is_free_in_future(session, calendar, meeting_date,
agenda_free = False
return agenda_free
+
def is_user_managing_in_calendar(session, calendar_name, fas_user):
""" Returns True if the user is in a group set as manager of the
calendar and False otherwise. It will also return True if there are
@@ -699,7 +700,7 @@ def add_meeting(session, calendarobj, fas_user,
if frequency and end_repeats:
futur_meeting_at_time = agenda_is_free_in_future(session, calendarobj,
- meeting_date,end_repeats,
+ meeting_date, end_repeats,
meeting_time_start.time(), meeting_time_stop.time())
if not bool(calendarobj.calendar_multiple_meetings) and \
11 years, 5 months
[fedocal] master: When editing or adding a recursive meeting check that the time slot is always available (4e39dfd)
by Pierre-YvesChibon
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 4e39dfd1db216c158cc757e3e3e42dc628740374
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Mon Dec 10 20:36:37 2012 +0100
When editing or adding a recursive meeting check that the time slot is always available
This is aiming at preventing meeting conflicting later in the recursion.
Additionally, when editing a recursive meeting we keep the old one as long as there the
meeting used to be part of a recursion, we don't need to know if the new meeting is
part of a recursion or not.
Fix the unit-tests accordingly to keep our coverage.
Fixes ticket 18
>---------------------------------------------------------------
fedocal/fedocallib/__init__.py | 59 +++++++++++++++++++++++++++++++++++++-
fedocal/tests/test_fedocallib.py | 23 +++++++++++++++
2 files changed, 81 insertions(+), 1 deletions(-)
diff --git a/fedocal/fedocallib/__init__.py b/fedocal/fedocallib/__init__.py
index 6028606..1a37a04 100644
--- a/fedocal/fedocallib/__init__.py
+++ b/fedocal/fedocallib/__init__.py
@@ -473,6 +473,41 @@ def agenda_is_free(session, calendar, meeting_date,
return agenda_free
+def agenda_is_free_in_future(session, calendar, meeting_date,
+ recursion_ends, time_start, time_stop):
+ """For recursive meeting, check for meetings happening at the
+ specified time between the specified date and the end of the
+ recursion.
+
+ :arg session: the database session to use
+ :arg calendar: the name of the calendar of interest.
+ :arg meeting_date: the date of the meeting (as Datetime object)
+ :arg recursion_ends: the end date of the recursion
+ :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.in_future_at_time(session, calendar, meeting_date,
+ recursion_ends, time_start)
+ meetings.extend(Meeting.in_future_at_time(session, calendar,
+ meeting_date, recursion_ends, time_stop))
+ meetings.extend(Meeting.get_in_future_by_time(session, calendar,
+ meeting_date, recursion_ends, time_start, time_stop))
+ agenda_free = True
+ for meeting in set(meetings):
+ if time_start <= meeting.meeting_time_start \
+ and meeting.meeting_time_start < time_stop:
+ agenda_free = False
+ elif time_start < meeting.meeting_time_stop \
+ and meeting.meeting_time_stop <= time_stop:
+ agenda_free = False
+ elif time_start < meeting.meeting_time_start \
+ and time_stop > meeting.meeting_time_stop:
+ agenda_free = False
+ elif time_start > meeting.meeting_time_start \
+ and time_stop < meeting.meeting_time_stop:
+ agenda_free = False
+ return agenda_free
+
def is_user_managing_in_calendar(session, calendar_name, fas_user):
""" Returns True if the user is in a group set as manager of the
calendar and False otherwise. It will also return True if there are
@@ -662,6 +697,17 @@ def add_meeting(session, calendarobj, fas_user,
raise InvalidMeeting(
'The start or end time you have entered is already occupied.')
+ if frequency and end_repeats:
+ futur_meeting_at_time = agenda_is_free_in_future(session, calendarobj,
+ meeting_date,end_repeats,
+ meeting_time_start.time(), meeting_time_stop.time())
+
+ if not bool(calendarobj.calendar_multiple_meetings) and \
+ futur_meeting_at_time:
+ raise InvalidMeeting(
+ 'The start or end time you have entered is already '
+ 'occupied in the future.')
+
reminder = None
if remind_when and remind_who:
try:
@@ -729,6 +775,17 @@ def edit_meeting(session, meeting, calendarobj, fas_user,
raise InvalidMeeting(
'The start date of your meeting is later than the end date.')
+ if recursion_frequency and recursion_ends:
+ futur_meeting_at_time = agenda_is_free_in_future(session,
+ calendarobj, meeting_date, recursion_ends,
+ meeting_time_start, meeting_time_stop)
+
+ if not bool(calendarobj.calendar_multiple_meetings) and \
+ futur_meeting_at_time:
+ raise InvalidMeeting(
+ 'The start or end time you have entered is already '
+ 'occupied in the future.')
+
## The information are correct
## What we do now:
# a) the meeting is not recursive -> edit the information as provided
@@ -743,7 +800,7 @@ def edit_meeting(session, meeting, calendarobj, fas_user,
# -> copy meeting to new object w/ recursion and date = date + offset
remove_recursion = False
- if recursion_frequency and meeting.recursion_frequency:
+ if meeting.recursion_frequency:
old_meeting = Meeting.copy(meeting)
old_meeting.recursion_ends = meeting_date - timedelta(days=1)
if old_meeting.recursion_ends > old_meeting.meeting_date:
diff --git a/fedocal/tests/test_fedocallib.py b/fedocal/tests/test_fedocallib.py
index 60709f4..ed90b45 100644
--- a/fedocal/tests/test_fedocallib.py
+++ b/fedocal/tests/test_fedocallib.py
@@ -1004,6 +1004,29 @@ class Fedocallibtests(Modeltests):
self.assertEqual(meeting.meeting_date_end, date.today() +
timedelta(days=3))
+ meeting = model.Meeting.by_id(self.session, 9)
+ fedocallib.edit_meeting(
+ self.session, meeting, calendarobj, fasuser,
+ 'Test meeting with reminder-2.3',
+ date.today() + timedelta(days=1), date.today() + timedelta(
+ days=2),
+ time(23, 0), time(23, 59), None,
+ 'Information3', None, 'Europe/Paris',
+ None, None, # Recursion
+ None, None, # Reminder
+ edit_all_meeting=False)
+ meeting = model.Meeting.by_id(self.session, 9)
+ self.assertNotEqual(meeting, None)
+ self.assertEqual(meeting.meeting_name,
+ 'Test meeting with reminder-2.3')
+ self.assertEqual(meeting.meeting_manager, 'username,')
+ self.assertEqual(meeting.meeting_information, 'Information3')
+ self.assertEqual(meeting.reminder, None)
+ self.assertEqual(meeting.recursion_ends, None)
+ self.assertEqual(meeting.recursion_frequency, None)
+ self.assertEqual(meeting.meeting_date_end, date.today() +
+ timedelta(days=2))
+
if __name__ == '__main__':
SUITE = unittest.TestLoader().loadTestsFromTestCase(Fedocallibtests)
11 years, 5 months
[fedocal] master: Add methods to check for the availability of a time slot over a given time period (f9be80d)
by Pierre-YvesChibon
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit f9be80d297c29934689480b2418aad8c50aa2f95
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Mon Dec 10 20:33:13 2012 +0100
Add methods to check for the availability of a time slot over a given time period
This is necessary for recursive meeting where we need to make sure that there is not a
meeting later in the recursion (ie: in 3 months) that will happen at the same time as this
one.
>---------------------------------------------------------------
fedocal/fedocallib/model.py | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/fedocal/fedocallib/model.py b/fedocal/fedocallib/model.py
index 82a00c3..5404be5 100644
--- a/fedocal/fedocallib/model.py
+++ b/fedocal/fedocallib/model.py
@@ -316,6 +316,19 @@ class Meeting(BASE):
(Meeting.meeting_time_stop < stop_time)).all()
@classmethod
+ def get_in_future_by_time(cls, session, calendar, meetingdate,
+ recursion_ends, start_time, stop_time):
+ """ Retrieve the list of meetings for a given date and between
+ two times for a specific calendar.
+ """
+ return session.query(cls).filter(and_
+ (Meeting.calendar == calendar),
+ (Meeting.meeting_date >= meetingdate),
+ (Meeting.meeting_date <= recursion_ends),
+ (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.
"""
@@ -326,6 +339,19 @@ class Meeting(BASE):
(Meeting.meeting_time_stop > t_time)).all()
@classmethod
+ def in_future_at_time(cls, session, calendar, meetingdate,
+ recursion_ends, t_time):
+ """ Returns the meeting occuring at this specifict time point
+ at any time in the future.
+ """
+ return session.query(cls).filter(and_
+ (Meeting.calendar == calendar),
+ (Meeting.meeting_date >= meetingdate),
+ (Meeting.meeting_date <= recursion_ends),
+ (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):
""" Retrieve the list of meetings which specified username
is among the managers and which date is older than the specified
11 years, 5 months