feat(external-data): add information security registry entries endpoint
This commit is contained in:
@@ -131,6 +131,7 @@ OPENAPI_TAG_BY_PATH_PREFIX = OrderedDict(
|
||||
("/api/v1/prosecutor-checks/", "Внешние данные"),
|
||||
("/api/v1/public-procurements/", "Внешние данные"),
|
||||
("/api/v1/arbitration-cases/", "Внешние данные"),
|
||||
("/api/v1/information-security-registry-entries/", "Внешние данные"),
|
||||
("/api/v1/registers/", "Реестры"),
|
||||
("/api/v1/forms/f1/", "Форма Ф-1"),
|
||||
("/api/v1/forms/f2/", "Форма Ф-2"),
|
||||
|
||||
@@ -6,12 +6,14 @@ from apps.external_data.models import (
|
||||
IndustrialProduct,
|
||||
ProsecutorCheck,
|
||||
PublicProcurement,
|
||||
InformationSecurityRegistryEntry,
|
||||
)
|
||||
from apps.external_data.serializers import (
|
||||
ArbitrationCaseSerializer,
|
||||
IndustrialProductSerializer,
|
||||
ProsecutorCheckSerializer,
|
||||
PublicProcurementSerializer,
|
||||
InformationSecurityRegistryEntrySerializer,
|
||||
)
|
||||
from django_filters import rest_framework as filters
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
@@ -68,6 +70,15 @@ class ArbitrationCaseFilter(filters.FilterSet):
|
||||
]
|
||||
|
||||
|
||||
class InformationSecurityRegistryEntryFilter(filters.FilterSet):
|
||||
organization = filters.UUIDFilter(field_name="organization_id")
|
||||
presence_status = filters.CharFilter(lookup_expr="exact")
|
||||
|
||||
class Meta:
|
||||
model = InformationSecurityRegistryEntry
|
||||
fields = ["organization", "presence_status"]
|
||||
|
||||
|
||||
class IndustrialProductViewSet(ClassicReadOnlyViewSet[IndustrialProduct]):
|
||||
queryset = IndustrialProduct.objects.select_related("organization").all()
|
||||
serializer_class = IndustrialProductSerializer
|
||||
@@ -106,3 +117,15 @@ class ArbitrationCaseViewSet(ClassicReadOnlyViewSet[ArbitrationCase]):
|
||||
search_fields = ["case_number", "court_name"]
|
||||
ordering_fields = ["decision_date", "created_at"]
|
||||
ordering = ["-decision_date"]
|
||||
|
||||
|
||||
class InformationSecurityRegistryEntryViewSet(
|
||||
ClassicReadOnlyViewSet[InformationSecurityRegistryEntry]
|
||||
):
|
||||
queryset = InformationSecurityRegistryEntry.objects.select_related("organization").all()
|
||||
serializer_class = InformationSecurityRegistryEntrySerializer
|
||||
permission_classes = [IsAuthenticated]
|
||||
filterset_class = InformationSecurityRegistryEntryFilter
|
||||
search_fields = ["registry_name", "entry_number"]
|
||||
ordering_fields = ["issued_at", "expires_at", "created_at"]
|
||||
ordering = ["-issued_at"]
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
# Generated by Django 3.2.25 on 2026-04-14 08:59
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('organization', '0003_auto_20260407_1326'),
|
||||
('external_data', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='InformationSecurityRegistryEntry',
|
||||
fields=[
|
||||
('created_at', models.DateTimeField(auto_now_add=True, db_index=True, help_text='Дата и время создания записи', verbose_name='создано')),
|
||||
('updated_at', models.DateTimeField(auto_now=True, help_text='Дата и время последнего обновления', verbose_name='обновлено')),
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('registry_name', models.CharField(db_index=True, max_length=255, verbose_name='название реестра')),
|
||||
('presence_status', models.CharField(choices=[('present', 'В реестре'), ('absent', 'Не в реестре')], db_index=True, max_length=16, verbose_name='статус присутствия')),
|
||||
('entry_number', models.CharField(blank=True, default='', max_length=64, verbose_name='регистрационный номер')),
|
||||
('issued_at', models.DateField(blank=True, null=True, verbose_name='дата выдачи')),
|
||||
('expires_at', models.DateField(blank=True, null=True, verbose_name='дата окончания')),
|
||||
('organization', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='information_security_registry_entries', to='organization.organization', verbose_name='организация')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'запись реестра безопасности',
|
||||
'verbose_name_plural': 'записи реестра безопасности',
|
||||
'ordering': ['registry_name', '-issued_at'],
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -110,3 +110,41 @@ class ArbitrationCase(UUIDPrimaryKeyMixin, TimestampMixin, models.Model):
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.case_number} ({self.organization_id})"
|
||||
|
||||
|
||||
class InformationSecurityRegistryEntry(UUIDPrimaryKeyMixin, TimestampMixin, models.Model):
|
||||
class PresenceStatus(models.TextChoices):
|
||||
PRESENT = "present", _("В реестре")
|
||||
ABSENT = "absent", _("Не в реестре")
|
||||
|
||||
organization = models.ForeignKey(
|
||||
Organization,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="information_security_registry_entries",
|
||||
verbose_name=_("организация"),
|
||||
)
|
||||
registry_name = models.CharField(
|
||||
_("название реестра"), max_length=255, db_index=True
|
||||
)
|
||||
presence_status = models.CharField(
|
||||
_("статус присутствия"),
|
||||
max_length=16,
|
||||
choices=PresenceStatus.choices,
|
||||
db_index=True,
|
||||
)
|
||||
entry_number = models.CharField(
|
||||
_("регистрационный номер"),
|
||||
max_length=64,
|
||||
blank=True,
|
||||
default="",
|
||||
)
|
||||
issued_at = models.DateField(_("дата выдачи"), null=True, blank=True)
|
||||
expires_at = models.DateField(_("дата окончания"), null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("запись реестра безопасности")
|
||||
verbose_name_plural = _("записи реестра безопасности")
|
||||
ordering = ["registry_name", "-issued_at"]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.registry_name} ({self.organization_id})"
|
||||
|
||||
@@ -5,6 +5,7 @@ from apps.external_data.models import (
|
||||
IndustrialProduct,
|
||||
ProsecutorCheck,
|
||||
PublicProcurement,
|
||||
InformationSecurityRegistryEntry,
|
||||
)
|
||||
from rest_framework import serializers
|
||||
|
||||
@@ -75,3 +76,19 @@ class ArbitrationCaseSerializer(serializers.ModelSerializer):
|
||||
"status",
|
||||
"decision_date",
|
||||
]
|
||||
|
||||
|
||||
class InformationSecurityRegistryEntrySerializer(serializers.ModelSerializer):
|
||||
organization = serializers.UUIDField(source="organization_id", read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = InformationSecurityRegistryEntry
|
||||
fields = [
|
||||
"id",
|
||||
"organization",
|
||||
"registry_name",
|
||||
"presence_status",
|
||||
"entry_number",
|
||||
"issued_at",
|
||||
"expires_at",
|
||||
]
|
||||
|
||||
@@ -5,6 +5,7 @@ from apps.external_data.api import (
|
||||
IndustrialProductViewSet,
|
||||
ProsecutorCheckViewSet,
|
||||
PublicProcurementViewSet,
|
||||
InformationSecurityRegistryEntryViewSet,
|
||||
)
|
||||
from django.urls import include, path
|
||||
from rest_framework.routers import DefaultRouter
|
||||
@@ -24,6 +25,11 @@ router.register(
|
||||
router.register(
|
||||
"arbitration-cases", ArbitrationCaseViewSet, basename="arbitration-cases"
|
||||
)
|
||||
router.register(
|
||||
"information-security-registry-entries",
|
||||
InformationSecurityRegistryEntryViewSet,
|
||||
basename="information-security-registry-entries",
|
||||
)
|
||||
|
||||
urlpatterns = [
|
||||
path("", include(router.urls)),
|
||||
|
||||
Reference in New Issue
Block a user