diff --git a/apps/m3u/api_views.py b/apps/m3u/api_views.py index 508b6a89..e3d3b9d1 100644 --- a/apps/m3u/api_views.py +++ b/apps/m3u/api_views.py @@ -29,39 +29,6 @@ class M3UAccountViewSet(viewsets.ModelViewSet): serializer_class = M3UAccountSerializer permission_classes = [IsAuthenticated] - def update(self, request, *args, **kwargs): - # Get the M3UAccount instance we're updating - instance = self.get_object() - - # Handle updates to the 'enabled' flag of the related ChannelGroupM3UAccount instances - updates = request.data.get('channel_groups', []) - - for update_data in updates: - channel_group_id = update_data.get('channel_group') - enabled = update_data.get('enabled') - - try: - # Get the specific relationship to update - relationship = ChannelGroupM3UAccount.objects.get( - m3u_account=instance, channel_group_id=channel_group_id - ) - relationship.enabled = enabled - relationship.save() - except ChannelGroupM3UAccount.DoesNotExist: - return Response( - {"error": "ChannelGroupM3UAccount not found for the given M3UAccount and ChannelGroup."}, - status=status.HTTP_400_BAD_REQUEST - ) - - # After updating the ChannelGroupM3UAccount relationships, reload the M3UAccount instance - instance.refresh_from_db() - - refresh_single_m3u_account.delay(instance.id) - - # Serialize and return the updated M3UAccount data - serializer = self.get_serializer(instance) - return Response(serializer.data) - class M3UFilterViewSet(viewsets.ModelViewSet): """Handles CRUD operations for M3U filters""" queryset = M3UFilter.objects.all() diff --git a/apps/m3u/signals.py b/apps/m3u/signals.py index 4e27370e..1a885752 100644 --- a/apps/m3u/signals.py +++ b/apps/m3u/signals.py @@ -24,7 +24,7 @@ def create_or_update_refresh_task(sender, instance, **kwargs): task_name = f"m3u_account-refresh-{instance.id}" interval, _ = IntervalSchedule.objects.get_or_create( - every=24, + every=int(instance.refresh_interval), period=IntervalSchedule.HOURS )