dealer can no more be saved -- damned
This commit is contained in:
parent
a5638f0071
commit
765846547d
|
@ -65,15 +65,6 @@ class Station(programs.Nameable):
|
||||||
qs = qs.filter(type = type)
|
qs = qs.filter(type = type)
|
||||||
return [ source.prepare() or source for source in qs ]
|
return [ source.prepare() or source for source in qs ]
|
||||||
|
|
||||||
@property
|
|
||||||
def dealer_sources(self):
|
|
||||||
return self.get_sources(Source.Type.dealer)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def dealer(self):
|
|
||||||
dealers = self.dealer_sources
|
|
||||||
return dealers[0] if dealers else None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def stream_sources(self):
|
def stream_sources(self):
|
||||||
return self.get_sources(type = Source.Type.stream)
|
return self.get_sources(type = Source.Type.stream)
|
||||||
|
@ -91,7 +82,6 @@ class Station(programs.Nameable):
|
||||||
"""
|
"""
|
||||||
List of active outputs
|
List of active outputs
|
||||||
"""
|
"""
|
||||||
print(self.output_set)
|
|
||||||
return [ output for output in self.output_set.filter(active = True) ]
|
return [ output for output in self.output_set.filter(active = True) ]
|
||||||
|
|
||||||
def prepare(self, fetch = True):
|
def prepare(self, fetch = True):
|
||||||
|
@ -106,6 +96,7 @@ class Station(programs.Nameable):
|
||||||
raise ValueError('station be must saved first')
|
raise ValueError('station be must saved first')
|
||||||
|
|
||||||
self.controller = self.plugin.init_station(self)
|
self.controller = self.plugin.init_station(self)
|
||||||
|
self.dealer.prepare()
|
||||||
for source in self.source_set.all():
|
for source in self.source_set.all():
|
||||||
source.prepare()
|
source.prepare()
|
||||||
if fetch:
|
if fetch:
|
||||||
|
@ -115,10 +106,6 @@ class Station(programs.Nameable):
|
||||||
"""
|
"""
|
||||||
Generate default sources for the station and save them.
|
Generate default sources for the station and save them.
|
||||||
"""
|
"""
|
||||||
Source(station = self,
|
|
||||||
type = Source.Type.dealer,
|
|
||||||
name = _('Dealer')).save()
|
|
||||||
|
|
||||||
streams = programs.Program.objects.filter(
|
streams = programs.Program.objects.filter(
|
||||||
active = True, stream__isnull = False
|
active = True, stream__isnull = False
|
||||||
)
|
)
|
||||||
|
@ -131,15 +118,20 @@ class Station(programs.Nameable):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
self.dealer = Source(
|
||||||
|
station = self,
|
||||||
|
name = _('Dealer'),
|
||||||
|
type = Source.Type.dealer
|
||||||
|
)
|
||||||
|
|
||||||
if self.plugin_name:
|
if self.plugin_name:
|
||||||
self.plugin = Plugins.registry.get(self.plugin_name)
|
self.plugin = Plugins.registry.get(self.plugin_name)
|
||||||
|
|
||||||
|
|
||||||
def play_logs(self, include_diffusions = True,
|
def play_logs(self, include_diffusions = True,
|
||||||
include_sounds = True,
|
include_sounds = True,
|
||||||
exclude_archives = True):
|
exclude_archives = True):
|
||||||
"""
|
"""
|
||||||
Return a queryset with what is playing on air for this station.
|
Return a queryset with log of played elements on this station.
|
||||||
Ordered by date ascending.
|
Ordered by date ascending.
|
||||||
"""
|
"""
|
||||||
models = []
|
models = []
|
||||||
|
@ -148,7 +140,6 @@ class Station(programs.Nameable):
|
||||||
|
|
||||||
qs = Log.get_for(model = models) \
|
qs = Log.get_for(model = models) \
|
||||||
.filter(station = station, type = Log.Type.play)
|
.filter(station = station, type = Log.Type.play)
|
||||||
|
|
||||||
if exclude_archives and self.dealer:
|
if exclude_archives and self.dealer:
|
||||||
qs = qs.exclude(
|
qs = qs.exclude(
|
||||||
source = self.dealer.id_,
|
source = self.dealer.id_,
|
||||||
|
@ -156,10 +147,8 @@ class Station(programs.Nameable):
|
||||||
program.Sound
|
program.Sound
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return qs.order_by('date')
|
return qs.order_by('date')
|
||||||
|
|
||||||
|
|
||||||
def save(self, make_sources = True, *args, **kwargs):
|
def save(self, make_sources = True, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
* make_sources: if the model has not been yet saved, generate
|
* make_sources: if the model has not been yet saved, generate
|
||||||
|
@ -200,8 +189,8 @@ class Source(programs.Nameable):
|
||||||
"""
|
"""
|
||||||
dealer = 0x02
|
dealer = 0x02
|
||||||
"""
|
"""
|
||||||
This source is used for scheduled programs. For the moment only
|
This source is used for scheduled programs. It is automatically
|
||||||
one should be set.
|
added to the station, and may not be saved.
|
||||||
"""
|
"""
|
||||||
stream = 0x03
|
stream = 0x03
|
||||||
"""
|
"""
|
||||||
|
@ -301,6 +290,8 @@ class Source(programs.Nameable):
|
||||||
(not self.program or not self.program.stream_set.count()):
|
(not self.program or not self.program.stream_set.count()):
|
||||||
raise ValueError('missing related stream program; program must be '
|
raise ValueError('missing related stream program; program must be '
|
||||||
'a streamed program')
|
'a streamed program')
|
||||||
|
if self.type == self.Type.dealer:
|
||||||
|
raise ValueError('can not save a dealer source')
|
||||||
|
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
# TODO update controls
|
# TODO update controls
|
||||||
|
|
|
@ -46,7 +46,7 @@ class StationController(plugins.StationController):
|
||||||
self.current_source = [
|
self.current_source = [
|
||||||
# we assume sound is always from a registered source
|
# we assume sound is always from a registered source
|
||||||
source for source in self.station.get_sources()
|
source for source in self.station.get_sources()
|
||||||
if source.rid = rid
|
if source.rid == rid
|
||||||
][0]
|
][0]
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,4 +102,3 @@ class SourceController(plugins.SourceController):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user