From 7bd097e1a61d54c27feb88884534c2bc22eeece9 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 03 2022 10:52:12 +0000 Subject: [PATCH 1/3] Replace the wtforms.TextField by wtforms.StringField Fixes https://pagure.io/fedocal/issue/206 Signed-off-by: Pierre-Yves Chibon --- diff --git a/fedocal/__init__.py b/fedocal/__init__.py index 4f0fb42..bcf1e75 100644 --- a/fedocal/__init__.py +++ b/fedocal/__init__.py @@ -780,9 +780,9 @@ def add_calendar(): calendarobj = Calendar( calendar_name=form.calendar_name.data, calendar_contact=form.calendar_contact.data, - calendar_description=form.calendar_description.data, - calendar_editor_group=form.calendar_editor_groups.data, - calendar_admin_group=form.calendar_admin_groups.data, + calendar_description=form.calendar_description.data or '', + calendar_editor_group=form.calendar_editor_groups.data or '', + calendar_admin_group=form.calendar_admin_groups.data or '', calendar_status=form.calendar_status.data ) try: @@ -858,10 +858,10 @@ def add_meeting(calendar_name, full=True): if form.validate_on_submit(): tzone = form.meeting_timezone.data or tzone try: - information = form.information.data + information = form.information.data or '' # If a wiki_link is specified add it at the end of the # description - if form.wiki_link.data.strip(): + if form.wiki_link.data and form.wiki_link.data.strip(): wiki_link = form.wiki_link.data.strip() if wiki_link not in information: information += '\n\nMore information available at:'\ @@ -877,7 +877,7 @@ def add_meeting(calendar_name, full=True): meeting_time_stop=form.meeting_time_stop.data, comanager=form.comanager.data, meeting_information=information, - meeting_location=form.meeting_location.data, + meeting_location=form.meeting_location.data or '', tzone=tzone, frequency=form.frequency.data, end_repeats=form.end_repeats.data, @@ -1010,8 +1010,8 @@ def edit_meeting(meeting_id): meeting_time_start=form.meeting_time_start.data, meeting_time_stop=form.meeting_time_stop.data, comanager=form.comanager.data, - meeting_information=form.information.data, - meeting_location=form.meeting_location.data, + meeting_information=form.information.data or '', + meeting_location=form.meeting_location.data or '', tzone=tzone, recursion_frequency=form.frequency.data, recursion_ends=form.end_repeats.data, @@ -1351,11 +1351,12 @@ def edit_calendar(calendar_name): try: calendarobj.calendar_name = form.calendar_name.data calendarobj.calendar_contact = form.calendar_contact.data - calendarobj.calendar_description = form.calendar_description.data + calendarobj.calendar_description = \ + form.calendar_description.data or '' calendarobj.calendar_editor_group = \ - form.calendar_editor_groups.data + form.calendar_editor_groups.data or '' calendarobj.calendar_admin_group = \ - form.calendar_admin_groups.data + form.calendar_admin_groups.data or '' calendarobj.calendar_status = form.calendar_status.data calendarobj.save(SESSION) SESSION.commit() diff --git a/fedocal/forms.py b/fedocal/forms.py index 001119c..f070c83 100644 --- a/fedocal/forms.py +++ b/fedocal/forms.py @@ -65,7 +65,8 @@ def validate_multi_email(form, field): """ Raises an exception if the content of the field does not contain one or more email. """ - data = field.data.replace(' ', ',') + data = field.data or '' + data = data.replace(' ', ',') for entry in data.split(','): entry = entry.strip() if not entry: @@ -79,15 +80,15 @@ def validate_multi_email(form, field): class AddCalendarForm(i18nforms.Form): """ Form used to create a new calendar. """ - calendar_name = wtforms.TextField( + calendar_name = wtforms.StringField( _('Calendar'), [wtforms.validators.DataRequired()]) - calendar_contact = wtforms.TextField( + calendar_contact = wtforms.StringField( _('Contact email'), [wtforms.validators.DataRequired()]) - calendar_description = wtforms.TextField(_('Description')) - calendar_editor_groups = wtforms.TextField(_('Editor groups')) - calendar_admin_groups = wtforms.TextField(_('Admin groups')) + calendar_description = wtforms.StringField(_('Description')) + calendar_editor_groups = wtforms.StringField(_('Editor groups')) + calendar_admin_groups = wtforms.StringField(_('Admin groups')) calendar_status = wtforms.SelectField( _('Status'), [wtforms.validators.DataRequired()], @@ -126,7 +127,7 @@ class AddMeetingForm(i18nforms.Form): [wtforms.validators.DataRequired()], choices=[]) - meeting_name = wtforms.TextField( + meeting_name = wtforms.StringField( _('Meeting name'), [wtforms.validators.DataRequired()]) @@ -138,11 +139,11 @@ class AddMeetingForm(i18nforms.Form): _('End date'), [wtforms.validators.optional()]) - meeting_time_start = wtforms.TextField( + meeting_time_start = wtforms.StringField( _('Start time'), [wtforms.validators.DataRequired(), validate_time]) - meeting_time_stop = wtforms.TextField( + meeting_time_stop = wtforms.StringField( _('Stop time'), [wtforms.validators.DataRequired(), validate_time]) @@ -151,13 +152,13 @@ class AddMeetingForm(i18nforms.Form): [wtforms.validators.DataRequired()], choices=[(tzone, tzone) for tzone in sorted(common_timezones)]) - wiki_link = wtforms.TextField(_('More information URL')) + wiki_link = wtforms.StringField(_('More information URL')) - comanager = wtforms.TextField(_('Co-manager')) + comanager = wtforms.StringField(_('Co-manager')) information = wtforms.TextAreaField(_('Information')) - meeting_location = wtforms.TextField( + meeting_location = wtforms.StringField( _('Location'), [wtforms.validators.optional(), validate_meeting_location] ) @@ -190,10 +191,10 @@ class AddMeetingForm(i18nforms.Form): ('H-168', _('%(days)s days before', days='7')), ] ) - remind_who = wtforms.TextField( + remind_who = wtforms.StringField( _('Send reminder to'), [validate_multi_email, wtforms.validators.optional()]) - reminder_from = wtforms.TextField( + reminder_from = wtforms.StringField( _('Send reminder from'), [wtforms.validators.Email(), wtforms.validators.optional()]) From 452c55ad46a09927b9d7e124aa95bef05e27b398 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 03 2022 10:52:23 +0000 Subject: [PATCH 2/3] Adjust test for newer wtforms Signed-off-by: Pierre-Yves Chibon --- diff --git a/tests/test_flask_extras.py b/tests/test_flask_extras.py index d9f47c4..81501da 100644 --- a/tests/test_flask_extras.py +++ b/tests/test_flask_extras.py @@ -111,7 +111,7 @@ class ExtrasFlasktests(Modeltests): # If no date is specified, it returns the next occurence self.assertIn( - '' % (next_date), output_text ) @@ -124,7 +124,7 @@ class ExtrasFlasktests(Modeltests): output2_text = output2.get_data(as_text=True) self.assertIn( - '' % (TODAY + timedelta(days=28)), output2_text ) @@ -136,7 +136,7 @@ class ExtrasFlasktests(Modeltests): output2_text = output2.get_data(as_text=True) self.assertIn( - '' % (TODAY + timedelta(days=14)), output2_text ) @@ -146,7 +146,7 @@ class ExtrasFlasktests(Modeltests): output2_text = output2.get_data(as_text=True) self.assertIn( - '' % (TODAY), output2_text ) From 049bd75ac36b907f4519df8c5d027d3a18be72b9 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 03 2022 10:52:37 +0000 Subject: [PATCH 3/3] Add python 3.10 to the test matrix Signed-off-by: Pierre-Yves Chibon --- diff --git a/tox.ini b/tox.ini index 121d70f..a7f5f74 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py3{6,7,8,9} +envlist = py3{6,7,8,9,10} # If the user is missing an interpreter, don't fail skip_missing_interpreters = True