From c492f3ed5c0d8a1519b94fb2ceb74c3ea73264c4 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Sat, 4 Nov 2023 14:16:32 +0100 Subject: [PATCH 1/9] feat: Add disclaimer banners for unadopted I-Ds and non-IETF RFCs Fixes #6539 --- ietf/doc/templatetags/ietf_filters.py | 26 ++++++++++++++++++++++++++ ietf/templates/doc/disclaimer.html | 21 +++++++++++++++++++++ ietf/templates/doc/document_draft.html | 1 + ietf/templates/doc/document_info.html | 7 +++++-- 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 ietf/templates/doc/disclaimer.html diff --git a/ietf/doc/templatetags/ietf_filters.py b/ietf/doc/templatetags/ietf_filters.py index 9b4700bfb1..2a06ee11d6 100644 --- a/ietf/doc/templatetags/ietf_filters.py +++ b/ietf/doc/templatetags/ietf_filters.py @@ -876,3 +876,29 @@ def badgeify(blob): ) return text + + +@register.filter +def is_in_stream(doc): + """ + Check if the doc is in one of the states in it stream that + indicate that is actually adopted, i.e., part of the stream. + (There are various "candidate" states that necessitate this + filter.) + """ + if not doc.stream: + return False + stream = doc.stream.slug + state = doc.get_state_slug(f"draft-stream-{doc.stream.slug}") + if not state: + return False + + if stream == "ietf": + return state not in ["wg-cand", "c-adopt"] + elif stream == "irtf": + return state != "candidat" + elif stream == "iab": + return state not in ["candidat", "diff-org"] + elif stream == "editorial": + return True + return False diff --git a/ietf/templates/doc/disclaimer.html b/ietf/templates/doc/disclaimer.html new file mode 100644 index 0000000000..3471e28817 --- /dev/null +++ b/ietf/templates/doc/disclaimer.html @@ -0,0 +1,21 @@ +{# Copyright The IETF Trust 2016-2023, All Rights Reserved #} +{% load origin %} +{% load ietf_filters %} +{% origin %} +{% if doc.get_state_slug == "rfc"%} + {% if doc.stream.slug != "ietf" and doc.std_level.slug in "exp,inf"|split:","%} + + {% endif %} +{% elif not doc|is_in_stream %} + +{% endif %} \ No newline at end of file diff --git a/ietf/templates/doc/document_draft.html b/ietf/templates/doc/document_draft.html index 09cab69208..87626ce640 100644 --- a/ietf/templates/doc/document_draft.html +++ b/ietf/templates/doc/document_draft.html @@ -27,6 +27,7 @@ {% origin %} {{ top|safe }} {% include "doc/revisions_list.html" with document_html=document_html %} + {% include "doc/disclaimer.html" with document_html=document_html %}
{% if doc.rev != latest_rev %}
The information below is for an old version of the document.
diff --git a/ietf/templates/doc/document_info.html b/ietf/templates/doc/document_info.html index b2265c254a..2190c3c8cd 100644 --- a/ietf/templates/doc/document_info.html +++ b/ietf/templates/doc/document_info.html @@ -62,9 +62,9 @@ {% endif %} {% else %} {% if snapshot and doc.doc.get_state_slug == 'rfc' %} - This is an older version of an Internet-Draft that was ultimately published as {{doc.doc.canonical_name|prettystdname}}. + This is an older version of an Internet-Draft that was ultimately published as {{doc.doc.canonical_name|prettystdname}}. {% elif snapshot and doc.rev != latest_rev %} - This is an older version of an Internet-Draft whose latest revision state is "{{ doc.doc.get_state }}". + This is an older version of an Internet-Draft whose latest revision state is "{{ doc.doc.get_state }}". {% else %} {% if snapshot and doc.rev == latest_rev %}{{ doc.doc.get_state }}{% else %}{{ doc.get_state }}{% endif %} Internet-Draft {% if submission %}({{ submission|safe }}){% endif %} @@ -76,6 +76,9 @@ Expired & archived {% endif %} + {% if document_html %} + {% include "doc/disclaimer.html" with document_html=document_html %} + {% endif %} {% if document_html %} From 3c4c0697a01691ef22f8b9e4306190bd6591a6b0 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Wed, 13 Dec 2023 15:34:42 +0200 Subject: [PATCH 2/9] Fixes --- ietf/doc/templatetags/ietf_filters.py | 3 +-- ietf/templates/doc/disclaimer.html | 16 ++++++++++++---- ietf/templates/doc/document_rfc.html | 3 ++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ietf/doc/templatetags/ietf_filters.py b/ietf/doc/templatetags/ietf_filters.py index 7154ff87e2..053aaf0f69 100644 --- a/ietf/doc/templatetags/ietf_filters.py +++ b/ietf/doc/templatetags/ietf_filters.py @@ -892,8 +892,7 @@ def is_in_stream(doc): stream = doc.stream.slug state = doc.get_state_slug(f"draft-stream-{doc.stream.slug}") if not state: - return False - + return True if stream == "ietf": return state not in ["wg-cand", "c-adopt"] elif stream == "irtf": diff --git a/ietf/templates/doc/disclaimer.html b/ietf/templates/doc/disclaimer.html index 3471e28817..ed25b4d923 100644 --- a/ietf/templates/doc/disclaimer.html +++ b/ietf/templates/doc/disclaimer.html @@ -2,15 +2,23 @@ {% load origin %} {% load ietf_filters %} {% origin %} -{% if doc.get_state_slug == "rfc"%} - {% if doc.stream.slug != "ietf" and doc.std_level.slug in "exp,inf"|split:","%} +{% if doc.type_id == "rfc"%} + {% if doc.stream.slug != "ietf" and not doc.std_level or doc.std_level.slug in "exp,inf"|split:","%} {% endif %} -{% elif not doc|is_in_stream %} +{% elif doc|is_in_stream %} + {% if doc.stream.slug != "ietf" and not doc.std_level or doc.std_level.slug in "exp,inf"|split:","%} + + {% endif %} +{% else %}