Skip to content

Commit 6745653

Browse files
committed
Merged in [18858] and [18875] from kivinen@iki.fi:
Remove the automatic redirect from latest version to page without version number (also from tests), and made sure when viewing old snapshot which also happens to be last revision for draft where we have rfc, we show information from the draft, not from the rfc. Fixes issue ietf-tools#3162. - Legacy-Id: 18882 Note: SVN reference [18858] has been migrated to Git commit 84a25ed Note: SVN reference [18875] has been migrated to Git commit fedab94
2 parents 8a06980 + fedab94 commit 6745653

5 files changed

Lines changed: 37 additions & 15 deletions

File tree

ietf/doc/tests.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,13 +930,21 @@ def test_document_primary_and_history_views(self):
930930
doc.rev = "01"
931931
doc.save_with_history([DocEvent.objects.create(doc=doc, rev=doc.rev, type="changed_document", by=Person.objects.get(user__username="secretary"), desc="Test")])
932932

933+
# Fetch the main page resulting latest version
933934
r = self.client.get(urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=doc.name)))
934935
self.assertEqual(r.status_code, 200)
935936
self.assertContains(r, "%s-01"%docname)
936-
937+
938+
# Fetch 01 version even when it is last version
937939
r = self.client.get(urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=doc.name,rev="01")))
940+
self.assertEqual(r.status_code, 200)
941+
self.assertContains(r, "%s-01"%docname)
942+
943+
# Fetch version number which is too large, that should redirect to main page
944+
r = self.client.get(urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=doc.name,rev="02")))
938945
self.assertEqual(r.status_code, 302)
939-
946+
947+
# Fetch 00 version which should result that version
940948
r = self.client.get(urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=doc.name,rev="00")))
941949
self.assertEqual(r.status_code, 200)
942950
self.assertContains(r, "%s-00"%docname)

ietf/doc/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ def join_justified(left, right, width=72):
935935
return lines
936936

937937
def build_file_urls(doc):
938-
if doc.get_state_slug() == "rfc":
938+
if isinstance(doc,Document) and doc.get_state_slug() == "rfc":
939939
name = doc.canonical_name()
940940
base_path = os.path.join(settings.RFC_PATH, name + ".")
941941
possible_types = settings.RFC_FILE_TYPES
@@ -952,7 +952,8 @@ def build_file_urls(doc):
952952
file_urls.append(("pdf", base + "pdfrfc/" + name + ".txt.pdf"))
953953

954954
if "txt" in found_types:
955-
file_urls.append(("htmlized", settings.TOOLS_ID_HTML_URL + name))
955+
file_urls.append(("htmlized (tools)", settings.TOOLS_ID_HTML_URL + name))
956+
file_urls.append(("htmlized", urlreverse('ietf.doc.views_doc.document_html', kwargs=dict(name=name))))
956957
if doc.tags.filter(slug="verified-errata").exists():
957958
file_urls.append(("with errata", settings.RFC_EDITOR_INLINE_ERRATA_URL.format(rfc_number=doc.rfc_number())))
958959
file_urls.append(("bibtex", urlreverse('ietf.doc.views_doc.document_main',kwargs=dict(name=name))+"bibtex"))

ietf/doc/views_doc.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,6 @@ def document_main(request, name, rev=None):
139139

140140
gh = None
141141
if rev != None:
142-
if rev == doc.rev:
143-
return redirect('ietf.doc.views_doc.document_main', name=name)
144-
145142
# find the entry in the history
146143
for h in doc.history_set.order_by("-time"):
147144
if rev == h.rev:
@@ -210,12 +207,24 @@ def document_main(request, name, rev=None):
210207

211208
latest_revision = None
212209

210+
# Workaround to allow displaying last rev of draft that became rfc as a draft
211+
# This should be unwound when RFCs become their own documents.
212+
if snapshot:
213+
doc.name = doc.doc.name
214+
name = doc.doc.name
215+
else:
216+
name = doc.name
217+
213218
file_urls, found_types = build_file_urls(doc)
219+
if not snapshot and doc.get_state_slug() == "rfc":
220+
# content
221+
content = doc.text_or_error() # pyflakes:ignore
222+
content = markup_txt.markup(maybe_split(content, split=split_content))
214223

215224
content = doc.text_or_error() # pyflakes:ignore
216225
content = markup_txt.markup(maybe_split(content, split=split_content))
217226

218-
if doc.get_state_slug() == "rfc":
227+
if not snapshot and doc.get_state_slug() == "rfc":
219228
if not found_types:
220229
content = "This RFC is not currently available online."
221230
split_content = False

ietf/templates/doc/document_draft.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
{% block pagehead %}
99
<link rel="alternate" type="application/atom+xml" title="Document changes" href="/feed/document-changes/{{ name }}/">
10-
<meta name="description" content="{{ doc.title }} {% if doc.get_state_slug == "rfc" %}(RFC {{ rfc_number }}{% if published %}, {{ published.time|date:"F Y" }}{% endif %}{% if obsoleted_by %}; obsoleted by {{ obsoleted_by|join:", " }}{% endif %}){% else %}(Internet-Draft, {{ doc.time|date:"Y" }}){% endif %}">
10+
<meta name="description" content="{{ doc.title }} {% if doc.get_state_slug == "rfc" and not snapshot %}(RFC {{ rfc_number }}{% if published %}, {{ published.time|date:"F Y" }}{% endif %}{% if obsoleted_by %}; obsoleted by {{ obsoleted_by|join:", " }}{% endif %}){% else %}(Internet-Draft, {{ doc.time|date:"Y" }}){% endif %}">
1111
<script src="{% static 'd3/d3.min.js' %}"></script>
1212
<script src="{% static 'jquery/jquery.min.js' %}"></script>
1313
<script src="{% static 'ietf/js/document_timeline.js' %}"></script>
@@ -18,7 +18,7 @@
1818
{% endblock %}
1919

2020
{% block title %}
21-
{% if doc.get_state_slug == "rfc" %}
21+
{% if doc.get_state_slug == "rfc" and not snapshot %}
2222
RFC {{ rfc_number }} - {{ doc.title }}
2323
{% else %}
2424
{{ name }}-{{ doc.rev }} - {{ doc.title }}
@@ -38,7 +38,11 @@
3838
{% if doc.rev != latest_rev %}
3939
<th colspan="4" class="alert-warning">The information below is for an old version of the document</th>
4040
{% else %}
41-
<th colspan="4"></th>
41+
{% if doc.get_state_slug == "rfc" and snapshot %}
42+
<th colspan="4" class="alert-warning">The information below is for an old version of the document that is already published as an RFC</th>
43+
{% else %}
44+
<th colspan="4"></th>
45+
{% endif %}
4246
{% endif %}
4347
</tr>
4448
</thead>
@@ -49,7 +53,7 @@
4953
<th>Type</th>
5054
<td class="edit"></td>
5155
<td>
52-
{% if doc.get_state_slug == "rfc" %}
56+
{% if doc.get_state_slug == "rfc" and not snapshot %}
5357
RFC - {{ doc.std_level }}
5458
({% if published %}{{ published.time|date:"F Y" }}{% else %}publication date unknown{% endif %}{% if has_errata %}; <a href="https://www.rfc-editor.org/errata_search.php?rfc={{ rfc_number }}" rel="nofollow">Errata</a>{% else %}; No errata{% endif %})
5559

@@ -171,7 +175,7 @@
171175
</td>
172176
</tr>
173177

174-
{% if doc.get_state_slug != "rfc" %}
178+
{% if doc.get_state_slug != "rfc" and not snapshot %}
175179
<tr>
176180
<th></th>
177181
<th>Intended RFC status</th>

ietf/templates/doc/revisions_list.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<ul class="pagination revlist">
33
<li class="disabled"><a><b>Versions</b></a></li>
44
{% for rev in revisions %}
5-
<li {% if rev == doc.rev %}{% if rev == latest_rev %}class="active"{% else %}class="warning"{% endif %}{% endif %}>
6-
<a href="{% url "ietf.doc.views_doc.document_main" name=doc.name %}{% if not forloop.last %}{{ rev }}/{% endif %}" {% if rev != "00" and rev != latest_rev %}rel="nofollow"{% endif %} >{{ rev }}</a>
5+
<li {% if rev == doc.rev %}{% if snapshot or not doc.get_state_slug == "rfc" %}{% if rev == latest_rev and not doc.get_state_slug == "rfc" %}class="active"{% else %}class="warning"{% endif %}{% endif %}{% endif %}>
6+
<a href="{% if snapshot and doc.get_state_slug == "rfc" %}{% url "ietf.doc.views_doc.document_main" name=doc.doc.name %}{% else %}{% url "ietf.doc.views_doc.document_main" name=doc.name %}{% endif %}{{ rev }}/" {% if rev != "00" and rev != latest_rev %}rel="nofollow"{% endif %} >{{ rev }}</a>
77
</li>
88
{% endfor %}
99
</ul>

0 commit comments

Comments
 (0)