Compare commits
2 Commits
7e07dc0091
...
f290e5e6a5
| Author | SHA1 | Date | |
|---|---|---|---|
| f290e5e6a5 | |||
|
|
c498cf392d |
@ -76,10 +76,12 @@ class ArticleAdmin(admin.ModelAdmin):
|
||||
|
||||
@admin.register(Comment)
|
||||
class CommentAdmin(admin.ModelAdmin):
|
||||
list_display = ('author_name', 'article', 'is_moderated', 'time_create')
|
||||
list_filter = ('is_moderated', 'time_create')
|
||||
search_fields = ('author_name', 'author_email', 'content')
|
||||
list_display = ('author_name', 'article', 'parent', 'is_moderated', 'time_create')
|
||||
list_filter = ('is_moderated', 'time_create', 'parent')
|
||||
search_fields = ('author_name', 'author_email', 'content', 'parent__author_name')
|
||||
actions = ['approve_comments', 'reject_comments']
|
||||
fields = ('article', 'author_name', 'author_email', 'user', 'parent', 'content', 'is_moderated', 'time_create')
|
||||
readonly_fields = ('time_create',)
|
||||
|
||||
def approve_comments(self, request, queryset):
|
||||
queryset.update(is_moderated=True)
|
||||
|
||||
@ -42,7 +42,6 @@
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
{{ form.parent_id }}
|
||||
<button type="submit" class="btn btn-primary">Отправить</button>
|
||||
</form>
|
||||
{% else %}
|
||||
|
||||
@ -96,6 +96,7 @@ class ArticleDetailView(MenuContextMixin, BreadcrumbMixin, DetailView):
|
||||
def post(self, request, *args, **kwargs):
|
||||
"""Обработка формы комментария."""
|
||||
self.object = self.get_object()
|
||||
print("POST data:", request.POST)
|
||||
|
||||
if not request.user.is_authenticated:
|
||||
messages.error(request, "❌ Только авторизованные пользователи могут оставлять комментарии.")
|
||||
@ -105,6 +106,7 @@ class ArticleDetailView(MenuContextMixin, BreadcrumbMixin, DetailView):
|
||||
if form.is_valid():
|
||||
|
||||
parent_id = form.cleaned_data.get('parent_id')
|
||||
print(f"parent_id from cleaned_data: {parent_id}")
|
||||
parent = None
|
||||
|
||||
if parent_id:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user