fix: adjusted bibtex view and tests
This commit is contained in:
parent
400280e50c
commit
799d3a1a3e
|
@ -1981,7 +1981,7 @@ class DocTestCase(TestCase):
|
|||
r = self.client.get(url)
|
||||
entry = self._parse_bibtex_response(r)["rfc%s"%num]
|
||||
self.assertEqual(entry['series'], 'Request for Comments')
|
||||
self.assertEqual(entry['number'], num)
|
||||
self.assertEqual(int(entry['number']), num)
|
||||
self.assertEqual(entry['doi'], '10.17487/RFC%s'%num)
|
||||
self.assertEqual(entry['year'], '2010')
|
||||
self.assertEqual(entry['month'].lower()[0:3], 'oct')
|
||||
|
@ -1995,7 +1995,7 @@ class DocTestCase(TestCase):
|
|||
std_level_id = 'inf',
|
||||
time = datetime.datetime(1990, 4, 1, tzinfo=ZoneInfo(settings.TIME_ZONE)),
|
||||
)
|
||||
num = april1.rfc_number()
|
||||
num = april1.rfc_number
|
||||
DocEventFactory.create(
|
||||
doc=april1,
|
||||
type='published_rfc',
|
||||
|
@ -2007,7 +2007,7 @@ class DocTestCase(TestCase):
|
|||
self.assertEqual(r.get('Content-Type'), 'text/plain; charset=utf-8')
|
||||
entry = self._parse_bibtex_response(r)["rfc%s"%num]
|
||||
self.assertEqual(entry['series'], 'Request for Comments')
|
||||
self.assertEqual(entry['number'], num)
|
||||
self.assertEqual(int(entry['number']), num)
|
||||
self.assertEqual(entry['doi'], '10.17487/RFC%s'%num)
|
||||
self.assertEqual(entry['year'], '1990')
|
||||
self.assertEqual(entry['month'].lower()[0:3], 'apr')
|
||||
|
|
|
@ -1241,31 +1241,35 @@ def document_bibtex(request, name, rev=None):
|
|||
|
||||
doc = get_object_or_404(Document, docalias__name=name)
|
||||
|
||||
latest_revision = doc.latest_event(NewRevisionDocEvent, type="new_revision")
|
||||
replaced_by = [d.name for d in doc.related_that("replaces")]
|
||||
published = doc.latest_event(type="published_rfc") is not None
|
||||
rfc = latest_revision.doc if latest_revision and latest_revision.doc.get_state_slug() == "rfc" else None
|
||||
doi = None
|
||||
draft_became_rfc = None
|
||||
replaced_by = None
|
||||
latest_revision = None
|
||||
if doc.type_id == "draft":
|
||||
latest_revision = doc.latest_event(NewRevisionDocEvent, type="new_revision")
|
||||
replaced_by = [d.name for d in doc.related_that("replaces")]
|
||||
draft_became_rfc_alias = next(iter(doc.related_that_doc("became_rfc")), None)
|
||||
|
||||
if rev != None and rev != doc.rev:
|
||||
# find the entry in the history
|
||||
for h in doc.history_set.order_by("-time"):
|
||||
if rev == h.rev:
|
||||
doc = h
|
||||
break
|
||||
|
||||
if doc.type_id == "rfc":
|
||||
if rev != None and rev != doc.rev:
|
||||
# find the entry in the history
|
||||
for h in doc.history_set.order_by("-time"):
|
||||
if rev == h.rev:
|
||||
doc = h
|
||||
break
|
||||
|
||||
if draft_became_rfc_alias:
|
||||
draft_became_rfc = draft_became_rfc_alias.document
|
||||
|
||||
elif doc.type_id == "rfc":
|
||||
# This needs to be replaced with a lookup, as the mapping may change
|
||||
# over time. Probably by updating ietf/sync/rfceditor.py to add the
|
||||
# as a DocAlias, and use a method on Document to retrieve it.
|
||||
doi = f"10.17487/RFC{doc.rfc_number:04d}"
|
||||
else:
|
||||
doi = None
|
||||
|
||||
return render(request, "doc/document_bibtex.bib",
|
||||
dict(doc=doc,
|
||||
replaced_by=replaced_by,
|
||||
published=published,
|
||||
rfc=rfc,
|
||||
published_as=draft_became_rfc,
|
||||
latest_revision=latest_revision,
|
||||
doi=doi,
|
||||
),
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
{% load ietf_filters %}
|
||||
{% load textfilters %}
|
||||
|
||||
{% if doc.get_state_slug == "rfc" %}
|
||||
{% if doc.type_id == "rfc" %}
|
||||
{% if doc.stream|slugify == "legacy" %}
|
||||
% Datatracker information for RFCs on the Legacy Stream is unfortunately often
|
||||
% incorrect. Please correct the bibtex below based on the information in the
|
||||
|
@ -16,7 +16,7 @@
|
|||
publisher = {RFC Editor},
|
||||
doi = {% templatetag openbrace %}{{ doi }}{% templatetag closebrace %},
|
||||
url = {% templatetag openbrace %}{{ doc.rfc_number|rfceditor_info_url }}{% templatetag closebrace %},{% else %}
|
||||
{% if published %}%% You should probably cite rfc{{ latest_revision.doc.rfc_number }} instead of this I-D.{% else %}{% if replaced_by %}%% You should probably cite {{replaced_by|join:" or "}} instead of this I-D.{% else %}
|
||||
{% if published_as %}%% You should probably cite rfc{{ published_as.rfc_number }} instead of this I-D.{% else %}{% if replaced_by %}%% You should probably cite {{replaced_by|join:" or "}} instead of this I-D.{% else %}
|
||||
{% if doc.rev != latest_revision.rev %}%% You should probably cite {{latest_revision.doc.name}}-{{latest_revision.rev}} instead of this revision.{%endif%}{% endif %}{% endif %}
|
||||
@techreport{% templatetag openbrace %}{{doc.name|slice:"6:"}}-{{doc.rev}},
|
||||
number = {% templatetag openbrace %}{{doc.name}}-{{doc.rev}}{% templatetag closebrace %},
|
||||
|
@ -29,7 +29,7 @@
|
|||
title = {% templatetag openbrace %}{% templatetag openbrace %}{{doc.title|texescape}}{% templatetag closebrace %}{% templatetag closebrace %},
|
||||
pagetotal = {{ doc.pages }},
|
||||
year = {{ doc.pub_date.year }},
|
||||
month = {{ doc.pub_date|date:"b" }},{% if not doc.rfc_number or doc.pub_date.day == 1 and doc.pub_date.month == 4 %}
|
||||
month = {{ doc.pub_date|date:"b" }},{% if not doc.type_id == "rfc" or doc.pub_date.day == 1 and doc.pub_date.month == 4 %}
|
||||
day = {{ doc.pub_date.day }},{% endif %}
|
||||
abstract = {% templatetag openbrace %}{{ doc.abstract|clean_whitespace|texescape }}{% templatetag closebrace %},
|
||||
{% templatetag closebrace %}
|
||||
|
|
Loading…
Reference in a new issue