From 3949a2ed5c06bed19009108ee58aa369fbb4c947 Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Tue, 15 Jul 2025 22:00:18 -0500 Subject: [PATCH] Fixes cleanup unused logos. --- apps/channels/api_urls.py | 3 ++- apps/channels/api_views.py | 14 +++++++++++--- frontend/src/api.js | 3 --- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/apps/channels/api_urls.py b/apps/channels/api_urls.py index 425a6792..469ec773 100644 --- a/apps/channels/api_urls.py +++ b/apps/channels/api_urls.py @@ -7,6 +7,7 @@ from .api_views import ( BulkDeleteStreamsAPIView, BulkDeleteChannelsAPIView, BulkDeleteLogosAPIView, + CleanupUnusedLogosAPIView, LogoViewSet, ChannelProfileViewSet, UpdateChannelMembershipAPIView, @@ -30,7 +31,7 @@ urlpatterns = [ path('streams/bulk-delete/', BulkDeleteStreamsAPIView.as_view(), name='bulk_delete_streams'), path('channels/bulk-delete/', BulkDeleteChannelsAPIView.as_view(), name='bulk_delete_channels'), path('logos/bulk-delete/', BulkDeleteLogosAPIView.as_view(), name='bulk_delete_logos'), - path('logos/cleanup/', BulkDeleteLogosAPIView.as_view(), {'action': 'cleanup_unused_logos'}, name='cleanup_unused_logos'), + path('logos/cleanup/', CleanupUnusedLogosAPIView.as_view(), name='cleanup_unused_logos'), path('channels//streams/', GetChannelStreamsAPIView.as_view(), name='get_channel_streams'), path('profiles//channels//', UpdateChannelMembershipAPIView.as_view(), name='update_channel_membership'), path('profiles//channels/bulk-update/', BulkUpdateChannelMembershipAPIView.as_view(), name='bulk_update_channel_membership'), diff --git a/apps/channels/api_views.py b/apps/channels/api_views.py index 9a04fed4..0956da11 100644 --- a/apps/channels/api_views.py +++ b/apps/channels/api_views.py @@ -1074,13 +1074,21 @@ class BulkDeleteLogosAPIView(APIView): status=status.HTTP_204_NO_CONTENT ) + +class CleanupUnusedLogosAPIView(APIView): + def get_permissions(self): + try: + return [ + perm() for perm in permission_classes_by_method[self.request.method] + ] + except KeyError: + return [Authenticated()] + @swagger_auto_schema( - method="post", operation_description="Delete all logos that are not used by any channels", responses={200: "Cleanup completed"}, ) - @action(detail=False, methods=["post"], url_path="cleanup") - def cleanup_unused_logos(self, request): + def post(self, request): """Delete all logos with no channel associations""" unused_logos = Logo.objects.filter(channels__isnull=True) deleted_count = unused_logos.count() diff --git a/frontend/src/api.js b/frontend/src/api.js index c63b73fb..fe5deae3 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -1332,9 +1332,6 @@ export default class API { method: 'POST', }); - // Refresh logos to update the UI - await this.fetchLogos(); - return response; } catch (e) { errorNotification('Failed to cleanup unused logos', e);