Add KYC monitoring model with shared base
All checks were successful
Build Docker Image / build (push) Successful in 1m37s
All checks were successful
Build Docker Image / build (push) Successful in 1m37s
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from django.contrib import admin, messages
|
||||
from .models import KYCRequest, KYCRequestRussia
|
||||
from .models import KYCRequest, KYCMonitoring, KYCRequestRussia
|
||||
from .temporal import KycWorkflowClient
|
||||
|
||||
|
||||
@@ -40,6 +40,31 @@ class KYCRequestAdmin(admin.ModelAdmin):
|
||||
)
|
||||
|
||||
|
||||
@admin.register(KYCMonitoring)
|
||||
class KYCMonitoringAdmin(admin.ModelAdmin):
|
||||
list_display = ('uuid', 'user_id', 'team_name', 'country_code', 'workflow_status', 'contact_person', 'created_at')
|
||||
list_filter = ('workflow_status', 'country_code', 'created_at')
|
||||
search_fields = ('uuid', 'user_id', 'team_name', 'contact_email', 'contact_person')
|
||||
readonly_fields = ('uuid', 'created_at', 'updated_at', 'content_type', 'object_id')
|
||||
ordering = ('-created_at',)
|
||||
|
||||
fieldsets = (
|
||||
('Основная информация', {
|
||||
'fields': ('uuid', 'user_id', 'team_name', 'country_code', 'workflow_status')
|
||||
}),
|
||||
('Контактная информация', {
|
||||
'fields': ('contact_person', 'contact_email', 'contact_phone')
|
||||
}),
|
||||
('Детали страны (GenericFK)', {
|
||||
'fields': ('content_type', 'object_id'),
|
||||
'classes': ('collapse',)
|
||||
}),
|
||||
('Статус', {
|
||||
'fields': ('score', 'approved_by', 'approved_at', 'created_at', 'updated_at')
|
||||
}),
|
||||
)
|
||||
|
||||
|
||||
@admin.register(KYCRequestRussia)
|
||||
class KYCRequestRussiaAdmin(admin.ModelAdmin):
|
||||
list_display = ('id', 'company_name', 'inn', 'ogrn')
|
||||
|
||||
@@ -4,8 +4,9 @@ from django.contrib.contenttypes.models import ContentType
|
||||
import uuid
|
||||
|
||||
|
||||
class KYCRequest(models.Model):
|
||||
"""Главная модель KYC заявки. Ссылается на детали страны через ContentType."""
|
||||
class AbstractKycBase(models.Model):
|
||||
"""Общая база для KYC сущностей с идентичными полями."""
|
||||
|
||||
WORKFLOW_STATUS_CHOICES = [
|
||||
('pending', 'Ожидает обработки'),
|
||||
('active', 'Активен'),
|
||||
@@ -44,6 +45,23 @@ class KYCRequest(models.Model):
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
||||
class KYCRequest(AbstractKycBase):
|
||||
"""Главная модель KYC заявки. Ссылается на детали страны через ContentType."""
|
||||
|
||||
content_type = models.ForeignKey(
|
||||
ContentType,
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
blank=True,
|
||||
related_name='kyc_requests'
|
||||
)
|
||||
object_id = models.PositiveIntegerField(null=True, blank=True)
|
||||
country_details = GenericForeignKey('content_type', 'object_id')
|
||||
|
||||
class Meta:
|
||||
db_table = 'kyc_requests'
|
||||
|
||||
@@ -57,6 +75,26 @@ class KYCRequest(models.Model):
|
||||
return {}
|
||||
|
||||
|
||||
class KYCMonitoring(AbstractKycBase):
|
||||
"""KYC мониторинг (копия заявки для долгосрочного наблюдения)."""
|
||||
|
||||
content_type = models.ForeignKey(
|
||||
ContentType,
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
blank=True,
|
||||
related_name='kyc_monitoring'
|
||||
)
|
||||
object_id = models.PositiveIntegerField(null=True, blank=True)
|
||||
country_details = GenericForeignKey('content_type', 'object_id')
|
||||
|
||||
class Meta:
|
||||
db_table = 'kyc_monitoring'
|
||||
|
||||
def __str__(self):
|
||||
return f"KYC Monitoring {self.user_id} - {self.workflow_status}"
|
||||
|
||||
|
||||
class KYCRequestRussia(models.Model):
|
||||
"""Детали KYC для России. Отдельная модель без наследования."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user