create aircox_streamer as separate application

This commit is contained in:
bkfox
2019-09-19 15:22:56 +02:00
parent e30d1b54ef
commit 4e61ec1520
45 changed files with 497 additions and 11934 deletions

View File

@ -1,7 +1,6 @@
import os
from django.db import models
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from filer.fields.image import FilerImageField
@ -9,7 +8,7 @@ from filer.fields.image import FilerImageField
from .. import settings
__all__ = ['Station', 'StationQuerySet', 'Port']
__all__ = ['Station', 'StationQuerySet']
class StationQuerySet(models.QuerySet):
@ -22,6 +21,9 @@ class StationQuerySet(models.QuerySet):
return self.order_by('-default', 'pk').first()
return self.filter(pk=station).first()
def active(self):
return self.filter(active=True)
class Station(models.Model):
"""
@ -44,7 +46,12 @@ class Station(models.Model):
default = models.BooleanField(
_('default station'),
default=True,
help_text=_('if checked, this station is used as the main one')
help_text=_('use this station as the main one.')
)
active = models.BooleanField(
_('active'),
default=True,
help_text=_('whether this station is still active or not.')
)
logo = FilerImageField(
on_delete=models.SET_NULL, null=True, blank=True,
@ -79,6 +86,20 @@ class Station(models.Model):
super().save(*args, **kwargs)
class PortQuerySet(models.QuerySet):
def active(self, value=True):
""" Active ports """
return self.filter(active=value)
def output(self):
""" Filter in output ports """
return self.filter(direction=Port.DIRECTION_OUTPUT)
def input(self):
""" Fitler in input ports """
return self.filter(direction=Port.DIRECTION_INPUT)
class Port(models.Model):
"""
Represent an audio input/output for the audio stream
@ -126,6 +147,14 @@ class Port(models.Model):
blank=True, null=True
)
objects = PortQuerySet.as_manager()
def __str__(self):
return "{direction}: {type} #{id}".format(
direction=self.get_direction_display(),
type=self.get_type_display(), id=self.pk or ''
)
def is_valid_type(self):
"""
Return True if the type is available for the given direction.
@ -148,11 +177,3 @@ class Port(models.Model):
return super().save(*args, **kwargs)
def __str__(self):
return "{direction}: {type} #{id}".format(
direction=self.get_direction_display(),
type=self.get_type_display(),
id=self.pk or ''
)