Repository :
http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
---------------------------------------------------------------
commit bb65d08caacfe8ce934e578608d9a7d3fb471ad7
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Wed Nov 14 15:02:19 2012 +0100
Add a contact email to each calendar
From now on each calendar must have a contact email. This can be either
someone or a mailing list (recommanded).
This includes a database change.
---------------------------------------------------------------
.../versions/45d83da297e8_add_calendar_contact.py | 25 ++++++++++++++
doc/usage.rst | 5 +++
fedocal/__init__.py | 13 ++++---
fedocal/fedocallib/model.py | 4 ++-
fedocal/forms.py | 2 +
fedocal/templates/add_calendar.html | 1 +
fedocal/tests/test_calendar.py | 36 ++++++++++++++------
fedocal/tests/test_fedocallib.py | 7 +++-
8 files changed, 74 insertions(+), 19 deletions(-)
diff --git a/alembic/versions/45d83da297e8_add_calendar_contact.py
b/alembic/versions/45d83da297e8_add_calendar_contact.py
new file mode 100644
index 0000000..e8d156a
--- /dev/null
+++ b/alembic/versions/45d83da297e8_add_calendar_contact.py
@@ -0,0 +1,25 @@
+"""Add calendar contact field
+
+Revision ID: 45d83da297e8
+Revises: 2c5c36431061
+Create Date: 2012-11-14 14:30:07.352865
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '45d83da297e8'
+down_revision = '2c5c36431061'
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+ """ Add the calendar_contact field to the calendar table.
"""
+ op.add_column('calendars', sa.Column('calendar_contact',
sa.String(80)))
+
+
+def downgrade():
+ """ Remove the calendar_contact field to the calendar table.
"""
+ op.drop_column('calendars', 'calendar_contact')
+
diff --git a/doc/usage.rst b/doc/usage.rst
index ce96040..f3af99e 100644
--- a/doc/usage.rst
+++ b/doc/usage.rst
@@ -41,6 +41,11 @@ The form to will ask for:
- ``calendar name``: the name of the calendar as used in the link and as title
for this calendar.
+- ``calendar contact``: an address email that will be publish as contact point
+ for this calendar. This is not linked to :ref:`reminders` but it is more
+ aimed at providing an email to people wanted to obtain information about a
+ specific calendar.
+
- ``calendar description``: a short description of what the calendar is used for.
This description will also show up on the page of the calendar and should
thus not be too long.
diff --git a/fedocal/__init__.py b/fedocal/__init__.py
index 418ad51..6095285 100644
--- a/fedocal/__init__.py
+++ b/fedocal/__init__.py
@@ -261,11 +261,14 @@ def add_calendar():
# pylint: disable=E1101
if form.validate_on_submit():
calendarobj = Calendar(
- form.calendar_name.data,
- form.calendar_description.data,
- form.calendar_manager_groups.data,
- bool(form.calendar_multiple_meetings.data),
- bool(form.calendar_regional_meetings.data),
+ calendar_name=form.calendar_name.data,
+ calendar_contact=form.calendar_contact.data,
+ calendar_description=form.calendar_description.data,
+ calendar_manager_group=form.calendar_manager_groups.data,
+ calendar_multiple_meetings=bool(
+ form.calendar_multiple_meetings.data),
+ calendar_regional_meetings=bool(
+ form.calendar_regional_meetings.data),
)
try:
calendarobj.save(SESSION)
diff --git a/fedocal/fedocallib/model.py b/fedocal/fedocallib/model.py
index e78826b..bb89928 100644
--- a/fedocal/fedocallib/model.py
+++ b/fedocal/fedocallib/model.py
@@ -66,17 +66,19 @@ class Calendar(BASE):
__tablename__ = 'calendars'
calendar_name = Column(String(80), primary_key=True)
+ calendar_contact = Column(String(80))
calendar_description = Column(String(500))
calendar_manager_group = Column(String(100)) # 3 groups (3*32)
calendar_multiple_meetings = Column(Boolean, default=False)
calendar_regional_meetings = Column(Boolean, default=False)
# pylint: disable=R0913
- def __init__(self, calendar_name, calendar_description,
+ def __init__(self, calendar_name, calendar_contact, calendar_description,
calendar_manager_group, calendar_multiple_meetings=False,
calendar_regional_meetings=False):
""" Constructor instanciating the defaults values.
"""
self.calendar_name = calendar_name
+ self.calendar_contact = calendar_contact
self.calendar_description = calendar_description
self.calendar_manager_group = calendar_manager_group
self.calendar_multiple_meetings = calendar_multiple_meetings
diff --git a/fedocal/forms.py b/fedocal/forms.py
index 91a2b00..d9a0321 100644
--- a/fedocal/forms.py
+++ b/fedocal/forms.py
@@ -33,6 +33,8 @@ class AddCalendarForm(wtf.Form):
""" Form used to create a new calendar. """
calendar_name = wtf.TextField('Calendar',
[wtf.validators.Required()])
+ calendar_contact = wtf.TextField('Contact email',
+ [wtf.validators.Required()])
calendar_description = wtf.TextField('Description')
calendar_manager_groups = wtf.TextField('Manager groups')
calendar_multiple_meetings = wtf.BooleanField(
diff --git a/fedocal/templates/add_calendar.html b/fedocal/templates/add_calendar.html
index 00f6da3..d449752 100644
--- a/fedocal/templates/add_calendar.html
+++ b/fedocal/templates/add_calendar.html
@@ -14,6 +14,7 @@
<form action="" method="post">
{{ render_field(form.calendar_name) }}
+ {{ render_field(form.calendar_contact) }}
{{ render_field(form.calendar_description) }}
{{ render_field(form.calendar_manager_groups) }}
{{ render_field(form.calendar_multiple_meetings) }}
diff --git a/fedocal/tests/test_calendar.py b/fedocal/tests/test_calendar.py
index f0868a1..eee73ed 100644
--- a/fedocal/tests/test_calendar.py
+++ b/fedocal/tests/test_calendar.py
@@ -46,29 +46,43 @@ class Calendartests(Modeltests):
def test_init_calendar(self):
""" Test the Calendar init function. """
- obj = model.Calendar('test_calendar', 'This is a test calendar',
- 'fi-apprentice', False)
+ obj = model.Calendar(
+ calendar_name='test_calendar',
+ calendar_contact='test(a)example.com',
+ calendar_description='This is a test calendar',
+ calendar_manager_group='fi-apprentice',
+ calendar_multiple_meetings=False)
obj.save(self.session)
self.session.commit()
self.assertNotEqual(obj, None)
- obj = model.Calendar('test_calendar2',
- 'This is another test calendar',
- 'packager', True)
+ obj = model.Calendar(
+ calendar_name='test_calendar2',
+ calendar_contact='test2(a)example.com',
+ calendar_description='This is another test calendar',
+ calendar_manager_group='packager',
+ calendar_multiple_meetings=True)
obj.save(self.session)
self.session.commit()
self.assertNotEqual(obj, None)
- obj = model.Calendar('test_calendar3',
- 'This is the third test calendar',
- 'packager', True)
+ obj = model.Calendar(
+ calendar_name='test_calendar3',
+ calendar_contact='test3(a)example.com',
+ calendar_description='This is the third test calendar',
+ calendar_manager_group='packager',
+ calendar_multiple_meetings=True)
obj.save(self.session)
self.session.commit()
self.assertNotEqual(obj, None)
- obj = model.Calendar('test_calendar4',
- 'This is yet another test calendar',
- 'packager', True, True)
+ obj = model.Calendar(
+ calendar_name='test_calendar4',
+ calendar_contact='test4(a)example.com',
+ calendar_description='This is yet another test calendar',
+ calendar_manager_group='packager',
+ calendar_multiple_meetings=True,
+ calendar_regional_meetings=True)
obj.save(self.session)
self.session.commit()
self.assertNotEqual(obj, None)
diff --git a/fedocal/tests/test_fedocallib.py b/fedocal/tests/test_fedocallib.py
index 380e9be..0fb97b7 100644
--- a/fedocal/tests/test_fedocallib.py
+++ b/fedocal/tests/test_fedocallib.py
@@ -441,8 +441,11 @@ class Fedocallibtests(Modeltests):
self.assertFalse(fedocallib.is_user_managing_in_calendar(
self.session, 'test_calendar', user))
- calendar = model.Calendar('test_calendar30',
- 'This is a test calendar30', '')
+ calendar = model.Calendar(
+ calendar_name='test_calendar30',
+ calendar_contact='test30(a)example.com',
+ calendar_description='This is a test calendar30',
+ calendar_manager_group='')
calendar.save(self.session)
self.session.commit()