mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-22 09:37:57 +00:00
Merge pull request #93 from MooseyOnTheLoosey/main
Channel Number to Float
This commit is contained in:
commit
baabea5006
4 changed files with 28 additions and 10 deletions
|
|
@ -266,7 +266,7 @@ class ChannelViewSet(viewsets.ModelViewSet):
|
|||
type=openapi.TYPE_INTEGER, description="ID of the stream to link"
|
||||
),
|
||||
"channel_number": openapi.Schema(
|
||||
type=openapi.TYPE_INTEGER,
|
||||
type=openapi.TYPE_NUMBER,
|
||||
description="(Optional) Desired channel number. Must not be in use."
|
||||
),
|
||||
"name": openapi.Schema(
|
||||
|
|
@ -293,9 +293,9 @@ class ChannelViewSet(viewsets.ModelViewSet):
|
|||
|
||||
channel_number = None
|
||||
if 'tvg-chno' in stream_custom_props:
|
||||
channel_number = int(stream_custom_props['tvg-chno'])
|
||||
channel_number = float(stream_custom_props['tvg-chno'])
|
||||
elif 'channel-number' in stream_custom_props:
|
||||
channel_number = int(stream_custom_props['channel-number'])
|
||||
channel_number = float(stream_custom_props['channel-number'])
|
||||
|
||||
if channel_number is None:
|
||||
provided_number = request.data.get('channel_number')
|
||||
|
|
@ -303,7 +303,7 @@ class ChannelViewSet(viewsets.ModelViewSet):
|
|||
channel_number = Channel.get_next_available_channel_number()
|
||||
else:
|
||||
try:
|
||||
channel_number = int(provided_number)
|
||||
channel_number = float(provided_number)
|
||||
except ValueError:
|
||||
return Response({"error": "channel_number must be an integer."}, status=status.HTTP_400_BAD_REQUEST)
|
||||
# If the provided number is already used, return an error.
|
||||
|
|
@ -362,7 +362,7 @@ class ChannelViewSet(viewsets.ModelViewSet):
|
|||
type=openapi.TYPE_INTEGER, description="ID of the stream to link"
|
||||
),
|
||||
"channel_number": openapi.Schema(
|
||||
type=openapi.TYPE_INTEGER,
|
||||
type=openapi.TYPE_NUMBER,
|
||||
description="(Optional) Desired channel number. Must not be in use."
|
||||
),
|
||||
"name": openapi.Schema(
|
||||
|
|
@ -419,9 +419,9 @@ class ChannelViewSet(viewsets.ModelViewSet):
|
|||
|
||||
channel_number = None
|
||||
if 'tvg-chno' in stream_custom_props:
|
||||
channel_number = int(stream_custom_props['tvg-chno'])
|
||||
channel_number = float(stream_custom_props['tvg-chno'])
|
||||
elif 'channel-number' in stream_custom_props:
|
||||
channel_number = int(stream_custom_props['channel-number'])
|
||||
channel_number = float(stream_custom_props['channel-number'])
|
||||
|
||||
# Determine channel number: if provided, use it (if free); else auto assign.
|
||||
if channel_number is None:
|
||||
|
|
@ -430,7 +430,7 @@ class ChannelViewSet(viewsets.ModelViewSet):
|
|||
channel_number = get_auto_number()
|
||||
else:
|
||||
try:
|
||||
channel_number = int(provided_number)
|
||||
channel_number = float(provided_number)
|
||||
except ValueError:
|
||||
errors.append({"item": item, "error": "channel_number must be an integer."})
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 5.1.6 on 2025-05-08 14:05
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('dispatcharr_channels', '0017_alter_channelgroup_name'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='channel',
|
||||
name='channel_number',
|
||||
field=models.FloatField(db_index=True),
|
||||
),
|
||||
]
|
||||
|
|
@ -209,7 +209,7 @@ class ChannelManager(models.Manager):
|
|||
|
||||
|
||||
class Channel(models.Model):
|
||||
channel_number = models.IntegerField()
|
||||
channel_number = models.FloatField(db_index=True)
|
||||
name = models.CharField(max_length=255)
|
||||
logo = models.ForeignKey(
|
||||
'Logo',
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ class BulkChannelProfileMembershipSerializer(serializers.Serializer):
|
|||
#
|
||||
class ChannelSerializer(serializers.ModelSerializer):
|
||||
# Show nested group data, or ID
|
||||
channel_number = serializers.IntegerField(allow_null=True, required=False)
|
||||
channel_number = serializers.FloatField(allow_null=True, required=False)
|
||||
channel_group_id = serializers.PrimaryKeyRelatedField(
|
||||
queryset=ChannelGroup.objects.all(),
|
||||
source="channel_group",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue