fix: repairs to the timeline graphic

This commit is contained in:
Robert Sparks 2023-09-12 09:23:01 -05:00
parent 5bbea70cb0
commit 0c85c4169d
No known key found for this signature in database
GPG key ID: 6E2A6A5775F91318
4 changed files with 13 additions and 6 deletions

View file

@ -936,6 +936,8 @@ def make_rev_history(doc):
if document not in predecessors:
predecessors.append(document)
predecessors.extend(get_predecessors(document, predecessors))
if doc.came_from_draft():
predecessors.append(doc.came_from_draft())
return predecessors
def get_ancestors(doc, ancestors = None):
@ -946,6 +948,8 @@ def make_rev_history(doc):
if document not in ancestors:
ancestors.append(document)
ancestors.extend(get_ancestors(document, ancestors))
if doc.became_rfc():
ancestors.append(doc.became_rfc())
return ancestors
def get_replaces_tree(doc):
@ -971,6 +975,9 @@ def make_rev_history(doc):
history[url]['pages'] = d.history_set.filter(rev=e.newrevisiondocevent.rev).first().pages
if doc.type_id == "draft":
# Do nothing - all draft revisions are captured above already.
e = None
elif doc.type_id == "rfc":
# e.time.date() agrees with RPC publication date when shown in the RPC_TZINFO time zone
e = doc.latest_event(type='published_rfc')
else:
@ -983,7 +990,7 @@ def make_rev_history(doc):
'published': e.time.isoformat(),
'url': url
}
if hasattr(e, 'newrevisiondocevent') and doc.history_set.filter(rev=e.newrevisiondocevent.rev).exists():
if doc.type_id != "rfc" and hasattr(e, 'newrevisiondocevent') and doc.history_set.filter(rev=e.newrevisiondocevent.rev).exists():
history[url]['pages'] = doc.history_set.filter(rev=e.newrevisiondocevent.rev).first().pages
history = list(history.values())
return sorted(history, key=lambda x: x['published'])

View file

@ -1649,8 +1649,6 @@ def document_json(request, name, rev=None):
data["expires"] = doc.expires.strftime("%Y-%m-%d %H:%M:%S") if doc.expires else None
data["title"] = doc.title
data["abstract"] = doc.abstract
# Preserve aliases in this api? What about showing rfc_number directly?
data["aliases"] = list(doc.name)
data["state"] = extract_name(doc.get_state())
data["intended_std_level"] = extract_name(doc.intended_std_level)
data["std_level"] = extract_name(doc.std_level)
@ -1666,7 +1664,7 @@ def document_json(request, name, rev=None):
latest_revision = doc.latest_event(NewRevisionDocEvent, type="new_revision")
data["rev_history"] = make_rev_history(latest_revision.doc if latest_revision else doc)
if doc.type_id == "draft":
if doc.type_id == "draft": # These live only on drafts
data["iesg_state"] = extract_name(doc.get_state("draft-iesg"))
data["rfceditor_state"] = extract_name(doc.get_state("draft-rfceditor"))
data["iana_review_state"] = extract_name(doc.get_state("draft-iana-review"))
@ -1675,6 +1673,8 @@ def document_json(request, name, rev=None):
if doc.stream_id in ("ietf", "irtf", "iab"):
e = doc.latest_event(ConsensusDocEvent, type="changed_consensus")
data["consensus"] = e.consensus if e else None
if doc.type_id in ["draft", "rfc"]:
data["stream"] = extract_name(doc.stream)
return HttpResponse(json.dumps(data, indent=2), content_type='application/json')

View file

@ -22,7 +22,7 @@
{% block content %}
{% origin %}
{{ top|safe }}
<div id="timeline"></div>
<div id="doc-timeline"></div>
<table class="table table-sm table-borderless">
{% include "doc/document_info.html" %}
<tbody class="meta border-top">

View file

@ -9,7 +9,7 @@
{% origin %}
{{ top|safe }}
{% include "doc/revisions_list.html" %}
<div id="timeline"></div>
<div id="doc-timeline"></div>
{% if doc.rev != latest_rev %}
<div class="alert alert-warning my-3">The information below is for an older version of this statement.</div>
{% endif %}