From d0bac8913db69bff21fc8884e069cee043bf5394 Mon Sep 17 00:00:00 2001
From: Robert Sparks <rjsparks@nostrum.com>
Date: Tue, 5 Sep 2023 18:04:16 -0500
Subject: [PATCH] fix: use type instead of state in templates

---
 ietf/templates/doc/document_conflict_review.html |  2 +-
 ietf/templates/doc/document_draft.html           | 10 +++++-----
 ietf/templates/doc/document_format_buttons.html  |  4 ++--
 ietf/templates/doc/document_history_form.html    |  2 +-
 ietf/templates/doc/document_html.html            |  6 +++---
 ietf/templates/doc/document_info.html            |  4 ++--
 ietf/templates/doc/document_rfc.html             |  6 +++---
 ietf/templates/doc/opengraph.html                |  2 +-
 ietf/templates/doc/revisions_list.html           |  4 ++--
 ietf/templates/doc/search/status_columns.html    |  2 +-
 10 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/ietf/templates/doc/document_conflict_review.html b/ietf/templates/doc/document_conflict_review.html
index 00300e780..8a2361832 100644
--- a/ietf/templates/doc/document_conflict_review.html
+++ b/ietf/templates/doc/document_conflict_review.html
@@ -28,7 +28,7 @@
                 <td class="edit"></td>
                 <td>
                     <a href="{% url "ietf.doc.views_doc.document_main" name=conflictdoc.name %}">
-                        {% if conflictdoc.get_state_slug == 'rfc' %}{{ conflictdoc.name|prettystdname }}{% else %}{{ conflictdoc.name }}-{{ conflictdoc.rev }}{% endif %}</a>
+                        {% if conflictdoc.type_id == 'rfc' %}{{ conflictdoc.name|prettystdname }}{% else %}{{ conflictdoc.name }}-{{ conflictdoc.rev }}{% endif %}</a>
                     <span class="badge rounded-pill text-bg-info">{{ conflictdoc.stream }} stream</span>
                     {% if snapshot %}<span class="badge rounded-pill text-bg-warning">Snapshot</span>{% endif %}
                 </td>
diff --git a/ietf/templates/doc/document_draft.html b/ietf/templates/doc/document_draft.html
index 15e3a8047..c099e1075 100644
--- a/ietf/templates/doc/document_draft.html
+++ b/ietf/templates/doc/document_draft.html
@@ -13,11 +13,11 @@
           title="Document changes"
           href="/feed/document-changes/{{ name }}/">
     <meta name="description"
-          content="{{ doc.title }} {% if doc.get_state_slug == 'rfc' and not snapshot %}(RFC {{ rfc_number }}{% if published %}, {{ doc.pub_date|date:'F Y' }}{% endif %}{% if obsoleted_by %}; obsoleted by {% for rel in obsoleted_by %}{{ rel.source.name|prettystdname}}{% if not forloop.last%}, {% endif %}{% endfor %}{% endif %}){% endif %}">
+          content="{{ doc.title }} {% if doc.type_id == 'rfc' and not snapshot %}(RFC {{ rfc_number }}{% if published %}, {{ doc.pub_date|date:'F Y' }}{% endif %}{% if obsoleted_by %}; obsoleted by {% for rel in obsoleted_by %}{{ rel.source.name|prettystdname}}{% if not forloop.last%}, {% endif %}{% endfor %}{% endif %}){% endif %}">
 {% endblock %}
 {% block morecss %}.inline { display: inline; }{% endblock %}
 {% block title %}
-    {% if doc.get_state_slug == "rfc" and not snapshot %}
+    {% if doc.type_id == "rfc" and not snapshot %}
         RFC {{ rfc_number }} - {{ doc.title }}
     {% else %}
         {{ name }}-{{ doc.rev }} - {{ doc.title }}
@@ -31,7 +31,7 @@
     {% if doc.rev != latest_rev %}
         <div class="alert alert-warning my-3">The information below is for an old version of the document.</div>
     {% else %}
-        {% if doc.get_state_slug == "rfc" and snapshot %}
+        {% if doc.type_id == "rfc" and snapshot %}
             <div class="alert alert-warning my-3">
                 The information below is for an old version of the document that is already published as an RFC.
             </div>
@@ -764,10 +764,10 @@
                 {% endfor %}
             {% endif %}
         </div>
-        {% if doc.get_state_slug == "active" or doc.get_state_slug == "rfc" %}
+        {% if doc.get_state_slug == "active" or doc.type_id == "rfc" %}
             <div class="card mt-5">
                 <div class="card-header">
-                    {% if doc.get_state_slug == "rfc" and not snapshot %}
+                    {% if doc.type_id == "rfc" and not snapshot %}
                         RFC {{ rfc_number }}
                     {% else %}
                         {{ name }}-{{ doc.rev }}
diff --git a/ietf/templates/doc/document_format_buttons.html b/ietf/templates/doc/document_format_buttons.html
index 2c79c9264..043b9a797 100644
--- a/ietf/templates/doc/document_format_buttons.html
+++ b/ietf/templates/doc/document_format_buttons.html
@@ -4,11 +4,11 @@
         {% if label != skip_format %}
         <a class="btn btn-primary btn-sm"
           {% if label == 'pdf' or label == 'pdfized' %}
-            download="{% if not snapshot and doc.get_state_slug == 'rfc' %}rfc{{ doc.rfc_number }}{% else %}{{ doc.name }}-{{ doc.rev }}{% endif %}.pdf"
+            download="{% if not snapshot and doc.type_id == 'rfc' %}rfc{{ doc.rfc_number }}{% else %}{{ doc.name }}-{{ doc.rev }}{% endif %}.pdf"
           {% comment %}
           TODO: determine if we want bibtex to jiust download
           {% elif label == 'bibtex' %}
-            download="{% if not snapshot and doc.get_state_slug == 'rfc' %}rfc{{ doc.rfc_number }}{% else %}{{ doc.name }}-{{ doc.rev }}{% endif %}.bib"
+            download="{% if not snapshot and doc.type_id == 'rfc' %}rfc{{ doc.rfc_number }}{% else %}{{ doc.name }}-{{ doc.rev }}{% endif %}.bib"
           {% endcomment %}
          {% endif %}
           {% if label != 'htmlized' %}target="_blank"{% endif %}
diff --git a/ietf/templates/doc/document_history_form.html b/ietf/templates/doc/document_history_form.html
index 30e0d2800..6fa10002e 100644
--- a/ietf/templates/doc/document_history_form.html
+++ b/ietf/templates/doc/document_history_form.html
@@ -60,7 +60,7 @@
                 {% for name, rev, time, url in diff_revisions %}
                     <option value="{{ url }}"
                         {% if document_html %}
-                            {% if not snapshot and doc.get_state_slug == "rfc" and name == "rfc"|add:doc.rfc_number or snapshot and name == doc.name and rev == doc.rev %} selected{% endif %}
+                            {% if not snapshot and doc.type_id == "rfc" and name == "rfc"|add:doc.rfc_number or snapshot and name == doc.name and rev == doc.rev %} selected{% endif %}
                         {% else %}
                             {% if forloop.counter == 1 %} selected{% endif %}
                         {% endif %}>
diff --git a/ietf/templates/doc/document_html.html b/ietf/templates/doc/document_html.html
index 0d68f0448..627067940 100644
--- a/ietf/templates/doc/document_html.html
+++ b/ietf/templates/doc/document_html.html
@@ -33,7 +33,7 @@
         {% endif %}
         <link rel="alternate" type="application/atom+xml" title="Document changes" href="/feed/document-changes/{{ doc.name }}/">
         <meta name="description"
-            {% if not snapshot and doc.get_state_slug == 'rfc' %}
+            {% if not snapshot and doc.type_id == 'rfc' %}
                 content="{{ doc.title }} (RFC {{ doc.rfc_number }}{% if published %}, {{ published.time|date:'F Y' }}{% endif %}{% if obsoleted_by %}; obsoleted by {% for rel in obsoleted_by %}{{ rel.source.name|prettystdname}}{% if not forloop.last%}, {% endif %}{% endfor %}{% endif %})"
             {% else %}
                 content="{{ doc.title }} (Internet-Draft, {{ doc.time|date:'Y' }})"
@@ -98,7 +98,7 @@
         <nav class="navbar bg-light-subtle px-1 fixed-top d-print-none d-md-none">
             <a class="nav-link ps-1"
                href="{% url 'ietf.doc.views_doc.document_main' name=doc.name %}">
-                {% if not snapshot and doc.get_state_slug == "rfc" %}
+                {% if not snapshot and doc.type_id == "rfc" %}
                     RFC {{ doc.rfc_number }}
                 {% else %}
                     {{ doc.name }}-{{ doc.rev }}
@@ -175,7 +175,7 @@
                     <div class="pt-2 pt-lg-3 px-md-2 px-lg-3">
                         <a class="btn btn-primary btn-sm" href="{% url 'ietf.doc.views_doc.document_main' name=doc.name %}">Datatracker</a>
                         <p class="fw-bold pt-2">
-                                {% if not snapshot and doc.get_state_slug == "rfc" %}
+                                {% if not snapshot and doc.type_id == "rfc" %}
                                     RFC {{ doc.rfc_number }}
                                 {% else %}
                                     {{ doc.name }}-{{ doc.rev }}
diff --git a/ietf/templates/doc/document_info.html b/ietf/templates/doc/document_info.html
index 33d89a60d..1dc7d9ca5 100644
--- a/ietf/templates/doc/document_info.html
+++ b/ietf/templates/doc/document_info.html
@@ -31,7 +31,7 @@
                         {% if document_html %}View errata{% else %}Errata{% endif %}
                     </a>
                 {% endif %}
-                {% if document_html and doc.get_state_slug == "rfc" and not snapshot %}
+                {% if document_html and doc.type_id == "rfc" and not snapshot %}
                     <a class="btn btn-sm btn-warning"
                        title="Click to report an error in the document."
                        href="https://www.rfc-editor.org/errata.php#reportnew"
@@ -60,7 +60,7 @@
                     </div>
                 {% endif %}
             {% else %}
-                {% if snapshot and doc.doc.get_state_slug == 'rfc' %}
+                {% if snapshot and doc.doc.type_id == 'rfc' %}
                    <div{% if document_html %} class="alert alert-warning small"{% endif %}>This is an older version of an Internet-Draft that was ultimately published as <a href="{% url 'ietf.doc.views_doc.document_html' name=doc.doc.name %}">{{doc.doc.name|prettystdname}}</a>.</div>
                 {% elif snapshot and doc.rev != latest_rev  %}
                     <div{% if document_html %} class="alert alert-warning small"{% endif %}>This is an older version of an Internet-Draft whose latest revision state is "{{ doc.doc.get_state }}".</div>
diff --git a/ietf/templates/doc/document_rfc.html b/ietf/templates/doc/document_rfc.html
index 0119a81f2..856c935ea 100644
--- a/ietf/templates/doc/document_rfc.html
+++ b/ietf/templates/doc/document_rfc.html
@@ -13,7 +13,7 @@
           title="Document changes"
           href="/feed/document-changes/{{ name }}/">
     <meta name="description"
-          content="{{ doc.title }} {% if doc.get_state_slug == 'rfc' and not snapshot %}(RFC {{ rfc_number }}{% if published %}, {{ doc.pub_date|date:'F Y' }}{% endif %}{% if obsoleted_by %}; obsoleted by {% for rel in obsoleted_by %}{{ rel.source.name|prettystdname}}{% if not forloop.last%}, {% endif %}{% endfor %}{% endif %}){% endif %}">
+          content="{{ doc.title }} {% if doc.type_id == 'rfc' and not snapshot %}(RFC {{ rfc_number }}{% if published %}, {{ doc.pub_date|date:'F Y' }}{% endif %}{% if obsoleted_by %}; obsoleted by {% for rel in obsoleted_by %}{{ rel.source.name|prettystdname}}{% if not forloop.last%}, {% endif %}{% endfor %}{% endif %}){% endif %}">
 {% endblock %}
 {% block morecss %}.inline { display: inline; }{% endblock %}
 {% block title %}
@@ -280,10 +280,10 @@
                 {% endfor %}
             {% endif %}
         </div>
-        {% if doc.get_state_slug == "active" or doc.get_state_slug == "rfc" %}
+        {% if doc.get_state_slug == "active" or doc.type_id == "rfc" %}
             <div class="card mt-5">
                 <div class="card-header">
-                    {% if doc.get_state_slug == "rfc" and not snapshot %}
+                    {% if doc.type_id == "rfc" and not snapshot %}
                         RFC {{ rfc_number }}
                     {% else %}
                         {{ name }}-{{ doc.rev }}
diff --git a/ietf/templates/doc/opengraph.html b/ietf/templates/doc/opengraph.html
index f4527966a..4fe39b620 100644
--- a/ietf/templates/doc/opengraph.html
+++ b/ietf/templates/doc/opengraph.html
@@ -3,7 +3,7 @@
 {% load static %}
 {% load ietf_filters %}
 {% origin %}
-<meta property="og:title" content="{% if doc.get_state_slug == 'rfc' and not snapshot %}RFC {{ rfc_number }}: {% endif %}{{ doc.title }}">
+<meta property="og:title" content="{% if doc.type_id == 'rfc' and not snapshot %}RFC {{ rfc_number }}: {% endif %}{{ doc.title }}">
 <meta property="og:url" content="{{ settings.IDTRACKER_BASE_URL }}{{ request.path }}">
 <link rel="canonical" href="{{ settings.IDTRACKER_BASE_URL }}{{ request.path }}">
 <meta property="og:site_name" content="IETF Datatracker">
diff --git a/ietf/templates/doc/revisions_list.html b/ietf/templates/doc/revisions_list.html
index 3a3042c62..61f104bf4 100644
--- a/ietf/templates/doc/revisions_list.html
+++ b/ietf/templates/doc/revisions_list.html
@@ -17,14 +17,14 @@
                 </li>
             {% endif %}
         {% endfor %}
-        {% if doc.get_state_slug == 'rfc' %}
+        {% if doc.type_id == 'rfc' %}
             <li class="page-item rfc{% if not snapshot %} active{% endif %}">
                 <a class="page-link"
                    href="{% if doc.doc %}{% if document_html %}{% url 'ietf.doc.views_doc.document_html' name=doc.doc.name %}{% else %}{% url 'ietf.doc.views_doc.document_main' name=doc.doc.name %}{% endif %}{% else %}{% if document_html %}{% url 'ietf.doc.views_doc.document_html' name=doc.name %}{% else %}{% url 'ietf.doc.views_doc.document_main' name=doc.name %}{% endif %}{% endif %}">
                     RFC {{ doc.rfc_number }}
                 </a>
             </li>
-        {% elif doc.doc.get_state_slug == 'rfc' %}
+        {% elif doc.doc.type_id == 'rfc' %}
             <li class="page-item rfc">
                 <a class="page-link"
                    href="{% if document_html %}{% url 'ietf.doc.views_doc.document_html' name=doc.doc.name %}{% else %}{% url 'ietf.doc.views_doc.document_main' name=doc.doc.name %}{% endif %}">
diff --git a/ietf/templates/doc/search/status_columns.html b/ietf/templates/doc/search/status_columns.html
index a126cc1a2..5f8dd826f 100644
--- a/ietf/templates/doc/search/status_columns.html
+++ b/ietf/templates/doc/search/status_columns.html
@@ -4,7 +4,7 @@
 {% load ietf_filters ballot_icon person_filters %}
 <td class="status bg-transparent">
     <div class="float-end ms-1 mb-1" id="ballot-icon-{{ doc.name }}">{% ballot_icon doc %}</div>
-    {% if not doc.get_state_slug == "rfc" %}
+    {% if not doc.type_id == "rfc" %}
         {% if '::' in doc.friendly_state %}
             {{ doc.friendly_state|safe }}
         {% else %}