Skip to content

Commit 5b43494

Browse files
committed
Merged in [18858] 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: 18872 Note: SVN reference [18858] has been migrated to Git commit 84a25ed
2 parents 4fe5a51 + 84a25ed commit 5b43494

4 files changed

Lines changed: 22 additions & 13 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/views_doc.py

Lines changed: 1 addition & 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,7 +207,7 @@ def document_main(request, name, rev=None):
210207

211208
latest_revision = None
212209

213-
if doc.get_state_slug() == "rfc":
210+
if not snapshot and doc.get_state_slug() == "rfc":
214211
# content
215212
content = doc.text_or_error() # pyflakes:ignore
216213
content = markup_txt.markup(maybe_split(content, split=split_content))

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

@@ -170,7 +174,7 @@
170174
</td>
171175
</tr>
172176

173-
{% if doc.get_state_slug != "rfc" %}
177+
{% if doc.get_state_slug != "rfc" and not snapshot %}
174178
<tr>
175179
<th></th>
176180
<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="{% url "ietf.doc.views_doc.document_main" name=doc.name %}{{ rev }}/" {% if rev != "00" and rev != latest_rev %}rel="nofollow"{% endif %} >{{ rev }}</a>
77
</li>
88
{% endfor %}
99
</ul>

0 commit comments

Comments
 (0)