Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use idnits3 for post submission nits check #8169

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions ietf/doc/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2996,6 +2996,24 @@ def test_raw_id(self):
self.should_succeed(dict(name=draft.name, rev='00',ext='txt'))
self.should_404(dict(name=draft.name, rev='00',ext='html'))

@override_settings(IDNITS3_BASE_URL="https://example.org/idnits3")
def test_nits_url(self):
draft = WgDraftFactory(name="draft-ietf-moon-test",rev="01", create_revisions=range(0,2))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment as to why you're setting up this particular arrangement of revisions would be helpful


dir = settings.INTERNET_ALL_DRAFTS_ARCHIVE_DIR
(Path(dir) / f"{draft.name}-01.xml").touch()
r = self.client.get(urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=draft.name)))
self.assertContains(r, settings.IDNITS3_BASE_URL)

@override_settings(IDNITS_BASE_URL="https://example.org/nits")
def test_nits_url_txt_only(self):
draft = WgDraftFactory(name="draft-ietf-moon-test",rev="01", create_revisions=range(0,2))

dir = settings.INTERNET_ALL_DRAFTS_ARCHIVE_DIR
(Path(dir) / f"{draft.name}-01.txt").touch()
r = self.client.get(urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=draft.name)))
self.assertContains(r, settings.IDNITS_BASE_URL)

# test_raw_id_rfc intentionally removed
# an rfc is no longer a pseudo-version of a draft.

Expand Down
11 changes: 10 additions & 1 deletion ietf/doc/views_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,14 @@ def document_main(request, name, rev=None, document_html=False):
# Stream description and name passing test
stream = ("draft-stream-" + doc.stream.slug) if doc.stream != None else "(None)"

# Nits URL
nits_url = ''
if 'xml' in found_types:
nits_url = f"{settings.IDNITS3_BASE_URL}?url={[fu[1] for fu in file_urls if fu[0] == 'xml'][0]}"
elif 'txt' in found_types:
nits_url = f"{settings.IDNITS_BASE_URL}?url={[fu[1] for fu in file_urls if fu[0] == 'plain text'][0]}"


html = None
js = None
css = None
Expand Down Expand Up @@ -711,7 +719,8 @@ def document_main(request, name, rev=None, document_html=False):
review_requests=review_requests,
no_review_from_teams=no_review_from_teams,
due_date=due_date,
diff_revisions=diff_revisions
diff_revisions=diff_revisions,
nits_url=nits_url
))

elif doc.type_id == "charter":
Expand Down
1 change: 1 addition & 0 deletions ietf/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ def skip_unreadable_post(record):
IDTRACKER_BASE_URL = "https://datatracker.ietf.org"
RFCDIFF_BASE_URL = "https://author-tools.ietf.org/iddiff"
IDNITS_BASE_URL = "https://author-tools.ietf.org/api/idnits"
IDNITS3_BASE_URL = "https://author-tools.ietf.org/api/idnits3"
IDNITS_SERVICE_URL = "https://author-tools.ietf.org/idnits"

# Content security policy configuration (django-csp)
Expand Down
4 changes: 3 additions & 1 deletion ietf/templates/doc/document_draft.html
Original file line number Diff line number Diff line change
Expand Up @@ -653,14 +653,16 @@
</i>
Referenced by
</a>
{% if nits_url %}
<a class="btn btn-primary btn-sm"
href="{{ settings.IDNITS_BASE_URL }}?url=https://www.ietf.org/archive/id/{{ doc.filename_with_rev }}"
href="{{ nits_url }}"
rel="nofollow"
target="_blank">
<i class="bi bi-exclamation">
</i>
Nits
</a>
{% endif %}
<a class="btn btn-primary btn-sm"
href="https://mailarchive.ietf.org/arch/search/?q=%22{{ doc.name }}%22"
rel="nofollow"
Expand Down
Loading