Skip to content

Commit

Permalink
Merged in [13109] from [email protected]:
Browse files Browse the repository at this point in the history
    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 e14dcda
  • Loading branch information
levkowetz committed Mar 26, 2017
2 parents 00d5ff8 + e14dcda commit 6aee4d4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
29 changes: 22 additions & 7 deletions ietf/doc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,19 +654,34 @@ def extract_complete_replaces_ancestor_mapping_for_docs(names):
return replaces


def crawl_history(doc):
def make_rev_history(doc):
# 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):
ancestors = []
if hasattr(doc, 'relateddocument_set'):
for rel in doc.relateddocument_set.filter(relationship__slug='replaces'):
if rel.target.document not in ancestors:
ancestors.append(rel.target.document)
ancestors.extend(get_ancestors(rel.target.document))
return ancestors
for alias in doc.related_that('replaces'):
if alias.document not in ancestors:
ancestors.append(alias.document)
ancestors.extend(get_ancestors(alias.document))
return ancestors

def get_replaces_tree(doc):
tree = get_predecessors(doc)
tree.extend(get_ancestors(doc))
return tree

history = {}
docs = get_ancestors(doc)
docs = get_replaces_tree(doc)
if docs is not None:
docs.append(doc)
for d in docs:
Expand Down
4 changes: 2 additions & 2 deletions ietf/doc/views_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
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,
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)
from ietf.community.utils import augment_docs_with_tracking_info
from ietf.group.models import Role
Expand Down Expand Up @@ -996,7 +996,7 @@ def extract_name(s):
data["ad"] = doc.ad.role_email("ad").formatted_email() if doc.ad else None

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":
data["iesg_state"] = extract_name(doc.get_state("draft-iesg"))
Expand Down

0 comments on commit 6aee4d4

Please sign in to comment.