Skip to content
Merged
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
2 changes: 1 addition & 1 deletion ietf/group/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2201,7 +2201,7 @@ def statements(request, acronym, group_type=None):
).values_list("state__slug", flat=True)[:1]
)
)
.order_by("-published")
.order_by("status", "-published")
)
return render(
request,
Expand Down
4 changes: 2 additions & 2 deletions ietf/nomcom/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def retrieve_nomcom_private_key(request, year):
if not private_key:
return private_key

command = "%s bf -d -in /dev/stdin -k \"%s\" -a"
command = "%s aes-128-ecb -d -in /dev/stdin -k \"%s\" -a -iter 1000"
code, out, error = pipe(
command % (
settings.OPENSSL_COMMAND,
Expand All @@ -208,7 +208,7 @@ def store_nomcom_private_key(request, year, private_key):
if not private_key:
request.session['NOMCOM_PRIVATE_KEY_%s' % year] = ''
else:
command = "%s bf -e -in /dev/stdin -k \"%s\" -a"
command = "%s aes-128-ecb -e -in /dev/stdin -k \"%s\" -a -iter 1000"
code, out, error = pipe(
command % (
settings.OPENSSL_COMMAND,
Expand Down
22 changes: 14 additions & 8 deletions ietf/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright The IETF Trust 2007-2024, All Rights Reserved
# Copyright The IETF Trust 2007-2025, All Rights Reserved
# -*- coding: utf-8 -*-


Expand All @@ -9,6 +9,7 @@
import os
import sys
import datetime
import pathlib
import warnings
from hashlib import sha384
from typing import Any, Dict, List, Tuple # pyflakes:ignore
Expand All @@ -27,8 +28,12 @@
warnings.filterwarnings("ignore", message="Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated", module="bleach")
warnings.filterwarnings("ignore", message="HTTPResponse.getheader\\(\\) is deprecated", module='selenium.webdriver')

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.abspath(BASE_DIR + "/.."))
base_path = pathlib.Path(__file__).resolve().parent
BASE_DIR = str(base_path)

project_path = base_path.parent
PROJECT_DIR = str(project_path)
sys.path.append(PROJECT_DIR)

from ietf import __version__
import debug
Expand Down Expand Up @@ -717,12 +722,13 @@ def skip_unreadable_post(record):
]

# These are filename globs. They are used by test_parse_templates() and
# get_template_paths()
# get_template_paths(). Globs are applied via pathlib.Path().match, using
# the path to the template from the project root.
TEST_TEMPLATE_IGNORE = [
".*", # dot-files
"*~", # tilde temp-files
"#*", # files beginning with a hashmark
"500.html" # isn't loaded by regular loader, but checked by test_500_page()
".*", # dot-files
"*~", # tilde temp-files
"#*", # files beginning with a hashmark
"500.html", # isn't loaded by regular loader, but checked by test_500_page()
]

TEST_COVERAGE_MAIN_FILE = os.path.join(BASE_DIR, "../release-coverage.json")
Expand Down
3 changes: 2 additions & 1 deletion ietf/static/js/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ $(document)

$(table)
.find(".sort")
.on("click", function () {
.on("click", function (ev) {
ev.preventDefault()
var order = $(this)
.hasClass("asc") ? "desc" : "asc";
$.each(list_instance, (_, e) => {
Expand Down
19 changes: 14 additions & 5 deletions ietf/templates/group/statements.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ <h2 class="my-3">{{group.acronym|upper}} Statements</h2>
{% if request.user|has_role:"Secretariat" %}
<div class="buttonlist">
<a id="start_button"
class="btn btn-primary"
href="{% url 'ietf.doc.views_statement.new_statement' %}">
class="btn btn-primary"
href="{% url 'ietf.doc.views_statement.new_statement' %}">
Start New Statement
</a>
</div>
Expand All @@ -25,16 +25,25 @@ <h2 class="my-3">{{group.acronym|upper}} Statements</h2>
<th scope="col" data-sort="statement">Statement</th>
</tr>
</thead>
{% regroup statements by status as grouped_statements %}
{% for statement_group in grouped_statements %}
<tbody>
{% for statement in statements %}
<tr class="table-info">
<th scope="col" colspan="2">
{{ statement_group.grouper|title }} {{"Statement"|plural:statement_group.list }} ({{ statement_group.list|length }} {{"hit"|plural:statement_group.list }})
</th>
</tr>
</tbody>
<tbody>
{% for statement in statement_group.list %}
<tr>
<td title="{{ statement.published|date:'Y-m-d H:i:s O' }}">{{ statement.published|date:"Y-m-d" }}</td>
<td><a href="{% url 'ietf.doc.views_doc.document_main' name=statement.name %}">{{statement.title}}</a>
{% if statement.status == "replaced" %}<span class="badge rounded-pill text-bg-warning">Replaced</span>{% endif %}
</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
{% endfor %}
</table>
{% endblock %}
{% block js %}
Expand Down
41 changes: 21 additions & 20 deletions ietf/utils/test_runner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright The IETF Trust 2009-2020, All Rights Reserved
# Copyright The IETF Trust 2009-2025, All Rights Reserved
# -*- coding: utf-8 -*-
#
# Portion Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
Expand Down Expand Up @@ -54,7 +54,6 @@
import urllib3
import warnings

from fnmatch import fnmatch
from typing import Callable, Optional
from urllib.parse import urlencode

Expand Down Expand Up @@ -414,8 +413,9 @@ def do_append(res, p0, p1, item):
res.append((str(item.pattern), item))
return res


_all_templates = None
def get_template_paths(apps=None):
def get_template_paths(apps=None) -> list[str]:
global _all_templates
if not _all_templates:
# TODO: Add app templates to the full list, if we are using
Expand All @@ -424,25 +424,26 @@ def get_template_paths(apps=None):
templatepaths = settings.TEMPLATES[0]['DIRS']
for templatepath in templatepaths:
for dirpath, dirs, files in os.walk(templatepath):
if ".svn" in dirs:
dirs.remove(".svn")
relative_path = dirpath[len(templatepath)+1:]
for file in files:
ignore = False
for pattern in settings.TEST_TEMPLATE_IGNORE:
if fnmatch(file, pattern):
ignore = True
break
if ignore:
continue
if relative_path != "":
file = os.path.join(relative_path, file)
templates.add(file)
if apps:
templates = [ t for t in templates if t.split(os.path.sep)[0] in apps ]
_all_templates = templates
# glob against path from PROJECT_DIR
project_path = pathlib.Path(
dirpath.removeprefix(settings.PROJECT_DIR).lstrip("/")
)
# label entries with name relative to templatepath
relative_path = pathlib.Path(
dirpath.removeprefix(templatepath).lstrip("/")
)
if apps and relative_path.parts[0] not in apps:
continue # skip uninteresting apps
for filename in files:
file_path = project_path / filename
if not any(
file_path.match(pat) for pat in settings.TEST_TEMPLATE_IGNORE
):
templates.add(relative_path / filename)
_all_templates = [str(t) for t in templates]
return _all_templates


def save_test_results(failures, test_labels):
# Record the test result in a file, in order to be able to check the
# results and avoid re-running tests if we've already run them with OK
Expand Down
17 changes: 10 additions & 7 deletions ietf/utils/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from fnmatch import fnmatch
from importlib import import_module
from textwrap import dedent
from tempfile import mkdtemp
Expand Down Expand Up @@ -320,7 +319,7 @@ class TemplateChecksTestCase(TestCase):
def setUp(self):
super().setUp()
set_coverage_checking(False)
self.paths = list(get_template_paths())
self.paths = get_template_paths() # already filtered ignores
self.paths.sort()
for path in self.paths:
try:
Expand All @@ -335,11 +334,7 @@ def tearDown(self):
def test_parse_templates(self):
errors = []
for path in self.paths:
for pattern in settings.TEST_TEMPLATE_IGNORE:
if fnmatch(path, pattern):
continue
if not path in self.templates:

if path not in self.templates:
try:
get_template(path)
except Exception as e:
Expand Down Expand Up @@ -709,6 +704,14 @@ def test_render_author_name(self):
)),
"Joanna Q. Public",
)
self.assertEqual(
XMLDraft.render_author_name(lxml.etree.Element(
"author",
fullname=chr(340)+"ich",
asciiFullname="Rich UTF-8",
)),
chr(340)+"ich (Rich UTF-8)",
)
self.assertEqual(
XMLDraft.render_author_name(lxml.etree.Element(
"author",
Expand Down
6 changes: 6 additions & 0 deletions ietf/utils/xmldraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ def render_author_name(author_elt):
# Use fullname attribute, if present
fullname = author_elt.attrib.get("fullname", "").strip()
if fullname:
# If any 8bit chars in the fullname, try to append the author's
# name in ascii.
if any([x >= 0x80 for x in fullname.encode('utf8')]):
asciifullname = author_elt.attrib.get("asciiFullname", "").strip()
if asciifullname:
fullname = fullname + ' (' + asciifullname + ')'
return fullname
surname = author_elt.attrib.get("surname", "").strip()
initials = author_elt.attrib.get("initials", "").strip()
Expand Down
Loading