Skip to content

Commit 40cafc3

Browse files
committed
Improved history tab in "new tracker UI"; per-document page now works better without JavaScript; internal refactoring/cleaning of per-document page
- Legacy-Id: 1906
1 parent 6084b7b commit 40cafc3

8 files changed

Lines changed: 348 additions & 443 deletions

File tree

ietf/idrfc/testurl.list

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,24 @@
44
# draft that's now RFC
55
200 /doc/draft-ietf-avt-rtp-atrac-family/
66
200 /doc/draft-ietf-avt-rtp-atrac-family/_debug.data
7-
200 /doc/draft-ietf-avt-rtp-atrac-family/_comments.data
87
200 /doc/draft-ietf-avt-rtp-atrac-family/_ballot.data
9-
200 /doc/draft-ietf-avt-rtp-atrac-family/_versions.data
108

119
# replaced draft, never went to IESG
1210
200 /doc/draft-eronen-mobike-mopo/
13-
404 /doc/draft-eronen-mobike-mopo/_comments.data
1411
404 /doc/draft-eronen-mobike-mopo/_ballot.data
15-
200 /doc/draft-eronen-mobike-mopo/_versions.data
12+
13+
# expired draft
14+
200 /doc/draft-eronen-eap-sim-aka-80211/
1615

1716
# Normal RFC
1817
200 /doc/rfc4739/
1918
200 /doc/rfc4739/_debug.data
20-
404 /doc/rfc4739/_comments.data
2119
404 /doc/rfc4739/_ballot.data
22-
404 /doc/rfc4739/_versions.data
2320

2421
# RFC that's evaluated in IESG
2522
200 /doc/rfc3852/
2623
200 /doc/rfc3852/_debug.data
27-
200 /doc/rfc3852/_comments.data
2824
200 /doc/rfc3852/_ballot.data
29-
404 /doc/rfc3852/_versions.data
3025

3126
404 /doc/draft-no-such-draft/
3227
404 /doc/rfc4637/

ietf/idrfc/urls.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
(r'^search/$', views_search.search_results),
4040
(r'^(?P<name>[^/]+)/$', views_doc.document_main),
4141
(r'^(?P<name>[^/]+)/_debug.data$', views_doc.document_debug),
42-
(r'^(?P<name>[^/]+)/_comments.data$', views_doc.document_comments),
4342
(r'^(?P<name>[^/]+)/_ballot.data$', views_doc.document_ballot),
44-
(r'^(?P<name>[^/]+)/_versions.data$', views_doc.document_versions),
4543
(r'^ad/(?P<name>[^/]+)/$', views_search.by_ad)
4644
)

ietf/idrfc/views_doc.py

Lines changed: 86 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
1+
# Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
22
# All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
33
#
44
# Redistribution and use in source and binary forms, with or without
@@ -30,7 +30,8 @@
3030
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3131
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3232

33-
import re
33+
import re, os
34+
from datetime import datetime, time
3435
from django.http import HttpResponse, Http404
3536
from django.shortcuts import render_to_response, get_object_or_404
3637
from ietf.idtracker.models import InternetDraft, IDInternal, BallotInfo
@@ -42,6 +43,7 @@
4243
from django.template.defaultfilters import truncatewords_html
4344
from ietf.idtracker.templatetags.ietf_filters import format_textarea, fill
4445

46+
4547
def document_debug(request, name):
4648
r = re.compile("^rfc([0-9]+)$")
4749
m = r.match(name)
@@ -54,29 +56,40 @@ def document_debug(request, name):
5456
doc = IdWrapper(draft=id)
5557
return HttpResponse(doc.to_json(), mimetype='text/plain')
5658

57-
def document_main_rfc(request, rfc_number):
58-
rfci = get_object_or_404(RfcIndex, rfc_number=rfc_number)
59-
doc = RfcWrapper(rfci)
60-
61-
info = {}
62-
content1 = None
63-
content2 = None
59+
def _get_html(key, filename):
6460
f = None
6561
try:
66-
try:
67-
f = open(settings.RFC_PATH+"rfc"+str(rfc_number)+".txt")
68-
content = f.read()
69-
(content1, content2) = markup_txt.markup(content)
70-
except IOError:
71-
content1 = "Error - can't find"+"rfc"+str(rfc_number)+".txt"
72-
content2 = ""
62+
f = open(filename, 'rb')
63+
raw_content = f.read()
64+
except IOError:
65+
return ("Error; cannot read "+key, "")
7366
finally:
7467
if f:
7568
f.close()
69+
(c1,c2) = markup_txt.markup(raw_content)
70+
return (c1,c2)
71+
72+
def document_main_rfc(request, rfc_number):
73+
rfci = get_object_or_404(RfcIndex, rfc_number=rfc_number)
74+
doc = RfcWrapper(rfci)
75+
76+
info = {}
77+
info['is_rfc'] = True
78+
(content1, content2) = _get_html(
79+
"rfc"+str(rfc_number)+",html",
80+
os.path.join(settings.RFC_PATH, "rfc"+str(rfc_number)+".txt"))
81+
82+
if doc.in_ietf_process() and doc.ietf_process.has_iesg_ballot():
83+
ballot = doc.ietf_process.iesg_ballot()
84+
else:
85+
ballot = None
86+
87+
history = _get_history(doc)
7688

7789
return render_to_response('idrfc/doc_main_rfc.html',
7890
{'content1':content1, 'content2':content2,
79-
'doc':doc, 'info':info},
91+
'doc':doc, 'info':info, 'ballot':ballot,
92+
'history':history},
8093
context_instance=RequestContext(request));
8194

8295
def document_main(request, name):
@@ -108,53 +121,71 @@ def document_main(request, name):
108121
info['type'] = "Old Internet-Draft"+stream
109122

110123
info['has_pdf'] = (".pdf" in doc.file_types())
124+
info['is_rfc'] = False
111125

112-
content1 = None
113-
content2 = None
114-
if info['is_active_draft']:
115-
f = None
116-
try:
117-
try:
118-
f = open(settings.INTERNET_DRAFT_PATH+name+"-"+id.revision+".txt")
119-
content = f.read()
120-
(content1, content2) = markup_txt.markup(content)
121-
except IOError:
122-
content1 = "Error - can't find "+name+"-"+id.revision+".txt"
123-
content2 = ""
124-
finally:
125-
if f:
126-
f.close()
126+
(content1, content2) = _get_html(
127+
str(name)+","+str(id.revision)+",html",
128+
os.path.join(settings.INTERNET_DRAFT_PATH, name+"-"+id.revision+".txt"))
129+
130+
if doc.in_ietf_process() and doc.ietf_process.has_iesg_ballot():
131+
ballot = doc.ietf_process.iesg_ballot()
132+
else:
133+
ballot = None
134+
135+
versions = _get_versions(id)
136+
history = _get_history(doc)
127137

128138
return render_to_response('idrfc/doc_main_id.html',
129139
{'content1':content1, 'content2':content2,
130-
'doc':doc, 'info':info},
140+
'doc':doc, 'info':info, 'ballot':ballot,
141+
'versions':versions, 'history':history},
131142
context_instance=RequestContext(request));
132143

133-
def document_comments(request, name):
134-
r = re.compile("^rfc([0-9]+)$")
135-
m = r.match(name)
136-
if m:
137-
id = get_object_or_404(IDInternal, rfc_flag=1, draft=int(m.group(1)))
138-
else:
139-
id = get_object_or_404(IDInternal, rfc_flag=0, draft__filename=name)
144+
# doc is either IdWrapper or RfcWrapper
145+
def _get_history(doc):
140146
results = []
141-
commentNumber = 0
142-
for comment in id.public_comments():
143-
info = {}
144-
r = re.compile(r'^(.*) by (?:<b>)?([A-Z]\w+ [A-Z]\w+)(?:</b>)?$')
145-
m = r.match(comment.comment_text)
146-
if m:
147-
info['text'] = m.group(1)
148-
info['by'] = m.group(2)
149-
else:
147+
if doc._idinternal:
148+
for comment in doc._idinternal.public_comments():
149+
info = {}
150150
info['text'] = comment.comment_text
151151
info['by'] = comment.get_fullname()
152-
info['textSnippet'] = truncatewords_html(format_textarea(fill(info['text'], 80)), 25)
153-
info['snipped'] = info['textSnippet'][-3:] == "..."
154-
info['commentNumber'] = commentNumber
155-
commentNumber = commentNumber + 1
156-
results.append({'comment':comment, 'info':info})
157-
return render_to_response('idrfc/doc_comments.html', {'comments':results}, context_instance=RequestContext(request))
152+
info['textSnippet'] = truncatewords_html(format_textarea(fill(info['text'], 80)), 25)
153+
info['snipped'] = info['textSnippet'][-3:] == "..."
154+
results.append({'comment':comment, 'info':info, 'date':comment.datetime(), 'is_com':True})
155+
if doc.is_id_wrapper:
156+
versions = _get_versions(doc._draft, False)
157+
versions.reverse()
158+
for v in versions:
159+
v['is_rev'] = True
160+
results.append(v)
161+
if doc.is_id_wrapper and doc.draft_status == "Expired" and doc._draft.expiration_date:
162+
results.append({'is_text':True, 'date':doc._draft.expiration_date, 'text':'Draft expired'})
163+
if doc.is_rfc_wrapper:
164+
results.append({'is_text':True, 'date':doc.publication_date, 'text':'RFC Published'})
165+
166+
# convert plain dates to datetimes (required for sorting)
167+
for x in results:
168+
if not isinstance(x['date'], datetime):
169+
x['date'] = datetime.combine(x['date'], time(0,0,0))
170+
171+
results.sort(key=lambda x: x['date'])
172+
results.reverse()
173+
return results
174+
175+
# takes InternetDraft instance
176+
def _get_versions(draft, include_replaced=True):
177+
ov = []
178+
ov.append({"draft_name":draft.filename, "revision":draft.revision_display(), "date":draft.revision_date})
179+
if include_replaced:
180+
draft_list = [draft]+list(draft.replaces_set.all())
181+
else:
182+
draft_list = [draft]
183+
for d in draft_list:
184+
for v in DraftVersions.objects.filter(filename=d.filename).order_by('-revision'):
185+
if (d.filename == draft.filename) and (draft.revision_display() == v.revision):
186+
continue
187+
ov.append({"draft_name":d.filename, "revision":v.revision, "date":v.revision_date})
188+
return ov
158189

159190
def document_ballot(request, name):
160191
r = re.compile("^rfc([0-9]+)$")
@@ -172,15 +203,3 @@ def document_ballot(request, name):
172203
ballot = BallotWrapper(id)
173204
return render_to_response('idrfc/doc_ballot.html', {'ballot':ballot}, context_instance=RequestContext(request))
174205

175-
def document_versions(request, name):
176-
draft = get_object_or_404(InternetDraft, filename=name)
177-
ov = []
178-
ov.append({"draft_name":draft.filename, "revision":draft.revision, "revision_date":draft.revision_date})
179-
for d in [draft]+list(draft.replaces_set.all()):
180-
for v in DraftVersions.objects.filter(filename=d.filename).order_by('-revision'):
181-
if (d.filename == draft.filename) and (draft.revision == v.revision):
182-
continue
183-
ov.append({"draft_name":d.filename, "revision":v.revision, "revision_date":v.revision_date})
184-
185-
return render_to_response('idrfc/doc_versions.html', {'versions':ov}, context_instance=RequestContext(request))
186-
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% comment %}
2-
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
2+
Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
33
All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
44

55
Redistribution and use in source and binary forms, with or without
@@ -32,38 +32,37 @@
3232
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333
{% endcomment %}
3434

35-
<h2 style="margin-top:0;">Old versions and diffs</h2>
36-
3735
<div class="diffTool">
38-
<form action="http://tools.ietf.org/rfcdiff" method="get" target="_blank">
39-
36+
<h2 style="margin-top:0;margin-bottom:4px;">Diffs</h2>
37+
<form action="http://tools.ietf.org/rfcdiff" method="get" target="_blank" style="margin:0;">
38+
<table>
39+
<tr><td>
4040
<label>From:</label> <select name="url1">
4141
{% for id in versions %}
42-
<option value="{{id.draft_name}}-{{id.revision}}" {% ifequal forloop.counter 2 %} selected="selected" {% endifequal %}>{{id.draft_name}}-{{id.revision}} ({{id.revision_date}})</option>
42+
<option value="{{id.draft_name}}-{{id.revision}}" {% ifequal forloop.counter 2 %} selected="selected" {% endifequal %}>{{id.draft_name}}-{{id.revision}} ({{id.date}})</option>
4343
{% endfor %}
44-
</select><br/>
45-
<label>To</label>
44+
</select>
45+
</td>
46+
<td rowspan="2" valign="top">
47+
Format:
48+
<select name="difftype">
49+
<option value="--html" selected="selected">Side-by-side</option>
50+
<option value="--abdiff">Before-after</option>
51+
<option value="--chbars">Change bars</option>
52+
<option value="--hwdiff">Wdiff</option>
53+
</select> <input name="submit" value="Go!" type="submit" />
54+
</td>
55+
</tr>
56+
<tr>
57+
<td>
58+
<label>To:</label>
4659
<select name="url2">
4760
{% for id in versions %}
48-
<option value="{{id.draft_name}}-{{id.revision}}" {% ifequal forloop.counter 1 %} selected="selected" {% endifequal %}>{{id.draft_name}}-{{id.revision}} ({{id.revision_date}})</option>
61+
<option value="{{id.draft_name}}-{{id.revision}}" {% ifequal forloop.counter 1 %} selected="selected" {% endifequal %}>{{id.draft_name}}-{{id.revision}} ({{id.date}})</option>
4962
{% endfor %}
50-
</select><br/>
51-
52-
<label>Format:</label>
53-
54-
<input name="difftype" value="--html" checked="checked" type="radio">Side-by-side
55-
<input name="difftype" value="--abdiff" type="radio">Before-after
56-
<input name="difftype" value="--chbars" type="radio">Change bars
57-
<input name="difftype" value="--hwdiff" type="radio">Wdiff<br />
58-
59-
<input name="submit" value="Generate diff" type="submit" />
60-
63+
</select>
64+
</td>
65+
</tr>
66+
</table>
6167
</form>
6268
</div>
63-
64-
<table class="ietfTable">
65-
<tr><th>Date</th><th>Document</th></tr>
66-
{% for id in versions %}
67-
<tr><td>{{id.revision_date}}</td><td><a href="http://tools.ietf.org/id/{{id.draft_name}}-{{id.revision}}.txt">{{id.draft_name}}-{{id.revision}}.txt</a></td></tr>
68-
{% endfor %}
69-
</table>
Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% comment %}
2-
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
2+
Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
33
All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
44

55
Redistribution and use in source and binary forms, with or without
@@ -33,30 +33,44 @@
3333
{% endcomment %}
3434

3535
{% load ietf_filters %}
36-
37-
<h2 style="margin-top:0;">Document history</h2>
3836
<table class="ietfTable">
3937
<tr><th class="comment_date">Date</th><th class="comment_version">Version</th><th class="comment_by">By</th><th class="comment_text">Text</th></tr>
4038

41-
{% for c in comments %}
42-
39+
{% for c in history %}
4340
<tr class="{% cycle oddrow,evenrow %}">
44-
<td class="comment_date">{{ c.comment.date }}</td>
41+
<td class="comment_date">{{ c.date|date:"Y-m-d" }}</td>
42+
43+
{% if c.is_rev %}
44+
<td class="comment_version">{{ c.revision }}</td>
45+
<td class="comment_by">(System)</td>
46+
<td class="comment_text">New version available: <a href="http://tools.ietf.org/id/{{c.draft_name}}-{{c.revision}}.txt">{{c.draft_name}}-{{c.revision}}</a> {% ifnotequal c.revision "00" %}(<a href="http://tools.ietf.org/rfcdiff?url2={{c.draft_name}}-{{c.revision}}">diff from -{{c.revision|add:"-1"|stringformat:"02d"}}</a>){% endifnotequal %}</td>
47+
{% endif %}
48+
49+
{% if c.is_text %}
50+
<td class="comment_version">&nbsp;</td>
51+
<td class="comment_by">(System)</td>
52+
<td class="comment_text">{{ c.text }}</td>
53+
{% endif %}
54+
55+
{% if c.is_com %}
4556
<td class="comment_version">{{ c.comment.version }}</td>
4657
<td class="comment_by">{{ c.info.by|escape }}</td>
4758
<td class="comment_text">{% if c.comment.ballot %}
4859
[Ballot {{ c.comment.get_ballot_display }}]<br />
4960
{% endif %}
5061
{% if c.info.snipped %}
51-
<div class="commentSnippet" id="commentS{{c.info.commentNumber}}">{{ c.info.textSnippet|safe }}</div>
52-
<span class="commentToggle" onClick="toggleComment({{c.info.commentNumber}})" id="commentT{{c.info.commentNumber}}">[show all]</span>
53-
<div class="commentFull" id="commentF{{c.info.commentNumber}}" style="display:none;">
62+
<div class="commentSnippet" id="commentS{{forloop.counter}}">{{ c.info.textSnippet|safe }}</div>
63+
<span class="commentToggle" onclick="toggleComment({{forloop.counter}})" id="commentT{{forloop.counter}}">[show all]</span>
64+
<div class="commentFull" id="commentF{{forloop.counter}}" style="display:none;">
5465
{{c.info.text|fill:"80"|format_textarea|safe}}
5566
</div>
5667
{% else %}
5768
{{ c.info.text|fill:"80"|format_textarea|safe}}
5869
{% endif %}
5970
</td>
71+
{% endif %}
72+
73+
</tr>
6074
{% endfor %}
6175

62-
</table>
76+
</table>

0 commit comments

Comments
 (0)