mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-01-23 02:35:14 +00:00
Enhancement: Sort groups during xc_get_live_categories in the order that they first appear in the channel list (lowest channel number)
This commit is contained in:
parent
2042274f10
commit
423c56f582
1 changed files with 4 additions and 3 deletions
|
|
@ -1712,6 +1712,7 @@ def xc_xmltv(request):
|
|||
|
||||
|
||||
def xc_get_live_categories(user):
|
||||
from django.db.models import Min
|
||||
response = []
|
||||
|
||||
if user.user_level == 0:
|
||||
|
|
@ -1722,7 +1723,7 @@ def xc_get_live_categories(user):
|
|||
# No profile filtering - user sees all channel groups
|
||||
channel_groups = ChannelGroup.objects.filter(
|
||||
channels__isnull=False, channels__user_level__lte=user.user_level
|
||||
).distinct().order_by(Lower("name"))
|
||||
).distinct().annotate(min_channel_number=Min('channels__channel_number')).order_by('min_channel_number')
|
||||
else:
|
||||
# User has specific limited profiles assigned
|
||||
filters = {
|
||||
|
|
@ -1730,11 +1731,11 @@ def xc_get_live_categories(user):
|
|||
"channels__user_level": 0,
|
||||
"channels__channelprofilemembership__channel_profile__in": user.channel_profiles.all()
|
||||
}
|
||||
channel_groups = ChannelGroup.objects.filter(**filters).distinct().order_by(Lower("name"))
|
||||
channel_groups = ChannelGroup.objects.filter(**filters).distinct().annotate(min_channel_number=Min('channels__channel_number')).order_by('min_channel_number')
|
||||
else:
|
||||
channel_groups = ChannelGroup.objects.filter(
|
||||
channels__isnull=False, channels__user_level__lte=user.user_level
|
||||
).distinct().order_by(Lower("name"))
|
||||
).distinct().annotate(min_channel_number=Min('channels__channel_number')).order_by('min_channel_number')
|
||||
|
||||
for group in channel_groups:
|
||||
response.append(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue