Merged in [13109] from lars@netapp.com:
Rename crawl_history to make_rev_history, which is more descriptive. Fix #2224
(thanks, Robert!) by generating graphs for the entire revision history of a doc,
both forward and backward in time.
- Legacy-Id: 13140
Note: SVN reference [13109] has been migrated to Git commit e14dcdac8f
This commit is contained in:
commit
6aee4d4a16
|
@ -654,19 +654,34 @@ def extract_complete_replaces_ancestor_mapping_for_docs(names):
|
||||||
return replaces
|
return replaces
|
||||||
|
|
||||||
|
|
||||||
def crawl_history(doc):
|
def make_rev_history(doc):
|
||||||
# return document history data for inclusion in doc.json (used by timeline)
|
# return document history data for inclusion in doc.json (used by timeline)
|
||||||
|
|
||||||
|
def get_predecessors(doc):
|
||||||
|
predecessors = []
|
||||||
|
if hasattr(doc, 'relateddocument_set'):
|
||||||
|
for alias in doc.related_that_doc('replaces'):
|
||||||
|
if alias.document not in predecessors:
|
||||||
|
predecessors.append(alias.document)
|
||||||
|
predecessors.extend(get_predecessors(alias.document))
|
||||||
|
return predecessors
|
||||||
|
|
||||||
def get_ancestors(doc):
|
def get_ancestors(doc):
|
||||||
ancestors = []
|
ancestors = []
|
||||||
if hasattr(doc, 'relateddocument_set'):
|
if hasattr(doc, 'relateddocument_set'):
|
||||||
for rel in doc.relateddocument_set.filter(relationship__slug='replaces'):
|
for alias in doc.related_that('replaces'):
|
||||||
if rel.target.document not in ancestors:
|
if alias.document not in ancestors:
|
||||||
ancestors.append(rel.target.document)
|
ancestors.append(alias.document)
|
||||||
ancestors.extend(get_ancestors(rel.target.document))
|
ancestors.extend(get_ancestors(alias.document))
|
||||||
return ancestors
|
return ancestors
|
||||||
|
|
||||||
|
def get_replaces_tree(doc):
|
||||||
|
tree = get_predecessors(doc)
|
||||||
|
tree.extend(get_ancestors(doc))
|
||||||
|
return tree
|
||||||
|
|
||||||
history = {}
|
history = {}
|
||||||
docs = get_ancestors(doc)
|
docs = get_replaces_tree(doc)
|
||||||
if docs is not None:
|
if docs is not None:
|
||||||
docs.append(doc)
|
docs.append(doc)
|
||||||
for d in docs:
|
for d in docs:
|
||||||
|
|
|
@ -49,7 +49,7 @@ from ietf.doc.models import ( Document, DocAlias, DocHistory, DocEvent, BallotDo
|
||||||
from ietf.doc.utils import ( add_links_in_new_revision_events, augment_events_with_revision,
|
from ietf.doc.utils import ( add_links_in_new_revision_events, augment_events_with_revision,
|
||||||
can_adopt_draft, get_chartering_type, get_document_content, get_tags_for_stream_id,
|
can_adopt_draft, get_chartering_type, get_document_content, get_tags_for_stream_id,
|
||||||
needed_ballot_positions, nice_consensus, prettify_std_name, update_telechat, has_same_ballot,
|
needed_ballot_positions, nice_consensus, prettify_std_name, update_telechat, has_same_ballot,
|
||||||
get_initial_notify, make_notify_changed_event, crawl_history, default_consensus,
|
get_initial_notify, make_notify_changed_event, make_rev_history, default_consensus,
|
||||||
add_events_message_info, get_unicode_document_content, build_doc_meta_block)
|
add_events_message_info, get_unicode_document_content, build_doc_meta_block)
|
||||||
from ietf.community.utils import augment_docs_with_tracking_info
|
from ietf.community.utils import augment_docs_with_tracking_info
|
||||||
from ietf.group.models import Role
|
from ietf.group.models import Role
|
||||||
|
@ -996,7 +996,7 @@ def document_json(request, name, rev=None):
|
||||||
data["ad"] = doc.ad.role_email("ad").formatted_email() if doc.ad else None
|
data["ad"] = doc.ad.role_email("ad").formatted_email() if doc.ad else None
|
||||||
|
|
||||||
latest_revision = doc.latest_event(NewRevisionDocEvent, type="new_revision")
|
latest_revision = doc.latest_event(NewRevisionDocEvent, type="new_revision")
|
||||||
data["rev_history"] = crawl_history(latest_revision.doc if latest_revision else doc)
|
data["rev_history"] = make_rev_history(latest_revision.doc if latest_revision else doc)
|
||||||
|
|
||||||
if doc.type_id == "draft":
|
if doc.type_id == "draft":
|
||||||
data["iesg_state"] = extract_name(doc.get_state("draft-iesg"))
|
data["iesg_state"] = extract_name(doc.get_state("draft-iesg"))
|
||||||
|
|
Loading…
Reference in a new issue