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 %} + <span>{% location_anchor no_location %}no_location{% end_location_anchor %}</span> + <span>{% location_anchor no_show_location %}no_show_location{% end_location_anchor %}</span> + <span>{% location_anchor show_location %}show_location{% end_location_anchor %}</span> + """) + result = template.render(context) + self.assertInHTML('<span>no_location</span>', result) + self.assertInHTML('<span>no_show_location</span>', result) + self.assertInHTML( + f'<span><a href="{context["show_location"].location.floorplan_url()}">show_location</a></span>', + 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 @@ <div class="hidden-sm hidden-md hidden-lg"> {% include "meeting/timeslot_start_end.html" %} </div> - {% 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 @@ <div class="hidden-sm hidden-md hidden-lg"> {% include "meeting/timeslot_start_end.html" %} </div> - {% 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 %} </td> {% else %} @@ -255,9 +255,9 @@ {% endwith %} </td> <td> - {% 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 %} </td> <td><div class="hidden-xs">{{item.session.historic_group.historic_parent.acronym}}</div></td>