From fc284be6d8f520915a91ea5d140513dd4a90e819 Mon Sep 17 00:00:00 2001
From: Jennifer Richards <jennifer@staff.ietf.org>
Date: Thu, 6 Jul 2023 17:33:04 -0300
Subject: [PATCH] fix: Deal with rfc doc types for references/referenced_by
 views

---
 ietf/doc/models.py                             | 16 +++++++++++++---
 ietf/templates/doc/document_referenced_by.html |  2 +-
 ietf/templates/doc/document_references.html    |  2 +-
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/ietf/doc/models.py b/ietf/doc/models.py
index 958fde12a..76c30738e 100644
--- a/ietf/doc/models.py
+++ b/ietf/doc/models.py
@@ -641,10 +641,20 @@ class DocumentInfo(models.Model):
         return self.relations_that_doc(('refnorm','refinfo','refunk','refold'))
 
     def referenced_by(self):
-        return self.relations_that(('refnorm','refinfo','refunk','refold')).filter(source__states__type__slug='draft',source__states__slug__in=['rfc','active'])
-
+        return self.relations_that(("refnorm", "refinfo", "refunk", "refold")).filter(
+            models.Q(
+                source__type__slug="draft",
+                source__states__type__slug="draft",
+                source__states__slug="active",
+            )
+            | models.Q(source__type__slug="rfc")
+        )
+    
+    
     def referenced_by_rfcs(self):
-        return self.relations_that(('refnorm','refinfo','refunk','refold')).filter(source__states__type__slug='draft',source__states__slug='rfc')
+        return self.relations_that(("refnorm", "refinfo", "refunk", "refold")).filter(
+            source__type__slug="rfc"
+        )
 
     class Meta:
         abstract = True
diff --git a/ietf/templates/doc/document_referenced_by.html b/ietf/templates/doc/document_referenced_by.html
index 958108bdd..7f7fe13c3 100644
--- a/ietf/templates/doc/document_referenced_by.html
+++ b/ietf/templates/doc/document_referenced_by.html
@@ -64,7 +64,7 @@
                             </a>
                         </td>
                         <td>
-                            {% if ref.source.get_state.slug == 'rfc' %}
+                            {% if ref.source.type_id == "rfc" %}
                                 {% with ref.source.std_level as lvl %}
                                     {% if lvl %}{{ lvl }}{% endif %}
                                 {% endwith %}
diff --git a/ietf/templates/doc/document_references.html b/ietf/templates/doc/document_references.html
index d9134be6f..83358774f 100644
--- a/ietf/templates/doc/document_references.html
+++ b/ietf/templates/doc/document_references.html
@@ -51,7 +51,7 @@
                             </a>
                         </td>
                         <td>
-                            {% if ref.target.document.get_state.slug == 'rfc' %}
+                            {% if ref.target.document.type_id == "rfc" %}
                                 {% with ref.target.document.std_level as lvl %}
                                     {% if lvl %}{{ lvl }}{% endif %}
                                 {% endwith %}