|
| 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 |
1 | 7 | from ietf.doc.models import Document, DocAlias, RelatedDocument, DocEvent, TelechatDocEvent |
2 | 8 | 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 |
4 | 10 |
|
5 | 11 | def wrap_value(v): |
6 | 12 | return lambda: v |
7 | 13 |
|
| 14 | + |
8 | 15 | def fill_in_document_table_attributes(docs): |
9 | 16 | # fill in some attributes for the document table results to save |
10 | 17 | # some hairy template code and avoid repeated SQL queries |
@@ -35,6 +42,13 @@ def fill_in_document_table_attributes(docs): |
35 | 42 | d.telechat_date = wrap_value(d.telechat_date(e)) |
36 | 43 | seen.add(e.doc_id) |
37 | 44 |
|
| 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 | + |
38 | 52 | # misc |
39 | 53 | for d in docs: |
40 | 54 | # emulate canonical name which is used by a lot of the utils |
@@ -64,6 +78,7 @@ def fill_in_document_table_attributes(docs): |
64 | 78 |
|
65 | 79 | 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) |
66 | 80 |
|
| 81 | + d.sessions = sessions[d] if d in sessions else [] |
67 | 82 |
|
68 | 83 | # RFCs |
69 | 84 |
|
@@ -101,10 +116,13 @@ def prepare_document_table(request, docs, query=None, max_results=500): |
101 | 116 | if not isinstance(docs, list): |
102 | 117 | # evaluate and fill in attribute results immediately to decrease |
103 | 118 | # 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") |
106 | 122 |
|
107 | | - docs = list(docs[:max_results]) |
| 123 | + if docs.count() > max_results: |
| 124 | + docs = docs[:max_results] |
| 125 | + docs = list(docs) |
108 | 126 |
|
109 | 127 | fill_in_document_table_attributes(docs) |
110 | 128 | augment_docs_with_tracking_info(docs, request.user) |
|
0 commit comments