Skip to content

Commit 1fd4a4d

Browse files
committed
Added session ical links to document lists (WG docs, search results, etc.) for documents on upcoming meeting agendas. Reduced the query and rendering times of document lists some more through additional prefetch_related().
- Legacy-Id: 14799
1 parent 88c3e90 commit 1fd4a4d

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

ietf/doc/utils_search.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
# Copyright The IETF Trust 2016, All Rights Reserved
2+
3+
import datetime
4+
import debug # pyflakes:ignore
5+
6+
from ietf.community.utils import augment_docs_with_tracking_info
17
from ietf.doc.models import Document, DocAlias, RelatedDocument, DocEvent, TelechatDocEvent
28
from ietf.doc.expire import expirable_draft
3-
from ietf.community.utils import augment_docs_with_tracking_info
9+
from ietf.meeting.models import SessionPresentation
410

511
def wrap_value(v):
612
return lambda: v
713

14+
815
def fill_in_document_table_attributes(docs):
916
# fill in some attributes for the document table results to save
1017
# some hairy template code and avoid repeated SQL queries
@@ -35,6 +42,13 @@ def fill_in_document_table_attributes(docs):
3542
d.telechat_date = wrap_value(d.telechat_date(e))
3643
seen.add(e.doc_id)
3744

45+
# on agenda in upcoming meetings
46+
presentations = SessionPresentation.objects.filter(session__meeting__date__gte=datetime.date.today()-datetime.timedelta(days=15)).select_related('session', 'document')
47+
session_list = [ (p.document, p.session) for p in presentations ]
48+
sessions = dict( (d, []) for (d, s) in session_list )
49+
for (d, s) in session_list:
50+
sessions[d].append(s)
51+
3852
# misc
3953
for d in docs:
4054
# emulate canonical name which is used by a lot of the utils
@@ -64,6 +78,7 @@ def fill_in_document_table_attributes(docs):
6478

6579
d.reviewed_by_teams = sorted(set(r.team for r in d.reviewrequest_set.filter(state__in=["requested","accepted","part-completed","completed"])), key=lambda g: g.acronym)
6680

81+
d.sessions = sessions[d] if d in sessions else []
6782

6883
# RFCs
6984

@@ -101,10 +116,13 @@ def prepare_document_table(request, docs, query=None, max_results=500):
101116
if not isinstance(docs, list):
102117
# evaluate and fill in attribute results immediately to decrease
103118
# the number of queries
104-
docs = docs.select_related("ad", "std_level", "intended_std_level", "group", "stream")
105-
docs = docs.prefetch_related("states__type", "tags", "groupmilestone_set__group", "reviewrequest_set__team")
119+
docs = docs.select_related("ad", "std_level", "intended_std_level", "group", "stream", "shepherd", )
120+
docs = docs.prefetch_related("states__type", "tags", "groupmilestone_set__group", "reviewrequest_set__team",
121+
"submission_set__checks", "ad__email_set")
106122

107-
docs = list(docs[:max_results])
123+
if docs.count() > max_results:
124+
docs = docs[:max_results]
125+
docs = list(docs)
108126

109127
fill_in_document_table_attributes(docs)
110128
augment_docs_with_tracking_info(docs, request.user)

ietf/templates/doc/search/search_result_row.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
<span class="fa fa-bookmark-o"></span>
2121
</a>
2222
{% endif %}
23+
{% for session in doc.sessions %}
24+
<br><small>
25+
<a href="{% url 'ietf.meeting.views.ical_agenda' num=session.meeting.number session_id=session.id %}"
26+
title="Calendar entry: document is on the agenda for {{ session.group.acronym }}@{{ session.meeting }}">
27+
<span class="fa fa-calendar"></span>
28+
</a>
29+
</small>
30+
{% endfor %}
2331
</td>
2432

2533
<td class="doc">

0 commit comments

Comments
 (0)