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 #3162.
 - Legacy-Id: 18882
Note: SVN reference [18858] has been migrated to Git commit 84a25ed491

Note: SVN reference [18875] has been migrated to Git commit fedab94d3d
This commit is contained in:
Robert Sparks 2021-03-03 17:11:13 +00:00
commit 67456530e4
5 changed files with 37 additions and 15 deletions

View file

@ -930,13 +930,21 @@ Man Expires September 22, 2015 [Page 3]
doc.rev = "01"
doc.save_with_history([DocEvent.objects.create(doc=doc, rev=doc.rev, type="changed_document", by=Person.objects.get(user__username="secretary"), desc="Test")])
# Fetch the main page resulting latest version
r = self.client.get(urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=doc.name)))
self.assertEqual(r.status_code, 200)
self.assertContains(r, "%s-01"%docname)
# Fetch 01 version even when it is last version
r = self.client.get(urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=doc.name,rev="01")))
self.assertEqual(r.status_code, 200)
self.assertContains(r, "%s-01"%docname)
# Fetch version number which is too large, that should redirect to main page
r = self.client.get(urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=doc.name,rev="02")))
self.assertEqual(r.status_code, 302)
# Fetch 00 version which should result that version
r = self.client.get(urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=doc.name,rev="00")))
self.assertEqual(r.status_code, 200)
self.assertContains(r, "%s-00"%docname)

View file

@ -935,7 +935,7 @@ def join_justified(left, right, width=72):
return lines
def build_file_urls(doc):
if doc.get_state_slug() == "rfc":
if isinstance(doc,Document) and doc.get_state_slug() == "rfc":
name = doc.canonical_name()
base_path = os.path.join(settings.RFC_PATH, name + ".")
possible_types = settings.RFC_FILE_TYPES
@ -952,7 +952,8 @@ def build_file_urls(doc):
file_urls.append(("pdf", base + "pdfrfc/" + name + ".txt.pdf"))
if "txt" in found_types:
file_urls.append(("htmlized", settings.TOOLS_ID_HTML_URL + name))
file_urls.append(("htmlized (tools)", settings.TOOLS_ID_HTML_URL + name))
file_urls.append(("htmlized", urlreverse('ietf.doc.views_doc.document_html', kwargs=dict(name=name))))
if doc.tags.filter(slug="verified-errata").exists():
file_urls.append(("with errata", settings.RFC_EDITOR_INLINE_ERRATA_URL.format(rfc_number=doc.rfc_number())))
file_urls.append(("bibtex", urlreverse('ietf.doc.views_doc.document_main',kwargs=dict(name=name))+"bibtex"))

View file

@ -139,9 +139,6 @@ def document_main(request, name, rev=None):
gh = None
if rev != None:
if rev == doc.rev:
return redirect('ietf.doc.views_doc.document_main', name=name)
# find the entry in the history
for h in doc.history_set.order_by("-time"):
if rev == h.rev:
@ -210,12 +207,24 @@ def document_main(request, name, rev=None):
latest_revision = None
# Workaround to allow displaying last rev of draft that became rfc as a draft
# This should be unwound when RFCs become their own documents.
if snapshot:
doc.name = doc.doc.name
name = doc.doc.name
else:
name = doc.name
file_urls, found_types = build_file_urls(doc)
if not snapshot and doc.get_state_slug() == "rfc":
# content
content = doc.text_or_error() # pyflakes:ignore
content = markup_txt.markup(maybe_split(content, split=split_content))
content = doc.text_or_error() # pyflakes:ignore
content = markup_txt.markup(maybe_split(content, split=split_content))
if doc.get_state_slug() == "rfc":
if not snapshot and doc.get_state_slug() == "rfc":
if not found_types:
content = "This RFC is not currently available online."
split_content = False

View file

@ -7,7 +7,7 @@
{% block pagehead %}
<link rel="alternate" type="application/atom+xml" title="Document changes" href="/feed/document-changes/{{ name }}/">
<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 %}">
<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 %}">
<script src="{% static 'd3/d3.min.js' %}"></script>
<script src="{% static 'jquery/jquery.min.js' %}"></script>
<script src="{% static 'ietf/js/document_timeline.js' %}"></script>
@ -18,7 +18,7 @@
{% endblock %}
{% block title %}
{% if doc.get_state_slug == "rfc" %}
{% if doc.get_state_slug == "rfc" and not snapshot %}
RFC {{ rfc_number }} - {{ doc.title }}
{% else %}
{{ name }}-{{ doc.rev }} - {{ doc.title }}
@ -38,7 +38,11 @@
{% if doc.rev != latest_rev %}
<th colspan="4" class="alert-warning">The information below is for an old version of the document</th>
{% else %}
<th colspan="4"></th>
{% if doc.get_state_slug == "rfc" and snapshot %}
<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>
{% else %}
<th colspan="4"></th>
{% endif %}
{% endif %}
</tr>
</thead>
@ -49,7 +53,7 @@
<th>Type</th>
<td class="edit"></td>
<td>
{% if doc.get_state_slug == "rfc" %}
{% if doc.get_state_slug == "rfc" and not snapshot %}
RFC - {{ doc.std_level }}
({% 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 %})
@ -171,7 +175,7 @@
</td>
</tr>
{% if doc.get_state_slug != "rfc" %}
{% if doc.get_state_slug != "rfc" and not snapshot %}
<tr>
<th></th>
<th>Intended RFC status</th>

View file

@ -2,8 +2,8 @@
<ul class="pagination revlist">
<li class="disabled"><a><b>Versions</b></a></li>
{% for rev in revisions %}
<li {% if rev == doc.rev %}{% if rev == latest_rev %}class="active"{% else %}class="warning"{% endif %}{% endif %}>
<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>
<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 %}>
<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>
</li>
{% endfor %}
</ul>