feat(admin): expand exchange admin and unify admin UX
Some checks failed
CI/CD Pipeline / Code Quality Checks (pull_request) Failing after 2m39s
CI/CD Pipeline / Run Tests (pull_request) Successful in 3m0s
CI/CD Pipeline / Run API Inventory E2E Tests (pull_request) Successful in 35s
CI/CD Pipeline / Telegram Notify Success (pull_request) Has been skipped
Some checks failed
CI/CD Pipeline / Code Quality Checks (pull_request) Failing after 2m39s
CI/CD Pipeline / Run Tests (pull_request) Successful in 3m0s
CI/CD Pipeline / Run API Inventory E2E Tests (pull_request) Successful in 35s
CI/CD Pipeline / Telegram Notify Success (pull_request) Has been skipped
This commit is contained in:
@@ -171,41 +171,52 @@ class ParserLoadLogAdmin(admin.ModelAdmin):
|
||||
|
||||
list_display = [
|
||||
"id",
|
||||
"source",
|
||||
"batch_id",
|
||||
"source_title",
|
||||
"status_badge",
|
||||
"records_count",
|
||||
"created_at",
|
||||
]
|
||||
list_filter = ["source", "status", "created_at"]
|
||||
search_fields = ["batch_id", "error_message"]
|
||||
search_fields = ["error_message"]
|
||||
readonly_fields = ["created_at", "updated_at"]
|
||||
ordering = ["-created_at"]
|
||||
list_per_page = 50
|
||||
date_hierarchy = "created_at"
|
||||
|
||||
fieldsets = (
|
||||
("Основное", {"fields": ("source", "batch_id", "status")}),
|
||||
("Основное", {"fields": ("source", "status")}),
|
||||
("Результат", {"fields": ("records_count", "error_message")}),
|
||||
("Даты", {"fields": ("created_at", "updated_at"), "classes": ("collapse",)}),
|
||||
(
|
||||
"Служебное",
|
||||
{
|
||||
"fields": ("batch_id", "created_at", "updated_at"),
|
||||
"classes": ("collapse",),
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
def source_title(self, obj):
|
||||
"""Полное название источника."""
|
||||
return obj.get_source_display()
|
||||
|
||||
source_title.short_description = "Источник"
|
||||
source_title.admin_order_field = "source"
|
||||
|
||||
def status_badge(self, obj):
|
||||
"""Цветной бейдж статуса."""
|
||||
colors = {
|
||||
"success": "#28a745",
|
||||
"failed": "#dc3545",
|
||||
"in_progress": "#ffc107",
|
||||
"pending": "#6c757d",
|
||||
ParserLoadLog.Status.SUCCESS: "#28a745",
|
||||
ParserLoadLog.Status.FAILED: "#dc3545",
|
||||
ParserLoadLog.Status.IN_PROGRESS: "#ffc107",
|
||||
ParserLoadLog.Status.PENDING: "#6c757d",
|
||||
ParserLoadLog.Status.SKIPPED: "#17a2b8",
|
||||
}
|
||||
color = colors.get(obj.status, "#6c757d")
|
||||
return format_html(
|
||||
'<span style="color: white; background: {}; padding: 3px 10px; '
|
||||
'border-radius: 3px;">{}</span>',
|
||||
color,
|
||||
obj.get_status_display()
|
||||
if hasattr(obj, "get_status_display")
|
||||
else obj.status,
|
||||
obj.get_status_display(),
|
||||
)
|
||||
|
||||
status_badge.short_description = "Статус"
|
||||
@@ -917,7 +928,7 @@ class FinancialReportAdmin(admin.ModelAdmin):
|
||||
context = {
|
||||
**self.admin_site.each_context(request),
|
||||
"opts": self.model._meta,
|
||||
"title": "Загрузка Excel отчетности ФНС",
|
||||
"title": "Загрузка Excel бухгалтерской отчетности ФНС",
|
||||
"changelist_url": changelist_url,
|
||||
}
|
||||
return TemplateResponse(
|
||||
@@ -961,7 +972,7 @@ class FinancialReportAdmin(admin.ModelAdmin):
|
||||
context = {
|
||||
**self.admin_site.each_context(request),
|
||||
"opts": self.model._meta,
|
||||
"title": "Загрузка ZIP отчетности ФНС",
|
||||
"title": "Загрузка ZIP бухгалтерской отчетности ФНС",
|
||||
"changelist_url": changelist_url,
|
||||
}
|
||||
return TemplateResponse(
|
||||
|
||||
Reference in New Issue
Block a user