#188 Add checks for None in meetings widget
Merged 7 years ago by atelic. Opened 7 years ago by atelic.
atelic/fedora-hubs fix/meetings-break-with-none  into  develop

file modified
+4 -3
@@ -41,7 +41,7 @@ 

          # their local with moment.js.

          meeting['start_time'] = meeting['meeting_time_start'][:-3] + " UTC"

          meeting['stop_time'] = meeting['meeting_time_stop'][:-3] + " UTC"

-         meeting['location'] = meeting['meeting_location']

+         meeting['location'] = meeting['meeting_location'] or ''

          if '@' in meeting['location']:

              meeting['location'] = '#' + meeting['location'].split('@')[0]

          if stop_dt - start_dt >= datetime.timedelta(hours=24) :
@@ -71,8 +71,9 @@ 

  

      tmp = collections.defaultdict(list)

      for meeting in response['meetings']:

-         meeting['meeting_information_html'] = utils.markup(

-             meeting['meeting_information'])

+         if meeting.get('meeting_information_html'):

+             meeting['meeting_information_html'] = utils.markup(

+                 meeting['meeting_information'])

          tmp[meeting['meeting_name']].append(meeting)

  

      meetings = {}

@@ -26,6 +26,7 @@ 

        </a>

      </div>

    </div>

+   {% if next.get('meeting_information_html')  %}

    <div class="row">

        <div class="col-md-12 meeting-info">

          {{ next.meeting_information_html[:150] }}
@@ -36,6 +37,7 @@ 

          {% endif %}

        </div>

    </div>

+   {% endif  %}

  </div>

  {% if meetings | length > 1 %} <hr> {% endif %}

  {% endfor %}

Purpose

Right now there is some data that gets pulled down that has None for meeting_location and/or meeting_information. This causes breakage and the meetings widget will not load.

Changes

  • Checks in meetings.py that avoid iterating or calling a function on None
  • Check in meetings.html that is a result of the above

FTR you don't need to specify None in the second part as if there is no second argument, it will default to None

>>> print {}.get('foo')
None
>>> print {}.get('foo', None)
None

:thumbsup: for me as well

Thanks. Would you like me to remove the two instances of it?

As you like, it doesn't do any arm but we might as well get them out of the way while we think of it

rebased

7 years ago

Cool, go ahead and merge :)

Preferred way? Just use the merge button here?

The merge button here should work just fine :)

Pull-Request has been merged by atelic

7 years ago