Added back the on-agenda calendar links to document lists, now in an implementation with better performance characteristics.
- Legacy-Id: 15020
This commit is contained in:
parent
2bb5788a76
commit
248c2dd055
|
@ -6,7 +6,7 @@ import debug # pyflakes:ignore
|
||||||
from ietf.community.utils import augment_docs_with_tracking_info
|
from ietf.community.utils import augment_docs_with_tracking_info
|
||||||
from ietf.doc.models import Document, DocAlias, RelatedDocument, DocEvent, TelechatDocEvent, BallotDocEvent
|
from ietf.doc.models import Document, DocAlias, RelatedDocument, DocEvent, TelechatDocEvent, BallotDocEvent
|
||||||
from ietf.doc.expire import expirable_draft
|
from ietf.doc.expire import expirable_draft
|
||||||
|
from ietf.meeting.models import SessionPresentation, Meeting, Session
|
||||||
|
|
||||||
def wrap_value(v):
|
def wrap_value(v):
|
||||||
return lambda: v
|
return lambda: v
|
||||||
|
@ -26,6 +26,21 @@ def fill_in_telechat_date(docs, doc_dict=None, doc_ids=None):
|
||||||
d.telechat_date = wrap_value(d.telechat_date(e))
|
d.telechat_date = wrap_value(d.telechat_date(e))
|
||||||
seen.add(e.doc_id)
|
seen.add(e.doc_id)
|
||||||
|
|
||||||
|
def fill_in_document_sessions(docs, doc_dict, doc_ids):
|
||||||
|
beg_date = datetime.date.today()-datetime.timedelta(days=7)
|
||||||
|
end_date = datetime.date.today()+datetime.timedelta(days=30)
|
||||||
|
meetings = Meeting.objects.filter(date__gte=beg_date, date__lte=end_date).prefetch_related('session_set')
|
||||||
|
# get sessions
|
||||||
|
sessions = Session.objects.filter(meeting_id__in=[ m.id for m in meetings ])
|
||||||
|
# get presentations
|
||||||
|
presentations = SessionPresentation.objects.filter(session_id__in=[ s.id for s in sessions ])
|
||||||
|
session_list = [ (p.document_id, p.session) for p in presentations ]
|
||||||
|
for d in doc_dict.values():
|
||||||
|
d.sessions = []
|
||||||
|
for (i, s) in session_list:
|
||||||
|
if i in doc_ids:
|
||||||
|
doc_dict[i].sessions.append(s)
|
||||||
|
|
||||||
def fill_in_document_table_attributes(docs, have_telechat_date=False):
|
def fill_in_document_table_attributes(docs, have_telechat_date=False):
|
||||||
# fill in some attributes for the document table results to save
|
# fill in some attributes for the document table results to save
|
||||||
# some hairy template code and avoid repeated SQL queries
|
# some hairy template code and avoid repeated SQL queries
|
||||||
|
@ -58,14 +73,8 @@ def fill_in_document_table_attributes(docs, have_telechat_date=False):
|
||||||
fill_in_telechat_date(docs, doc_dict, doc_ids)
|
fill_in_telechat_date(docs, doc_dict, doc_ids)
|
||||||
|
|
||||||
# on agenda in upcoming meetings
|
# on agenda in upcoming meetings
|
||||||
sessions = {}
|
# get meetings
|
||||||
# debug.mark()
|
fill_in_document_sessions(docs, doc_dict, doc_ids)
|
||||||
# presentations = SessionPresentation.objects.filter(session__meeting__date__gte=datetime.date.today()-datetime.timedelta(days=7)).select_related('session', 'document')
|
|
||||||
# session_list = [ (p.document, p.session) for p in presentations ]
|
|
||||||
# sessions = dict( (d, []) for (d, s) in session_list )
|
|
||||||
# for (d, s) in session_list:
|
|
||||||
# sessions[d].append(s)
|
|
||||||
# debug.clock('presentations')
|
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
for d in docs:
|
for d in docs:
|
||||||
|
@ -95,8 +104,6 @@ def fill_in_document_table_attributes(docs, have_telechat_date=False):
|
||||||
d.milestones = [ m for (t, m) in sorted(((m.time, m) for m in d.groupmilestone_set.all() if m.state_id == "active")) ]
|
d.milestones = [ m for (t, m) in sorted(((m.time, m) for m in d.groupmilestone_set.all() if m.state_id == "active")) ]
|
||||||
d.reviewed_by_teams = sorted(set(r.team.acronym for r in d.reviewrequest_set.filter(state__in=["requested","accepted","part-completed","completed"]).distinct().select_related('team')))
|
d.reviewed_by_teams = sorted(set(r.team.acronym for r in d.reviewrequest_set.filter(state__in=["requested","accepted","part-completed","completed"]).distinct().select_related('team')))
|
||||||
|
|
||||||
d.sessions = sessions[d] if d in sessions else []
|
|
||||||
|
|
||||||
e = d.latest_event_cache.get('started_iesg_proces', None)
|
e = d.latest_event_cache.get('started_iesg_proces', None)
|
||||||
d.balloting_started = e.time if e else datetime.datetime.min
|
d.balloting_started = e.time if e else datetime.datetime.min
|
||||||
|
|
||||||
|
|
|
@ -19,14 +19,14 @@
|
||||||
<a href="{% url "ietf.community.views.track_document" username=request.user.username name=doc.name %}" class="track-untrack-doc {% if doc.tracked_in_personal_community_list %}hide{% endif %}" title="Add to your personal ID list">
|
<a href="{% url "ietf.community.views.track_document" username=request.user.username name=doc.name %}" class="track-untrack-doc {% if doc.tracked_in_personal_community_list %}hide{% endif %}" title="Add to your personal ID list">
|
||||||
<span class="fa fa-bookmark-o"></span>
|
<span class="fa fa-bookmark-o"></span>
|
||||||
</a>
|
</a>
|
||||||
|
<br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for session in doc.sessions %}
|
{% for session in doc.sessions %}
|
||||||
<br><small>
|
|
||||||
<a href="{% url 'ietf.meeting.views.ical_agenda' num=session.meeting.number session_id=session.id %}"
|
<a href="{% url 'ietf.meeting.views.ical_agenda' num=session.meeting.number session_id=session.id %}"
|
||||||
title="Calendar entry: document is on the agenda for {{ session.group.acronym }}@{{ session.meeting }}">
|
title="Calendar entry: document is on the agenda for {{ session.group.acronym }}@{{ session.meeting }}">
|
||||||
<span class="fa fa-calendar"></span>
|
{# font-size set to make the width of fa-calendar come out the same as fa-bookmark-o above: #}
|
||||||
|
<span class="fa fa-calendar" style="font-size: 75%"></span>
|
||||||
</a>
|
</a>
|
||||||
</small>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue