mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-08-02 14:52:15 +00:00
fixed channel creation from stream
This commit is contained in:
parent
cb18c4266c
commit
8e6f8d59e0
1 changed files with 3 additions and 3 deletions
|
|
@ -174,14 +174,14 @@ class ChannelSerializer(serializers.ModelSerializer):
|
|||
return StreamSerializer(obj.streams.all().order_by('channelstream__order'), many=True).data
|
||||
|
||||
def create(self, validated_data):
|
||||
stream_ids = validated_data.pop('streams', [])
|
||||
streams = validated_data.pop('streams', [])
|
||||
channel_number = validated_data.pop('channel_number', Channel.get_next_available_channel_number())
|
||||
validated_data["channel_number"] = channel_number
|
||||
channel = Channel.objects.create(**validated_data)
|
||||
|
||||
# Add streams in the specified order
|
||||
for index, stream_id in enumerate(stream_ids):
|
||||
ChannelStream.objects.create(channel=channel, stream_id=stream_id, order=index)
|
||||
for index, stream in enumerate(streams):
|
||||
ChannelStream.objects.create(channel=channel, stream_id=stream.id, order=index)
|
||||
|
||||
return channel
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue