diff --git a/ietf/doc/migrations/0016_move_dochistory.py b/ietf/doc/migrations/0016_move_dochistory.py index 3a43edb3b..cfc98529b 100644 --- a/ietf/doc/migrations/0016_move_dochistory.py +++ b/ietf/doc/migrations/0016_move_dochistory.py @@ -25,14 +25,10 @@ def forward(apps, schema_editor): ).exists() -def reverse(apps, schema_editor): - # there is no going back - raise NotImplementedError - - class Migration(migrations.Migration): dependencies = [ ("doc", "0015_delete_docalias"), ] - operations = [migrations.RunPython(forward, reverse)] + # There is no going back + operations = [migrations.RunPython(forward)] diff --git a/ietf/doc/models.py b/ietf/doc/models.py index ebc0a575e..075a34753 100644 --- a/ietf/doc/models.py +++ b/ietf/doc/models.py @@ -666,13 +666,16 @@ class DocumentInfo(models.Model): ) def became_rfc(self): - doc = self if isinstance(self, Document) else self.doc - return next(iter(doc.related_that_doc("became_rfc")), None) + if not hasattr(self, "_cached_became_rfc"): + doc = self if isinstance(self, Document) else self.doc + self._cached_became_rfc = next(iter(doc.related_that_doc("became_rfc")), None) + return self._cached_became_rfc def came_from_draft(self): - doc = self if isinstance(self, Document) else self.doc - return next(iter(doc.related_that("became_rfc")), None) - + if not hasattr(self, "_cached_came_from_draft"): + doc = self if isinstance(self, Document) else self.doc + self.cached_came_from_draft = next(iter(doc.related_that("became_rfc")), None) + return self._cached_came_from_draft class Meta: abstract = True diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py index 0c2a65650..c5b4e1296 100644 --- a/ietf/doc/views_doc.py +++ b/ietf/doc/views_doc.py @@ -195,6 +195,8 @@ def document_main(request, name, rev=None, document_html=False): doc = get_object_or_404(Document.objects.select_related(), name=name) + log.assertion('doc.type_id!="rfc" or doc.name.startswith("rfc")') + # take care of possible redirections if document_html is False and rev is None: became_rfc = doc.became_rfc() @@ -1126,8 +1128,10 @@ def document_email(request,name): def get_diff_revisions(request, name, doc): - """ returns list of (name, rev, time, url, is_this_doc, is_previous_doc) - ordered by -time for use by forms used to get to the diff tools. + """ Calculate what to offer for diff comparisons + + returns list of (name, rev, time, url, is_this_doc, is_previous_doc) + ordered by -time for use by forms used to get to the diff tools. """ diffable = any( [