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
7 changes: 3 additions & 4 deletions ietf/api/views_rpc.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Copyright The IETF Trust 2023-2025, All Rights Reserved
# Copyright The IETF Trust 2023-2026, All Rights Reserved
import shutil
from pathlib import Path
from tempfile import TemporaryDirectory

from django.conf import settings
from django.core.files.uploadedfile import UploadedFile
from drf_spectacular.utils import OpenApiParameter
from rest_framework import mixins, parsers, serializers, viewsets, status
from rest_framework.decorators import action
Expand Down Expand Up @@ -392,7 +391,7 @@ def post(self, request):
)
serializer.is_valid(raise_exception=True)
rfc = serializer.validated_data["rfc"]
uploaded_files: list[UploadedFile] = serializer.validated_data["contents"]
uploaded_files = serializer.validated_data["contents"] # list[UploadedFile]
replace = serializer.validated_data["replace"]
dest_stem = f"rfc{rfc.rfc_number}"

Expand All @@ -413,7 +412,7 @@ def post(self, request):
with TemporaryDirectory() as tempdir:
# Save files in a temporary directory. Use the uploaded filename
# extensions to identify files, but ignore the stems and generate our own.
files_to_move: list[Path] = []
files_to_move = [] # list[Path]
tmpfile_stem = Path(tempdir) / dest_stem
for upfile in uploaded_files:
uploaded_filename = Path(upfile.name) # name supplied by request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Migration(migrations.Migration):
field=models.CharField(
max_length=255,
validators=[
django.core.validators.ProhibitNullCharactersValidator,
django.core.validators.ProhibitNullCharactersValidator, # type:ignore
django.core.validators.RegexValidator(
message="Please enter a string without control characters.",
regex="^[^\x01-\x1f]*$",
Expand All @@ -30,7 +30,7 @@ class Migration(migrations.Migration):
field=models.CharField(
max_length=255,
validators=[
django.core.validators.ProhibitNullCharactersValidator,
django.core.validators.ProhibitNullCharactersValidator, # type:ignore
django.core.validators.RegexValidator(
message="Please enter a string without control characters.",
regex="^[^\x01-\x1f]*$",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright The IETF Trust 2026, All Rights Reserved

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("doc", "0029_editedrfcauthorsdocevent"),
]

operations = [
migrations.AlterField(
model_name="dochistory",
name="title",
field=models.CharField(
max_length=255,
validators=[
django.core.validators.ProhibitNullCharactersValidator(),
django.core.validators.RegexValidator(
message="Please enter a string without control characters.",
regex="^[^\x01-\x1f]*$",
),
],
),
),
migrations.AlterField(
model_name="document",
name="title",
field=models.CharField(
max_length=255,
validators=[
django.core.validators.ProhibitNullCharactersValidator(),
django.core.validators.RegexValidator(
message="Please enter a string without control characters.",
regex="^[^\x01-\x1f]*$",
),
],
),
),
]
4 changes: 2 additions & 2 deletions ietf/doc/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright The IETF Trust 2010-2025, All Rights Reserved
# Copyright The IETF Trust 2010-2026, All Rights Reserved
# -*- coding: utf-8 -*-


Expand Down Expand Up @@ -115,7 +115,7 @@ class DocumentInfo(models.Model):
title = models.CharField(
max_length=255,
validators=[
ProhibitNullCharactersValidator,
ProhibitNullCharactersValidator(),
validate_no_control_chars,
],
)
Expand Down
15 changes: 9 additions & 6 deletions ietf/doc/serializers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Copyright The IETF Trust 2024-2025, All Rights Reserved
# Copyright The IETF Trust 2024-2026, All Rights Reserved
"""django-rest-framework serializers"""

from dataclasses import dataclass
from typing import Literal, ClassVar

from django.db.models.manager import BaseManager
from django.db.models.query import QuerySet
from drf_spectacular.utils import extend_schema_field
from rest_framework import serializers

Expand Down Expand Up @@ -134,7 +135,7 @@ def name(self):
def from_document(cls, doc: Document):
"""Decide the status that applies to a document"""
return cls(
slug=(cls.stdlevelname_slug_map.get(doc.std_level.slug, "unknown")),
slug=(cls.stdlevelname_slug_map.get(doc.std_level.slug, "unkn")),
)

@classmethod
Expand Down Expand Up @@ -237,13 +238,15 @@ class Meta:
"errata",
]


@extend_schema_field(RfcAuthorSerializer(many=True))
def get_authors(self, doc: Document):
# If doc has any RfcAuthors, use those, otherwise fall back to DocumentAuthors
if doc.rfcauthor_set.exists():
author_queryset = doc.rfcauthor_set.all()
else:
author_queryset = doc.documentauthor_set.all()
author_queryset: QuerySet[RfcAuthor] | QuerySet[DocumentAuthor] = (
doc.rfcauthor_set.all()
if doc.rfcauthor_set.exists()
else doc.documentauthor_set.all()
)
# RfcAuthorSerializer can deal with DocumentAuthor instances
return RfcAuthorSerializer(
instance=author_queryset,
Expand Down
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

ignore_missing_imports = True

# allow PEP 695 type aliases (flag needed until mypy >= 1.13)
enable_incomplete_feature = NewGenericSyntax

plugins =
mypy_django_plugin.main

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ markdown>=3.8.0
types-markdown>=3.8.0
mock>=5.2.0 # should replace with unittest.mock and remove dependency
types-mock>=5.2.0
mypy~=1.7.0 # Version requirements determined by django-stubs.
mypy~=1.11.2 # Version requirements loosely determined by django-stubs.
oic>=1.7.0 # Used only by tests
opentelemetry-sdk>=1.38.0
opentelemetry-instrumentation-django>=0.59b0
Expand Down