Skip to content

Commit 21d642f

Browse files
committed
Visualize the revision timeline of drafts, chartes, status changes and conflict
reviews using a Google Chart Timeline. - Legacy-Id: 9920
1 parent 1fb8f5a commit 21d642f

7 files changed

Lines changed: 103 additions & 1 deletion

File tree

ietf/doc/utils.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import urllib
44
import math
55
import datetime
6+
import operator
67

78
from django.conf import settings
89
from django.db.models import Q
@@ -590,3 +591,26 @@ def uppercase_std_abbreviated_name(name):
590591
return name.upper()
591592
else:
592593
return name
594+
595+
596+
def crawl_history(doc):
597+
# return document history data for use in ietf/templates/doc/timeline.html
598+
def ancestors(doc):
599+
retval = []
600+
for rel in doc.relateddocument_set.filter(relationship__slug='replaces'):
601+
if not rel.target.document in retval:
602+
retval.append(rel.target.document)
603+
retval.extend(ancestors(rel.target.document))
604+
return retval
605+
606+
history = ancestors(doc)
607+
history.append(doc)
608+
609+
retval = []
610+
for d in history:
611+
for e in d.docevent_set.filter(type='new_revision'):
612+
retval.append((d.name, e.newrevisiondocevent.rev, e.time.isoformat()))
613+
e = doc.latest_event(type='published_rfc')
614+
if e:
615+
retval.append((doc.name, e.doc.canonical_name, e.time.isoformat()))
616+
return sorted(retval, key=operator.itemgetter(2))

ietf/doc/views_doc.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
from ietf.doc.utils import ( add_links_in_new_revision_events, augment_events_with_revision,
5050
can_adopt_draft, get_chartering_type, get_document_content, get_tags_for_stream_id,
5151
needed_ballot_positions, nice_consensus, prettify_std_name, update_telechat, has_same_ballot,
52-
get_initial_notify, make_notify_changed_event )
52+
get_initial_notify, make_notify_changed_event, crawl_history)
5353
from ietf.community.models import CommunityList
5454
from ietf.doc.mails import email_ad
5555
from ietf.group.models import Role
@@ -414,6 +414,7 @@ def document_main(request, name, rev=None):
414414
search_archive=search_archive,
415415
actions=actions,
416416
tracking_document=tracking_document,
417+
rev_history=crawl_history(doc),
417418
),
418419
context_instance=RequestContext(request))
419420

@@ -453,6 +454,7 @@ def document_main(request, name, rev=None):
453454
group=group,
454455
milestones=milestones,
455456
can_manage=can_manage,
457+
rev_history=crawl_history(doc),
456458
),
457459
context_instance=RequestContext(request))
458460

@@ -481,6 +483,7 @@ def document_main(request, name, rev=None):
481483
conflictdoc=conflictdoc,
482484
ballot_summary=ballot_summary,
483485
approved_states=('appr-reqnopub-pend','appr-reqnopub-sent','appr-noprob-pend','appr-noprob-sent'),
486+
rev_history=crawl_history(doc),
484487
),
485488
context_instance=RequestContext(request))
486489

@@ -516,6 +519,7 @@ def document_main(request, name, rev=None):
516519
ballot_summary=ballot_summary,
517520
approved_states=('appr-pend','appr-sent'),
518521
sorted_relations=sorted_relations,
522+
rev_history=crawl_history(doc),
519523
),
520524
context_instance=RequestContext(request))
521525

ietf/templates/doc/document_charter.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,20 @@
88
<link rel="alternate" type="application/atom+xml" href="/feed/group-changes/{{ group.acronym }}/">
99
{% endblock %}
1010

11+
{% block js %}
12+
$(window).on("resize", function (event) {
13+
draw_timeline();
14+
});
15+
{% endblock %}
16+
1117
{% block title %}{{ doc.title }}{% endblock %}
1218

1319
{% block content %}
1420
{% origin %}
1521
{{ top|safe }}
1622

1723
{% include "doc/revisions_list.html" %}
24+
{% include "doc/timeline.html" %}
1825

1926
<table class="table table-condensed">
2027
<thead id="message-row">

ietf/templates/doc/document_conflict_review.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@
44

55
{% load ietf_filters %}
66

7+
{% block js %}
8+
$(window).on("resize", function (event) {
9+
draw_timeline();
10+
});
11+
{% endblock %}
12+
713
{% block title %}{{ doc.title }}{% endblock %}
814

915
{% block content %}
1016
{% origin %}
1117
{{ top|safe }}
1218

1319
{% include "doc/revisions_list.html" %}
20+
{% include "doc/timeline.html" %}
1421

1522
<table class="table table-condensed">
1623
<thead id="message-row">

ietf/templates/doc/document_draft.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
.inline { display: inline; }
1414
{% endblock %}
1515

16+
{% block js %}
17+
$(window).on("resize", function (event) {
18+
draw_timeline();
19+
});
20+
{% endblock %}
21+
1622
{% block title %}
1723
{% if doc.get_state_slug == "rfc" %}
1824
RFC {{ rfc_number }}
@@ -26,6 +32,7 @@
2632
{{ top|safe }}
2733

2834
{% include "doc/revisions_list.html" %}
35+
{% include "doc/timeline.html" %}
2936

3037
<table class="table table-condensed">
3138
<thead id="message-row">

ietf/templates/doc/document_status_change.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@
44

55
{% load ietf_filters %}
66

7+
{% block js %}
8+
$(window).on("resize", function (event) {
9+
draw_timeline();
10+
});
11+
{% endblock %}
12+
713
{% block title %}{{ doc.title }}{% endblock %}
814

915
{% block content %}
1016
{% origin %}
1117
{{ top|safe }}
1218

1319
{% include "doc/revisions_list.html" %}
20+
{% include "doc/timeline.html" %}
1421

1522
<table class="table table-condensed">
1623
<thead id="message-row">

ietf/templates/doc/timeline.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization', 'version':'1','packages':['timeline']}]}"></script>
2+
3+
<script>
4+
google.setOnLoadCallback(draw_timeline);
5+
6+
function draw_timeline() {
7+
var data = [
8+
{% for r in rev_history %}
9+
[ '{{r.0}}', '{{r.1}}', new Date('{{ r.2 }}') ],
10+
{% endfor %}
11+
];
12+
13+
if (data[0]) {
14+
var t = $('#timeline')[0];
15+
var c = new google.visualization.Timeline(t);
16+
var d = new google.visualization.DataTable();
17+
18+
d.addColumn({ type: 'string', id: 'Name' });
19+
d.addColumn({ type: 'string', id: 'Revision' });
20+
d.addColumn({ type: 'date', id: 'Start' });
21+
d.addColumn({ type: 'date', id: 'End' });
22+
23+
for (i = 0; i < data.length-1; i++) {
24+
d.addRow([ data[0][0], data[i][0] + "-" + data[i][1], data[i][2], data[i+1][2] ]);
25+
}
26+
if (!data[i][1].match(/rfc/)) {
27+
d.addRow([ data[0][0], data[i][0] + "-" + data[i][1], data[i][2], new Date() ]);
28+
}
29+
30+
var options = {
31+
tooltip: { isHtml: true, },
32+
timeline: { showRowLabels: false,
33+
rowLabelStyle: { fontName: "PT Serif", fontSize: 13 },
34+
barLabelStyle: { fontName: "PT Serif", fontSize: 13 }
35+
},
36+
hAxis: {
37+
textStyle: { fontName: "PT Serif", fontSize: 13 },
38+
}
39+
};
40+
$('#timeline').css('height', '100');
41+
c.draw(d, options);
42+
}
43+
}
44+
</script>
45+
46+
<div id="timeline"></div>

0 commit comments

Comments
 (0)