From 0051aa9844c4fa6852ec6c4c72b63d4fb95f6c3f Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Thu, 16 Nov 2023 13:05:58 -0600 Subject: [PATCH] fix: search correct doc type/states, switch rfc correctly in html_body, remove dead code. (#6640) * fix: search correct doc type/states, switch rfc correctly in html_body, remove dead code * chore: Add unreachable() marker --------- Co-authored-by: Jennifer Richards --- ietf/doc/models.py | 2 +- ietf/doc/utils.py | 10 ---------- ietf/doc/utils_search.py | 4 +++- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/ietf/doc/models.py b/ietf/doc/models.py index f09a60b74..92d56e031 100644 --- a/ietf/doc/models.py +++ b/ietf/doc/models.py @@ -539,7 +539,7 @@ class DocumentInfo(models.Model): return self.text() or "Error; cannot read '%s'"%self.get_base_name() def html_body(self, classes=""): - if self.get_state_slug() == "rfc": + if self.type_id == "rfc": try: html = Path( os.path.join(settings.RFC_PATH, self.name + ".html") diff --git a/ietf/doc/utils.py b/ietf/doc/utils.py index 5c9805d9f..791339c4f 100644 --- a/ietf/doc/utils.py +++ b/ietf/doc/utils.py @@ -352,16 +352,6 @@ def augment_events_with_revision(doc, events): qs = NewRevisionDocEvent.objects.filter(doc=doc) event_revisions = list(qs.order_by('time', 'id').values('id', 'rev', 'time')) - if doc.type_id == "draft" and doc.get_state_slug() == "rfc": - # add fake "RFC" revision - if isinstance(events, QuerySetAny): - e = events.filter(type="published_rfc").order_by('time').last() - else: - e = doc.latest_event(type="published_rfc") - if e: - event_revisions.append(dict(id=e.id, time=e.time, rev="RFC")) - event_revisions.sort(key=lambda x: (x["time"], x["id"])) - for e in sorted(events, key=lambda e: (e.time, e.id), reverse=True): while event_revisions and (e.time, e.id) < (event_revisions[-1]["time"], event_revisions[-1]["id"]): event_revisions.pop() diff --git a/ietf/doc/utils_search.py b/ietf/doc/utils_search.py index 16cc731bd..f62c0707f 100644 --- a/ietf/doc/utils_search.py +++ b/ietf/doc/utils_search.py @@ -14,6 +14,7 @@ from ietf.doc.expire import expirable_drafts from ietf.doc.utils import augment_docs_and_user_with_user_info from ietf.meeting.models import SessionPresentation, Meeting, Session from ietf.review.utils import review_assignments_to_list_for_docs +from ietf.utils import log from ietf.utils.timezone import date_today @@ -102,6 +103,7 @@ def fill_in_document_table_attributes(docs, have_telechat_date=False): if d.type_id == "draft": state_slug = d.get_state_slug() if state_slug == "rfc": + log.unreachable("2023-11-15") d.search_heading = "RFC" d.expirable = False elif state_slug in ("ietf-rm", "auth-rm"): @@ -117,7 +119,7 @@ def fill_in_document_table_attributes(docs, have_telechat_date=False): d.search_heading = "%s" % (d.type,) d.expirable = False - if d.get_state_slug() != "rfc": + if d.type_id == "draft" and d.get_state_slug() != "rfc": d.milestones = [ m for (t, s, v, m) in sorted(((m.time, m.state.slug, m.desc, m) for m in d.groupmilestone_set.all() if m.state_id == "active")) ] d.review_assignments = review_assignments_to_list_for_docs([d]).get(d.name, [])