fix: unexpected chatlog links (#8774)
* fix: unexpected chatlog links * fix: separate handling of polls and chatlogs
This commit is contained in:
parent
2b7d4ad414
commit
f9ca030864
ietf
|
@ -7736,6 +7736,44 @@ class SessionTests(TestCase):
|
|||
self.assertEqual(r.status_code, 404)
|
||||
self.assertFalse(mock_delete.called)
|
||||
|
||||
def test_show_chatlog_links(self):
|
||||
meeting = MeetingFactory(type_id='ietf', number='122')
|
||||
session = SessionFactory(meeting=meeting)
|
||||
doc_name = 'chatlog-72-mars-197001010000'
|
||||
SessionPresentation.objects.create(session=session,document=DocumentFactory(type_id='chatlog', name=doc_name))
|
||||
|
||||
session_url = urlreverse('ietf.meeting.views.session_details',
|
||||
kwargs={'num':meeting.number, 'acronym':session.group.acronym})
|
||||
|
||||
r = self.client.get(session_url)
|
||||
|
||||
self.assertEqual(r.status_code, 200)
|
||||
|
||||
q = PyQuery(r.content)
|
||||
|
||||
# Find the chatlog link in the desktop view
|
||||
link_chatlog_box = q(f'a[title="Chat logs for {session.group.acronym}"]')
|
||||
self.assertTrue(link_chatlog_box, 'Expected <a> element with title "Chat logs for {group.acronym}" not found.')
|
||||
self.assertEqual(link_chatlog_box.attr('href'), '/doc/'+ doc_name)
|
||||
|
||||
# Find the chatlog link in the mobile view
|
||||
link_chatlog_list = q('li:contains("Chat logs")')
|
||||
self.assertTrue(link_chatlog_list, 'Expected <li> element containing "Chat logs" not found.')
|
||||
self.assertEqual(link_chatlog_list.find('a').attr('href'), '/doc/'+ doc_name)
|
||||
|
||||
def test_hide_chatlog_links(self):
|
||||
# mock meeting and session, but no chatlog document
|
||||
meeting = MeetingFactory(type_id='ietf', number='122')
|
||||
session = SessionFactory(meeting=meeting)
|
||||
|
||||
session_url = urlreverse('ietf.meeting.views.session_details',
|
||||
kwargs={'num':meeting.number, 'acronym':session.group.acronym})
|
||||
|
||||
r = self.client.get(session_url)
|
||||
|
||||
self.assertEqual(r.status_code, 200)
|
||||
# validate no links for chat logs exist
|
||||
self.assertNotContains(r, 'Chat logs')
|
||||
|
||||
|
||||
class HasMeetingsTests(TestCase):
|
||||
|
|
|
@ -23,6 +23,7 @@ from pathlib import Path
|
|||
from urllib.parse import parse_qs, unquote, urlencode, urlsplit, urlunsplit, urlparse
|
||||
from tempfile import mkstemp
|
||||
from wsgiref.handlers import format_date_time
|
||||
from itertools import chain
|
||||
|
||||
from django import forms
|
||||
from django.core.cache import caches
|
||||
|
@ -2496,7 +2497,12 @@ def session_details(request, num, acronym):
|
|||
session.filtered_artifacts.sort(key=lambda d:artifact_types.index(d.document.type.slug))
|
||||
session.filtered_slides = session.presentations.filter(document__type__slug='slides').order_by('order')
|
||||
session.filtered_drafts = session.presentations.filter(document__type__slug='draft')
|
||||
session.filtered_chatlog_and_polls = session.presentations.filter(document__type__slug__in=('chatlog', 'polls')).order_by('document__type__slug')
|
||||
|
||||
filtered_polls = session.presentations.filter(document__type__slug=('polls'))
|
||||
filtered_chatlogs = session.presentations.filter(document__type__slug=('chatlog'))
|
||||
session.filtered_chatlog_and_polls = chain(filtered_chatlogs, filtered_polls)
|
||||
session.chatlog = filtered_chatlogs.first()
|
||||
|
||||
# TODO FIXME Deleted materials shouldn't be in the presentations
|
||||
for qs in [session.filtered_artifacts,session.filtered_slides,session.filtered_drafts]:
|
||||
qs = [p for p in qs if p.document.get_state_slug(p.document.type_id)!='deleted']
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
{% load origin %}
|
||||
{% load static %}
|
||||
{% load textfilters tz %}
|
||||
{% load ietf_filters %}
|
||||
{% load ietf_filters session_filters %}
|
||||
|
||||
{% origin %}
|
||||
{% if item and item|should_show_agenda_session_buttons %}
|
||||
{% with slug=item.slug session=item.session timeslot=item.timeslot %}
|
||||
|
@ -126,10 +127,10 @@
|
|||
</a>
|
||||
{% else %}
|
||||
{# chat logs #}
|
||||
{% if meeting.has_chat_logs %}
|
||||
{% if meeting.has_chat_logs and session.chatlog %}
|
||||
<a class="btn btn-outline-primary"
|
||||
role="button"
|
||||
href="{{session.chat_archive_url}}"
|
||||
href="/doc/{{ session.chatlog.document.name }}"
|
||||
aria-label="Chat logs for {{ session.chat_room_name }}"
|
||||
title="Chat logs for {{ session.chat_room_name }}">
|
||||
<i class="bi bi-file-text"></i>
|
||||
|
@ -303,10 +304,10 @@
|
|||
</li>
|
||||
{% else %}
|
||||
{# chat logs #}
|
||||
{% if meeting.has_chat_logs %}
|
||||
{% if meeting.has_chat_logs and session.chatlog %}
|
||||
<li>
|
||||
<a class="dropdown-item"
|
||||
href="session.chat_room_url">
|
||||
href="/doc/{{ session.chatlog.document.name }}">
|
||||
<i class="bi bi-file-text"></i> Chat logs
|
||||
</a>
|
||||
</li>
|
||||
|
|
Loading…
Reference in a new issue