Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show htmlized views of draft revisions without DocHistory #5599

Merged
merged 2 commits into from
May 11, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions ietf/doc/views_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,13 +487,25 @@ def document_main(request, name, rev=None, document_html=False):
html = None
js = None
css = None
diff_revisions = None
simple_diff_revisions = None
if document_html:
html = doc.html_body()
if request.COOKIES.get("pagedeps") == "inline":
js = Path(finders.find("ietf/js/document_html.js")).read_text()
css = Path(finders.find("ietf/css/document_html_inline.css")).read_text()
if html:
css += Path(finders.find("ietf/css/document_html_txt.css")).read_text()
diff_revisions=get_diff_revisions(request, name, doc if isinstance(doc,Document) else doc.doc)
simple_diff_revisions = [t[1] for t in diff_revisions]
simple_diff_revisions.reverse()
if rev != doc.rev:
# No DocHistory was found matching rev - snapshot will be false
# and doc will be a Document object, not a DocHistory
snapshot = True
doc = doc.fake_history_obj(rev)
else:
html = doc.html_body()
if request.COOKIES.get("pagedeps") == "inline":
js = Path(finders.find("ietf/js/document_html.js")).read_text()
css = Path(finders.find("ietf/css/document_html_inline.css")).read_text()
if html:
css += Path(finders.find("ietf/css/document_html_txt.css")).read_text()

return render(request, "doc/document_draft.html" if document_html is False else "doc/document_html.html",
dict(doc=doc,
document_html=document_html,
Expand All @@ -505,7 +517,7 @@ def document_main(request, name, rev=None, document_html=False):
name=name,
content=content,
split_content=split_content,
revisions=revisions,
revisions=simple_diff_revisions if document_html else revisions,
snapshot=snapshot,
stream_desc=stream_desc,
latest_revision=latest_revision,
Expand Down Expand Up @@ -544,7 +556,7 @@ def document_main(request, name, rev=None, document_html=False):
status_changes=status_changes,
proposed_status_changes=proposed_status_changes,
rfc_aliases=rfc_aliases,
has_errata=doc.tags.filter(slug="errata"),
has_errata=doc.pk and doc.tags.filter(slug="errata"), # doc.pk == None if using a fake_history_obj
published=published,
file_urls=file_urls,
additional_urls=additional_urls,
Expand All @@ -569,7 +581,7 @@ def document_main(request, name, rev=None, document_html=False):
review_assignments=review_assignments,
no_review_from_teams=no_review_from_teams,
due_date=due_date,
diff_revisions=get_diff_revisions(request, name, doc if isinstance(doc,Document) else doc.doc) if document_html else None
diff_revisions=diff_revisions
))

if doc.type_id == "charter":
Expand Down