diff --git a/ietf/meeting/factories.py b/ietf/meeting/factories.py index a227b405a..799e0b16e 100644 --- a/ietf/meeting/factories.py +++ b/ietf/meeting/factories.py @@ -179,7 +179,8 @@ class TimeSlotFactory(factory.django.DjangoModelFactory): def location(obj, create, extracted, **kwargs): # pylint: disable=no-self-argument if create: if extracted: - obj.location = extracted + # accept the string "none" to set location to null + obj.location = None if extracted == 'none' else extracted else: obj.location = RoomFactory(meeting=obj.meeting) obj.save() diff --git a/ietf/meeting/templatetags/tests.py b/ietf/meeting/templatetags/tests.py index eb85fd47b..2734a57cd 100644 --- a/ietf/meeting/templatetags/tests.py +++ b/ietf/meeting/templatetags/tests.py @@ -1,6 +1,9 @@ # Copyright The IETF Trust 2009-2020, All Rights Reserved # -*- coding: utf-8 -*- +from django.template import Context, Template + +from ietf.meeting.factories import TimeSlotFactory from ietf.meeting.templatetags.agenda_custom_tags import AnchorNode from ietf.utils.test_utils import TestCase @@ -18,3 +21,23 @@ class AgendaCustomTagsTests(TestCase): self.fail(f'{subclass.__name__} must implement resolve_url() method') except: pass # any other failure ok since we used garbage inputs + + def test_location_anchor_node(self): + context = Context({ + 'no_location': TimeSlotFactory(location='none'), + 'no_show_location': TimeSlotFactory(show_location=False), + 'show_location': TimeSlotFactory(location__name='My Location'), + }) + template = Template(""" + {% load agenda_custom_tags %} + {% location_anchor no_location %}no_location{% end_location_anchor %} + {% location_anchor no_show_location %}no_show_location{% end_location_anchor %} + {% location_anchor show_location %}show_location{% end_location_anchor %} + """) + result = template.render(context) + self.assertInHTML('no_location', result) + self.assertInHTML('no_show_location', result) + self.assertInHTML( + f'show_location', + result, + ) diff --git a/ietf/templates/meeting/agenda.html b/ietf/templates/meeting/agenda.html index 85890dd4d..0f3725a5c 100644 --- a/ietf/templates/meeting/agenda.html +++ b/ietf/templates/meeting/agenda.html @@ -157,9 +157,9 @@
- {% location_anchor item.timeslot %} + {% if item.timeslot.show_location and item.timeslot.location %}{% location_anchor item.timeslot %} {{ item.timeslot.get_html_location }} - {% end_location_anchor %} + {% end_location_anchor %}{% endif %} {% if item.timeslot.show_location and item.timeslot.get_html_location %} {% with item.timeslot.location.floorplan as floor %} {% if item.timeslot.location.floorplan %} @@ -238,9 +238,9 @@ - {% location_anchor item.timeslot %} + {% if item.timeslot.show_location and item.timeslot.location %}{% location_anchor item.timeslot %} {{ item.timeslot.get_html_location }} - {% end_location_anchor %} + {% end_location_anchor %}{% endif %} {% else %} @@ -255,9 +255,9 @@ {% endwith %}