bukkl delte conte
This commit is contained in:
@@ -756,6 +756,22 @@ class ContentViewSet(SiteSectorModelViewSet):
|
|||||||
else:
|
else:
|
||||||
serializer.save()
|
serializer.save()
|
||||||
|
|
||||||
|
@action(detail=False, methods=['POST'], url_path='bulk_delete', url_name='bulk_delete')
|
||||||
|
def bulk_delete(self, request):
|
||||||
|
"""Bulk delete content"""
|
||||||
|
ids = request.data.get('ids', [])
|
||||||
|
if not ids:
|
||||||
|
return error_response(
|
||||||
|
error='No IDs provided',
|
||||||
|
status_code=status.HTTP_400_BAD_REQUEST,
|
||||||
|
request=request
|
||||||
|
)
|
||||||
|
|
||||||
|
queryset = self.get_queryset()
|
||||||
|
deleted_count, _ = queryset.filter(id__in=ids).delete()
|
||||||
|
|
||||||
|
return success_response(data={'deleted_count': deleted_count}, request=request)
|
||||||
|
|
||||||
@action(detail=True, methods=['post'], url_path='publish', url_name='publish', permission_classes=[IsAuthenticatedAndActive, IsEditorOrAbove])
|
@action(detail=True, methods=['post'], url_path='publish', url_name='publish', permission_classes=[IsAuthenticatedAndActive, IsEditorOrAbove])
|
||||||
def publish(self, request, pk=None):
|
def publish(self, request, pk=None):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import {
|
|||||||
Content as ContentType,
|
Content as ContentType,
|
||||||
ContentFilters,
|
ContentFilters,
|
||||||
generateImagePrompts,
|
generateImagePrompts,
|
||||||
|
deleteContent,
|
||||||
|
bulkDeleteContent,
|
||||||
} from '../../services/api';
|
} from '../../services/api';
|
||||||
import { optimizerApi } from '../../api/optimizer.api';
|
import { optimizerApi } from '../../api/optimizer.api';
|
||||||
import { useNavigate } from 'react-router';
|
import { useNavigate } from 'react-router';
|
||||||
@@ -210,6 +212,17 @@ export default function Content() {
|
|||||||
}
|
}
|
||||||
}, [toast, progressModal, loadContent, navigate]);
|
}, [toast, progressModal, loadContent, navigate]);
|
||||||
|
|
||||||
|
const handleDelete = useCallback(async (id: number) => {
|
||||||
|
await deleteContent(id);
|
||||||
|
loadContent();
|
||||||
|
}, [loadContent]);
|
||||||
|
|
||||||
|
const handleBulkDelete = useCallback(async (ids: number[]) => {
|
||||||
|
const result = await bulkDeleteContent(ids);
|
||||||
|
loadContent();
|
||||||
|
return result;
|
||||||
|
}, [loadContent]);
|
||||||
|
|
||||||
// Writer navigation tabs
|
// Writer navigation tabs
|
||||||
const writerTabs = [
|
const writerTabs = [
|
||||||
{ label: 'Tasks', path: '/writer/tasks', icon: <TaskIcon /> },
|
{ label: 'Tasks', path: '/writer/tasks', icon: <TaskIcon /> },
|
||||||
@@ -265,6 +278,8 @@ export default function Content() {
|
|||||||
}}
|
}}
|
||||||
headerMetrics={headerMetrics}
|
headerMetrics={headerMetrics}
|
||||||
onRowAction={handleRowAction}
|
onRowAction={handleRowAction}
|
||||||
|
onDelete={handleDelete}
|
||||||
|
onBulkDelete={handleBulkDelete}
|
||||||
getItemDisplayName={(row: ContentType) => row.title || `Content #${row.id}`}
|
getItemDisplayName={(row: ContentType) => row.title || `Content #${row.id}`}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import {
|
|||||||
ContentFilters,
|
ContentFilters,
|
||||||
fetchAPI,
|
fetchAPI,
|
||||||
fetchWordPressStatus,
|
fetchWordPressStatus,
|
||||||
|
deleteContent,
|
||||||
|
bulkDeleteContent,
|
||||||
} from '../../services/api';
|
} from '../../services/api';
|
||||||
import { useNavigate } from 'react-router';
|
import { useNavigate } from 'react-router';
|
||||||
import { useToast } from '../../components/ui/toast/ToastContainer';
|
import { useToast } from '../../components/ui/toast/ToastContainer';
|
||||||
@@ -190,6 +192,17 @@ export default function Published() {
|
|||||||
}
|
}
|
||||||
}, [toast, loadContent, navigate]);
|
}, [toast, loadContent, navigate]);
|
||||||
|
|
||||||
|
const handleDelete = useCallback(async (id: number) => {
|
||||||
|
await deleteContent(id);
|
||||||
|
loadContent();
|
||||||
|
}, [loadContent]);
|
||||||
|
|
||||||
|
const handleBulkDelete = useCallback(async (ids: number[]) => {
|
||||||
|
const result = await bulkDeleteContent(ids);
|
||||||
|
loadContent();
|
||||||
|
return result;
|
||||||
|
}, [loadContent]);
|
||||||
|
|
||||||
// Bulk WordPress publish
|
// Bulk WordPress publish
|
||||||
const handleBulkPublishWordPress = useCallback(async (ids: string[]) => {
|
const handleBulkPublishWordPress = useCallback(async (ids: string[]) => {
|
||||||
try {
|
try {
|
||||||
@@ -347,6 +360,8 @@ export default function Published() {
|
|||||||
}}
|
}}
|
||||||
headerMetrics={headerMetrics}
|
headerMetrics={headerMetrics}
|
||||||
onRowAction={handleRowAction}
|
onRowAction={handleRowAction}
|
||||||
|
onDelete={handleDelete}
|
||||||
|
onBulkDelete={handleBulkDelete}
|
||||||
onBulkAction={handleBulkAction}
|
onBulkAction={handleBulkAction}
|
||||||
onBulkUpdateStatus={handleBulkUpdateStatus}
|
onBulkUpdateStatus={handleBulkUpdateStatus}
|
||||||
onBulkExport={handleBulkExport}
|
onBulkExport={handleBulkExport}
|
||||||
|
|||||||
Reference in New Issue
Block a user