feat: в очереди модерации показать бренд, описание деятельности и ссылку на полную карточку
This commit is contained in:
1 parent
441c9e82cc
commit
970450cce2
1 file changed
+25
-2
@@ -1,4 +1,6 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from django.urls import reverse
|
||||||
|
from django.utils.html import format_html
|
||||||
|
|
||||||
from .models import AuditLog, ModerationRequest
|
from .models import AuditLog, ModerationRequest
|
||||||
|
|
||||||
@@ -6,12 +8,17 @@ from .models import AuditLog, ModerationRequest
|
|||||||
@admin.register(ModerationRequest)
|
@admin.register(ModerationRequest)
|
||||||
class ModerationRequestAdmin(admin.ModelAdmin):
|
class ModerationRequestAdmin(admin.ModelAdmin):
|
||||||
list_display = (
|
list_display = (
|
||||||
'content_type', 'object_id', 'get_user', 'decision',
|
'get_entity_name', 'get_user', 'get_story', 'get_link',
|
||||||
'moderator', 'created_at', 'decided_at',
|
'decision', 'moderator', 'created_at', 'decided_at',
|
||||||
)
|
)
|
||||||
list_filter = ('decision', 'content_type')
|
list_filter = ('decision', 'content_type')
|
||||||
search_fields = ('comment', 'user__username', 'user__full_name')
|
search_fields = ('comment', 'user__username', 'user__full_name')
|
||||||
|
|
||||||
|
@admin.display(description='Сущность')
|
||||||
|
def get_entity_name(self, obj):
|
||||||
|
entity = obj.entity
|
||||||
|
return str(entity) if entity else f'#{obj.object_id}'
|
||||||
|
|
||||||
@admin.display(description='Пользователь')
|
@admin.display(description='Пользователь')
|
||||||
def get_user(self, obj):
|
def get_user(self, obj):
|
||||||
"""Пользователь из поля user, либо выводимый из сущности."""
|
"""Пользователь из поля user, либо выводимый из сущности."""
|
||||||
@@ -27,6 +34,22 @@ class ModerationRequestAdmin(admin.ModelAdmin):
|
|||||||
return entity.brand.user
|
return entity.brand.user
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@admin.display(description='Описание деятельности')
|
||||||
|
def get_story(self, obj):
|
||||||
|
entity = obj.entity
|
||||||
|
story = getattr(entity, 'story', '') or ''
|
||||||
|
return story[:80] + ('…' if len(story) > 80 else '')
|
||||||
|
|
||||||
|
@admin.display(description='Полное описание')
|
||||||
|
def get_link(self, obj):
|
||||||
|
entity = obj.entity
|
||||||
|
if entity is None:
|
||||||
|
return '-'
|
||||||
|
app_label = entity._meta.app_label
|
||||||
|
model_name = entity._meta.model_name
|
||||||
|
url = reverse(f'admin:{app_label}_{model_name}_change', args=[entity.pk])
|
||||||
|
return format_html('<a href="{}">Открыть</a>', url)
|
||||||
|
|
||||||
|
|
||||||
@admin.register(AuditLog)
|
@admin.register(AuditLog)
|
||||||
class AuditLogAdmin(admin.ModelAdmin):
|
class AuditLogAdmin(admin.ModelAdmin):
|
||||||
|
|||||||
Reference in new issue
Block a user