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})
+@APP.route('/list/<calendar_name>/<int:year>/',
+ defaults={'month': None, 'day': None})
+@APP.route('/list/<calendar_name>/<int:year>/<int:month>/',
+ defaults={'day': None})
+@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