#208 Replace the wtforms.TextField by wtforms.StringField
Merged 2 years ago by pingou. Opened 2 years ago by pingou.

file modified
+12 -11
@@ -780,9 +780,9 @@ 

          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 @@ 

      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 @@ 

                  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 @@ 

                  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 @@ 

          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()

file modified
+15 -14
@@ -65,7 +65,8 @@ 

      """ 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 @@ 

  

  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 @@ 

          [wtforms.validators.DataRequired()],

          choices=[])

  

-     meeting_name = wtforms.TextField(

+     meeting_name = wtforms.StringField(

          _('Meeting name'),

          [wtforms.validators.DataRequired()])

  
@@ -138,11 +139,11 @@ 

          _('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 @@ 

          [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 @@ 

              ('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()])

  

file modified
+4 -4
@@ -111,7 +111,7 @@ 

  

              # If no date is specified, it returns the next occurence

              self.assertIn(

-                 '<input id="meeting_date" name="meeting_date" required type="text" '

+                 '<input id="meeting_date" name="meeting_date" required type="date" '

                  'value="%s">' % (next_date), output_text

              )

  
@@ -124,7 +124,7 @@ 

              output2_text = output2.get_data(as_text=True)

  

              self.assertIn(

-                 '<input id="meeting_date" name="meeting_date" required type="text" '

+                 '<input id="meeting_date" name="meeting_date" required type="date" '

                  'value="%s">' % (TODAY + timedelta(days=28)), output2_text

              )

  
@@ -136,7 +136,7 @@ 

              output2_text = output2.get_data(as_text=True)

  

              self.assertIn(

-                 '<input id="meeting_date" name="meeting_date" required type="text" '

+                 '<input id="meeting_date" name="meeting_date" required type="date" '

                  'value="%s">' % (TODAY + timedelta(days=14)), output2_text

              )

  
@@ -146,7 +146,7 @@ 

              output2_text = output2.get_data(as_text=True)

  

              self.assertIn(

-                 '<input id="meeting_date" name="meeting_date" required type="text" '

+                 '<input id="meeting_date" name="meeting_date" required type="date" '

                  'value="%s">' % (TODAY), output2_text

              )

  

file modified
+1 -1
@@ -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