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: restored where an rfc came from to the main rfc view #5930

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 3 additions & 6 deletions ietf/doc/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1490,11 +1490,9 @@ def test_draft_group_link(self):
self.assertEqual(r.status_code, 200)
self.assert_correct_wg_group_link(r, group)

rfc = WgRfcFactory(name='draft-rfc-document-%s' % group_type_id, group=group)
rfc = WgRfcFactory(group=group)
DocEventFactory.create(doc=rfc, type='published_rfc', time=event_datetime)
# get the rfc name to avoid a redirect
rfc_name = rfc.docalias.filter(name__startswith='rfc').first().name
r = self.client.get(urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=rfc_name)))
r = self.client.get(urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=rfc.name)))
self.assertEqual(r.status_code, 200)
self.assert_correct_wg_group_link(r, group)

Expand All @@ -1508,8 +1506,7 @@ def test_draft_group_link(self):
rfc = WgRfcFactory(name='draft-rfc-document-%s' % group_type_id, group=group)
DocEventFactory.create(doc=rfc, type='published_rfc', time=event_datetime)
# get the rfc name to avoid a redirect
rfc_name = rfc.docalias.filter(name__startswith='rfc').first().name
r = self.client.get(urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=rfc_name)))
r = self.client.get(urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=rfc.name)))
self.assertEqual(r.status_code, 200)
self.assert_correct_non_wg_group_link(r, group)

Expand Down
29 changes: 28 additions & 1 deletion ietf/doc/views_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,32 @@ def document_main(request, name, rev=None, document_html=False):
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()
# submission
submission = ""
if group is None:
submission = "unknown"
elif group.type_id == "individ":
submission = "individual"
elif group.type_id == "area" and doc.stream_id == "ietf":
submission = "individual in %s area" % group.acronym
else:
if group.features.acts_like_wg and not group.type_id == "edwg":
submission = "%s %s" % (group.acronym, group.type)
else:
submission = group.acronym
submission = '<a href="%s">%s</a>' % (group.about_url(), submission)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We ought to get in the habit of using mark_safe() / format_html() when we create safe strings instead of | safe in the templates.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair - this is copypasta (essentially) - the change would be good to apply in a comprehensive pass per view.

draft_alias = next(iter(doc.related_that("became_rfc")), None)
# Should be unreachable?
if (
draft_alias
and draft_alias.document.stream_id
and draft_alias.document.get_state_slug(
"draft-stream-%s" % draft_alias.document.stream_id
)
== "c-adopt"
):
submission = "candidate for %s" % submission


# todo replace document_html?
return render(request, "doc/document_rfc.html" if document_html is False else "doc/document_html.html",
Expand Down Expand Up @@ -367,7 +393,8 @@ def document_main(request, name, rev=None, document_html=False):
iana_experts_comment=iana_experts_comment,
search_archive=search_archive,
presentations=presentations,
diff_revisions=diff_revisions
diff_revisions=diff_revisions,
submission=submission
))

elif doc.type_id == "draft":
Expand Down