Merged in [19665] from jennifer@painless-security.com:
Guard against null timeslot location in agenda.html and add test of location_anchor tag
- Legacy-Id: 19668
Note: SVN reference [19665] has been migrated to Git commit b77e6627a4
This commit is contained in:
commit
c33ab6f92a
|
@ -179,7 +179,8 @@ class TimeSlotFactory(factory.django.DjangoModelFactory):
|
||||||
def location(obj, create, extracted, **kwargs): # pylint: disable=no-self-argument
|
def location(obj, create, extracted, **kwargs): # pylint: disable=no-self-argument
|
||||||
if create:
|
if create:
|
||||||
if extracted:
|
if extracted:
|
||||||
obj.location = extracted
|
# accept the string "none" to set location to null
|
||||||
|
obj.location = None if extracted == 'none' else extracted
|
||||||
else:
|
else:
|
||||||
obj.location = RoomFactory(meeting=obj.meeting)
|
obj.location = RoomFactory(meeting=obj.meeting)
|
||||||
obj.save()
|
obj.save()
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
# Copyright The IETF Trust 2009-2020, All Rights Reserved
|
# Copyright The IETF Trust 2009-2020, All Rights Reserved
|
||||||
# -*- coding: utf-8 -*-
|
# -*- 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.meeting.templatetags.agenda_custom_tags import AnchorNode
|
||||||
from ietf.utils.test_utils import TestCase
|
from ietf.utils.test_utils import TestCase
|
||||||
|
|
||||||
|
@ -18,3 +21,23 @@ class AgendaCustomTagsTests(TestCase):
|
||||||
self.fail(f'{subclass.__name__} must implement resolve_url() method')
|
self.fail(f'{subclass.__name__} must implement resolve_url() method')
|
||||||
except:
|
except:
|
||||||
pass # any other failure ok since we used garbage inputs
|
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,
|
||||||
|
)
|
||||||
|
|
|
@ -157,9 +157,9 @@
|
||||||
<div class="hidden-sm hidden-md hidden-lg">
|
<div class="hidden-sm hidden-md hidden-lg">
|
||||||
{% include "meeting/timeslot_start_end.html" %}
|
{% include "meeting/timeslot_start_end.html" %}
|
||||||
</div>
|
</div>
|
||||||
{% location_anchor item.timeslot %}
|
{% if item.timeslot.show_location and item.timeslot.location %}{% location_anchor item.timeslot %}
|
||||||
{{ item.timeslot.get_html_location }}
|
{{ item.timeslot.get_html_location }}
|
||||||
{% end_location_anchor %}
|
{% end_location_anchor %}{% endif %}
|
||||||
{% if item.timeslot.show_location and item.timeslot.get_html_location %}
|
{% if item.timeslot.show_location and item.timeslot.get_html_location %}
|
||||||
{% with item.timeslot.location.floorplan as floor %}
|
{% with item.timeslot.location.floorplan as floor %}
|
||||||
{% if item.timeslot.location.floorplan %}
|
{% if item.timeslot.location.floorplan %}
|
||||||
|
@ -238,9 +238,9 @@
|
||||||
<div class="hidden-sm hidden-md hidden-lg">
|
<div class="hidden-sm hidden-md hidden-lg">
|
||||||
{% include "meeting/timeslot_start_end.html" %}
|
{% include "meeting/timeslot_start_end.html" %}
|
||||||
</div>
|
</div>
|
||||||
{% location_anchor item.timeslot %}
|
{% if item.timeslot.show_location and item.timeslot.location %}{% location_anchor item.timeslot %}
|
||||||
{{ item.timeslot.get_html_location }}
|
{{ item.timeslot.get_html_location }}
|
||||||
{% end_location_anchor %}
|
{% end_location_anchor %}{% endif %}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -255,9 +255,9 @@
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% location_anchor item.timeslot %}
|
{% if item.timeslot.show_location and item.timeslot.location %}{% location_anchor item.timeslot %}
|
||||||
{{ item.timeslot.get_html_location }}
|
{{ item.timeslot.get_html_location }}
|
||||||
{% end_location_anchor %}
|
{% end_location_anchor %}{% endif %}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td><div class="hidden-xs">{{item.session.historic_group.historic_parent.acronym}}</div></td>
|
<td><div class="hidden-xs">{{item.session.historic_group.historic_parent.acronym}}</div></td>
|
||||||
|
|
Loading…
Reference in a new issue