Skip to content

Commit

Permalink
fix: 404 requests for bibtex for none draft or rfc documents (#6834)
Browse files Browse the repository at this point in the history
* fix: 404 requests for bibtex for none draft or rfc documents

* test: test rejecting the types with factories already being imported
  • Loading branch information
rjsparks committed Dec 21, 2023
1 parent 50aa399 commit bc74977
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ietf/doc/tests.py
Expand Up @@ -40,7 +40,7 @@
ConflictReviewFactory, WgDraftFactory, IndividualDraftFactory, WgRfcFactory,
IndividualRfcFactory, StateDocEventFactory, BallotPositionDocEventFactory,
BallotDocEventFactory, DocumentAuthorFactory, NewRevisionDocEventFactory,
StatusChangeFactory, DocExtResourceFactory, RgDraftFactory)
StatusChangeFactory, DocExtResourceFactory, RgDraftFactory, BcpFactory)
from ietf.doc.forms import NotifyForm
from ietf.doc.fields import SearchableDocumentsField
from ietf.doc.utils import create_ballot_if_not_open, uppercase_std_abbreviated_name
Expand Down Expand Up @@ -1948,6 +1948,12 @@ def _parse_bibtex_response(self, response) -> dict:

@override_settings(RFC_EDITOR_INFO_BASE_URL='https://www.rfc-editor.ietf.org/info/')
def test_document_bibtex(self):

for factory in [CharterFactory, BcpFactory, StatusChangeFactory, ConflictReviewFactory]: # Should be extended to all other doc types
doc = factory()
url = urlreverse("ietf.doc.views_doc.document_bibtex", kwargs=dict(name=doc.name))
r = self.client.get(url)
self.assertEqual(r.status_code, 404)
rfc = WgRfcFactory.create(
time=datetime.datetime(2010, 10, 10, tzinfo=ZoneInfo(settings.TIME_ZONE))
)
Expand Down
3 changes: 3 additions & 0 deletions ietf/doc/views_doc.py
Expand Up @@ -1262,6 +1262,9 @@ def document_bibtex(request, name, rev=None):

doc = get_object_or_404(Document, name=name)

if doc.type_id not in ["rfc", "draft"]:
raise Http404()

doi = None
draft_became_rfc = None
replaced_by = None
Expand Down

0 comments on commit bc74977

Please sign in to comment.