fix: привязать пользователя к заявке на модерацию и вывести в админке
This commit is contained in:
1 parent
c681c724a5
commit
8cbf24bc40
4 files changed
+33
-2
No files matched your search
@@ -100,6 +100,7 @@ def _create_seller(request, data, step3):
|
||||
ModerationRequest.objects.create(
|
||||
content_type=ContentType.objects.get_for_model(Brand),
|
||||
object_id=brand.pk,
|
||||
user=user,
|
||||
decision='pending',
|
||||
)
|
||||
AuditLog.objects.create(
|
||||
|
||||
@@ -5,9 +5,12 @@ from .models import AuditLog, ModerationRequest
|
||||
|
||||
@admin.register(ModerationRequest)
|
||||
class ModerationRequestAdmin(admin.ModelAdmin):
|
||||
list_display = ('content_type', 'object_id', 'decision', 'moderator', 'created_at', 'decided_at')
|
||||
list_display = (
|
||||
'content_type', 'object_id', 'user', 'decision',
|
||||
'moderator', 'created_at', 'decided_at',
|
||||
)
|
||||
list_filter = ('decision', 'content_type')
|
||||
search_fields = ('comment',)
|
||||
search_fields = ('comment', 'user__username', 'user__full_name')
|
||||
|
||||
|
||||
@admin.register(AuditLog)
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
# Generated by Django 5.1.15 on 2026-09-23 15:37
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('moderation', '0001_initial'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='moderationrequest',
|
||||
name='user',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='moderation_requests', to=settings.AUTH_USER_MODEL, verbose_name='Пользователь'),
|
||||
),
|
||||
]
|
||||
@@ -20,6 +20,12 @@ class ModerationRequest(models.Model):
|
||||
object_id = models.PositiveIntegerField('ID сущности')
|
||||
entity = GenericForeignKey('content_type', 'object_id')
|
||||
|
||||
user = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL, null=True, blank=True,
|
||||
on_delete=models.SET_NULL, related_name='moderation_requests',
|
||||
verbose_name='Пользователь',
|
||||
)
|
||||
|
||||
decision = models.CharField(
|
||||
'Решение', max_length=20, choices=Decision.choices,
|
||||
default=Decision.PENDING,
|
||||
|
||||
Reference in new issue
Block a user