diff --git a/ietf/doc/admin.py b/ietf/doc/admin.py index 5061f1495..b8402a3d9 100644 --- a/ietf/doc/admin.py +++ b/ietf/doc/admin.py @@ -111,7 +111,7 @@ admin.site.register(DocHistory, DocHistoryAdmin) class DocAliasAdmin(admin.ModelAdmin): list_display = ['name', 'targets'] - search_fields = ['name', 'docs__name'] + search_fields = ['name'] raw_id_fields = ['docs'] def targets(self, obj): return ', '.join([o.name for o in obj.docs.all()]) diff --git a/ietf/doc/migrations/0011_rfc_relateddocuments.py b/ietf/doc/migrations/0011_rfc_relateddocuments.py index 0b453219d..48b7f0f21 100644 --- a/ietf/doc/migrations/0011_rfc_relateddocuments.py +++ b/ietf/doc/migrations/0011_rfc_relateddocuments.py @@ -8,7 +8,7 @@ def forward(apps, schema_editor): Document = apps.get_model("doc", "Document") RelatedDocument = apps.get_model("doc", "RelatedDocument") for rfc_alias in DocAlias.objects.filter(name__startswith="rfc").exclude( - docs__type__slug="rfc" + type_id="rfc" ): # Move these over to the RFC RelatedDocument.objects.filter( diff --git a/ietf/doc/models.py b/ietf/doc/models.py index 960170a9f..f9f2c7ca5 100644 --- a/ietf/doc/models.py +++ b/ietf/doc/models.py @@ -939,8 +939,9 @@ class Document(DocumentInfo): def ipr(self,states=('posted','removed')): """Returns the IPR disclosures against this document (as a queryset over IprDocRel).""" - from ietf.ipr.models import IprDocRel - return IprDocRel.objects.filter(document__docs=self, disclosure__state__in=states) + # from ietf.ipr.models import IprDocRel + # return IprDocRel.objects.filter(document__docs=self, disclosure__state__in=states) # TODO - clear these comments away + return self.iprdocrel_set.filter(disclosure__state__in=states) def related_ipr(self): """Returns the IPR disclosures against this document and those documents this diff --git a/ietf/doc/templatetags/ietf_filters.py b/ietf/doc/templatetags/ietf_filters.py index ff798c617..901289c8f 100644 --- a/ietf/doc/templatetags/ietf_filters.py +++ b/ietf/doc/templatetags/ietf_filters.py @@ -146,7 +146,7 @@ def doc_name(name): key = hash(n) found = cache.get(key) if not found: - exact = Document.objects.filter(name=n) + exact = Document.objects.filter(name=n).first() found = exact.name if exact else "_" # TODO review this cache policy (and the need for these entire function) cache.set(key, found, timeout=60*60*24) # cache for one day @@ -250,14 +250,12 @@ def urlize_ietf_docs(string, autoescape=None): string, flags=re.IGNORECASE | re.ASCII, ) - debug.show('string') string = re.sub( r"\b(?bCp123456'), - ("Std 00123456", 'Std 00123456'), - ( - "FyI 0123456 changes std 00123456", - 'FyI 0123456 changes std 00123456', - ), + + # TODO: rework subseries when we add them + # ("bCp123456", 'bCp123456'), + # ("Std 00123456", 'Std 00123456'), + # ( + # "FyI 0123456 changes std 00123456", + # 'FyI 0123456 changes std 00123456', + # ), ("rfc123456", 'rfc123456'), ("Rfc 0123456", 'Rfc 0123456'), (rfc.name, f'{rfc.name}'), diff --git a/ietf/doc/tests_review.py b/ietf/doc/tests_review.py index fb40803f4..8ffe45639 100644 --- a/ietf/doc/tests_review.py +++ b/ietf/doc/tests_review.py @@ -922,7 +922,7 @@ class ReviewTests(TestCase): date_today().isoformat(), ] review_name = "-".join(c for c in name_components if c).lower() - Document.objects.create(name=review_name,type_id='review',group=assignment.review_request.team) + d = Document.objects.create(name=review_name,type_id='review',group=assignment.review_request.team) r = self.client.post(url, data={ "result": ReviewResultName.objects.get(reviewteamsettings_review_results_set__group=assignment.review_request.team, slug="ready").pk, diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py index 1475aade9..5f45eebac 100644 --- a/ietf/doc/views_doc.py +++ b/ietf/doc/views_doc.py @@ -1175,7 +1175,7 @@ def get_diff_revisions(request, name, doc): ) ) - if doc.tyoe_id == "rfc": + if doc.type_id == "rfc": e = doc.latest_event(type="published_rfc") diff_revisions.append((name, "", e.time if e else doc.time, name)) diff --git a/ietf/doc/views_search.py b/ietf/doc/views_search.py index d38a745cc..ac823b6a5 100644 --- a/ietf/doc/views_search.py +++ b/ietf/doc/views_search.py @@ -254,7 +254,7 @@ def search_for_name(request, name): startswith = Document.objects.filter(name__istartswith=n)[:2] if len(startswith) == 1: - return startswith.name + return startswith[0].name contains = Document.objects.filter(name__icontains=n)[:2] if len(contains) == 1: @@ -818,7 +818,7 @@ def index_all_drafts(request): # Should we rename this else: heading = "%s Internet-Drafts" % state.name - drafts = Document.objects.filter(docs__type_id="draft", docs__states=state).order_by("name") + drafts = Document.objects.filter(type_id="draft", states=state).order_by("name") names = [ f'{doc.name}' @@ -832,9 +832,9 @@ def index_all_drafts(request): # Should we rename this )) # gather RFCs - rfcs = Document.objects.filter(docs__type_id="rfc").order_by('-rfc_number') + rfcs = Document.objects.filter(type_id="rfc").order_by('-rfc_number') names = [ - f'{rfc.name}' + f'{rfc.name.upper()}' for rfc in rfcs ] diff --git a/ietf/ipr/utils.py b/ietf/ipr/utils.py index d56da5762..9ce7384d2 100644 --- a/ietf/ipr/utils.py +++ b/ietf/ipr/utils.py @@ -45,7 +45,7 @@ def related_docs(doc, relationship=('replaces', 'obs')): results = [doc] - rels = list(doc.document.all_relations_that_doc(relationship)) + rels = list(doc.all_relations_that_doc(relationship)) for rel in rels: rel.target.related = rel diff --git a/ietf/ipr/views.py b/ietf/ipr/views.py index c2a6b0a66..dc96eec8b 100644 --- a/ietf/ipr/views.py +++ b/ietf/ipr/views.py @@ -709,13 +709,13 @@ def search(request): # Search by wg acronym # Document list with IPRs elif search_type == "group": - docs = list(Document.objects.filter(docs__group=q)) + docs = list(Document.objects.filter(group=q)) related = [] for doc in docs: doc.product_of_this_wg = True related += related_docs(doc) iprs = iprs_from_docs(list(set(docs+related)),states=states) - docs = [ doc for doc in docs if doc.document.ipr() ] + docs = [ doc for doc in docs if doc.ipr() ] docs = sorted(docs, key=lambda x: max([ipr.disclosure.time for ipr in x.document.ipr()]), reverse=True) template = "ipr/search_wg_result.html" q = Group.objects.get(id=q).acronym # make acronym for use in template @@ -723,12 +723,12 @@ def search(request): # Search by rfc and id title # Document list with IPRs elif search_type == "doctitle": - docs = list(Document.objects.filter(docs__title__icontains=q)) + docs = list(Document.objects.filter(title__icontains=q)) related = [] for doc in docs: related += related_docs(doc) iprs = iprs_from_docs(list(set(docs+related)),states=states) - docs = [ doc for doc in docs if doc.document.ipr() ] + docs = [ doc for doc in docs if doc.ipr() ] docs = sorted(docs, key=lambda x: max([ipr.disclosure.time for ipr in x.document.ipr()]), reverse=True) template = "ipr/search_doctitle_result.html" diff --git a/ietf/stats/views.py b/ietf/stats/views.py index 64b914b85..c64b80ec8 100644 --- a/ietf/stats/views.py +++ b/ietf/stats/views.py @@ -214,13 +214,13 @@ def document_stats(request, stats_type=None): if any(stats_type == t[0] for t in possible_document_stats_types): # filter documents - document_filters = Q(docs__type="draft") + document_filters = Q(type__in=["draft","rfc"]) # TODO - review lots of "rfc is a draft" assumptions below rfc_state = State.objects.get(type="draft", slug="rfc") if document_type == "rfc": - document_filters &= Q(docs__states=rfc_state) + document_filters &= Q(states=rfc_state) elif document_type == "draft": - document_filters &= ~Q(docs__states=rfc_state) + document_filters &= ~Q(states=rfc_state) if from_time: # this is actually faster than joining in the database, @@ -231,7 +231,7 @@ def document_stats(request, stats_type=None): docevent__type__in=["published_rfc", "new_revision"], ).values_list("pk")) - document_filters &= Q(docs__in=docs_within_time_constraint) + document_filters &= Q(pk__in=docs_within_time_constraint) document_qs = Document.objects.filter(document_filters) diff --git a/ietf/templates/ipr/search_doc_result.html b/ietf/templates/ipr/search_doc_result.html index 484027094..4a3a4eda2 100644 --- a/ietf/templates/ipr/search_doc_result.html +++ b/ietf/templates/ipr/search_doc_result.html @@ -58,7 +58,7 @@