mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-21 01:05:30 +00:00
fixed m3u accounts not saving
This commit is contained in:
parent
90b4d05cd0
commit
319481f7d1
2 changed files with 1 additions and 34 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue