syntax
This commit is contained in:
parent
7e511e5076
commit
c10f7a6635
|
@ -35,7 +35,6 @@ Frequency = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Translators: html safe values
|
# Translators: html safe values
|
||||||
ugettext_lazy('ponctual')
|
ugettext_lazy('ponctual')
|
||||||
ugettext_lazy('every')
|
ugettext_lazy('every')
|
||||||
|
@ -56,7 +55,6 @@ DiffusionType = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Model (models.Model):
|
class Model (models.Model):
|
||||||
@classmethod
|
@classmethod
|
||||||
def type (cl):
|
def type (cl):
|
||||||
|
@ -93,8 +91,7 @@ class Metadata (Model):
|
||||||
author = models.ForeignKey (
|
author = models.ForeignKey (
|
||||||
User,
|
User,
|
||||||
verbose_name = _('author'),
|
verbose_name = _('author'),
|
||||||
blank = True,
|
blank = True, null = True,
|
||||||
null = True,
|
|
||||||
)
|
)
|
||||||
title = models.CharField(
|
title = models.CharField(
|
||||||
_('title'),
|
_('title'),
|
||||||
|
@ -207,7 +204,6 @@ class Track (Model):
|
||||||
# to-one relations and add a position argument
|
# to-one relations and add a position argument
|
||||||
episode = models.ForeignKey(
|
episode = models.ForeignKey(
|
||||||
'Episode',
|
'Episode',
|
||||||
null = True,
|
|
||||||
)
|
)
|
||||||
artist = models.CharField(
|
artist = models.CharField(
|
||||||
_('artist'),
|
_('artist'),
|
||||||
|
@ -217,10 +213,10 @@ class Track (Model):
|
||||||
_('title'),
|
_('title'),
|
||||||
max_length = 128,
|
max_length = 128,
|
||||||
)
|
)
|
||||||
tags = TaggableManager( blank = True )
|
tags = TaggableManager( blank = True )
|
||||||
# position can be used to specify a position in seconds for non-stop
|
# position can be used to specify a position in seconds for non-stop
|
||||||
# programs
|
# programs
|
||||||
position = models.SmallIntegerField(
|
position = models.SmallIntegerField(
|
||||||
default = 0,
|
default = 0,
|
||||||
help_text=_('position in the playlist'),
|
help_text=_('position in the playlist'),
|
||||||
)
|
)
|
||||||
|
@ -252,13 +248,11 @@ class Sound (Metadata):
|
||||||
path = settings.AIRCOX_PROGRAMS_DIR,
|
path = settings.AIRCOX_PROGRAMS_DIR,
|
||||||
match = '*(' + '|'.join(settings.AIRCOX_SOUNDFILE_EXT) + ')$',
|
match = '*(' + '|'.join(settings.AIRCOX_SOUNDFILE_EXT) + ')$',
|
||||||
recursive = True,
|
recursive = True,
|
||||||
blank = True,
|
blank = True, null = True,
|
||||||
null = True,
|
|
||||||
)
|
)
|
||||||
duration = models.TimeField(
|
duration = models.TimeField(
|
||||||
_('duration'),
|
_('duration'),
|
||||||
blank = True,
|
blank = True, null = True,
|
||||||
null = True,
|
|
||||||
)
|
)
|
||||||
fragment = models.BooleanField(
|
fragment = models.BooleanField(
|
||||||
_('incomplete sound'),
|
_('incomplete sound'),
|
||||||
|
@ -267,8 +261,7 @@ class Sound (Metadata):
|
||||||
)
|
)
|
||||||
embed = models.TextField(
|
embed = models.TextField(
|
||||||
_('embed HTML code from external website'),
|
_('embed HTML code from external website'),
|
||||||
blank = True,
|
blank = True, null = True,
|
||||||
null = True,
|
|
||||||
help_text = _('if set, consider the sound podcastable'),
|
help_text = _('if set, consider the sound podcastable'),
|
||||||
)
|
)
|
||||||
removed = models.BooleanField(
|
removed = models.BooleanField(
|
||||||
|
@ -300,14 +293,12 @@ class Sound (Metadata):
|
||||||
class Schedule (Model):
|
class Schedule (Model):
|
||||||
parent = models.ForeignKey(
|
parent = models.ForeignKey(
|
||||||
'Program',
|
'Program',
|
||||||
blank = True,
|
blank = True, null = True,
|
||||||
null = True,
|
|
||||||
)
|
)
|
||||||
begin = models.DateTimeField(_('begin'))
|
begin = models.DateTimeField(_('begin'))
|
||||||
end = models.DateTimeField(
|
end = models.DateTimeField(
|
||||||
_('end'),
|
_('end'),
|
||||||
blank = True,
|
blank = True, null = True,
|
||||||
null = True,
|
|
||||||
)
|
)
|
||||||
frequency = models.SmallIntegerField(
|
frequency = models.SmallIntegerField(
|
||||||
_('frequency'),
|
_('frequency'),
|
||||||
|
@ -315,8 +306,7 @@ class Schedule (Model):
|
||||||
)
|
)
|
||||||
rerun = models.ForeignKey(
|
rerun = models.ForeignKey(
|
||||||
'self',
|
'self',
|
||||||
blank = True,
|
blank = True, null = True,
|
||||||
null = True,
|
|
||||||
help_text = "Schedule of a rerun",
|
help_text = "Schedule of a rerun",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -361,8 +351,7 @@ class Schedule (Model):
|
||||||
"""
|
"""
|
||||||
Set the time of a datetime to the schedule's one
|
Set the time of a datetime to the schedule's one
|
||||||
"""
|
"""
|
||||||
return date.replace(hour = self.date.hour,
|
return date.replace(hour = self.date.hour, minute = self.date.minute)
|
||||||
minute = self.date.minute)
|
|
||||||
|
|
||||||
def dates_of_month (self, date = None):
|
def dates_of_month (self, date = None):
|
||||||
"""
|
"""
|
||||||
|
@ -375,17 +364,15 @@ class Schedule (Model):
|
||||||
if not date:
|
if not date:
|
||||||
date = timezone.datetime.today()
|
date = timezone.datetime.today()
|
||||||
|
|
||||||
date = timezone.datetime(year = date.year,
|
date = timezone.datetime(year = date.year, month = date.month, day = 1)
|
||||||
month = date.month,
|
|
||||||
day = 1)
|
|
||||||
wday = self.date.weekday()
|
wday = self.date.weekday()
|
||||||
fwday = date.weekday()
|
fwday = date.weekday()
|
||||||
|
|
||||||
# move date to the date weekday of the schedule
|
# move date to the date weekday of the schedule
|
||||||
# check on SO#3284452 for the formula
|
# check on SO#3284452 for the formula
|
||||||
date += timezone.timedelta(
|
date += timezone.timedelta(
|
||||||
days = (7 if fwday > wday else 0) - fwday + wday
|
days = (7 if fwday > wday else 0) - fwday + wday
|
||||||
)
|
)
|
||||||
fwday = date.weekday()
|
fwday = date.weekday()
|
||||||
|
|
||||||
# special frequency case
|
# special frequency case
|
||||||
|
@ -402,7 +389,7 @@ class Schedule (Model):
|
||||||
|
|
||||||
dates = []
|
dates = []
|
||||||
for week in range(0,5):
|
for week in range(0,5):
|
||||||
# NB: there can be five weeks in a month
|
# there can be five weeks in a month
|
||||||
if not weeks & (0b1 << week):
|
if not weeks & (0b1 << week):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -447,14 +434,13 @@ class Schedule (Model):
|
||||||
|
|
||||||
# make diffusion
|
# make diffusion
|
||||||
diffusion = Diffusion(
|
diffusion = Diffusion(
|
||||||
episode = episode,
|
episode = episode,
|
||||||
program = self.parent,
|
program = self.parent,
|
||||||
type = DiffusionType['scheduled'],
|
type = DiffusionType['scheduled'],
|
||||||
begin = date,
|
begin = date,
|
||||||
end = timezone.datetime.combine(date.date(),
|
end = timezone.datetime.combine(date.date(), self.end.time()),
|
||||||
self.end.time()),
|
stream = settings.AIRCOX_SCHEDULED_STREAM
|
||||||
stream = settings.AIRCOX_SCHEDULED_STREAM,
|
)
|
||||||
)
|
|
||||||
diffusion.program = self.program
|
diffusion.program = self.program
|
||||||
diffusions.append(diffusion)
|
diffusions.append(diffusion)
|
||||||
return diffusions
|
return diffusions
|
||||||
|
@ -472,8 +458,7 @@ class Article (Publication):
|
||||||
parent = models.ForeignKey(
|
parent = models.ForeignKey(
|
||||||
'self',
|
'self',
|
||||||
verbose_name = _('parent'),
|
verbose_name = _('parent'),
|
||||||
blank = True,
|
blank = True, null = True,
|
||||||
null = True,
|
|
||||||
help_text = _('parent article'),
|
help_text = _('parent article'),
|
||||||
)
|
)
|
||||||
static_page = models.BooleanField(
|
static_page = models.BooleanField(
|
||||||
|
@ -482,7 +467,6 @@ class Article (Publication):
|
||||||
)
|
)
|
||||||
focus = models.BooleanField(
|
focus = models.BooleanField(
|
||||||
_('article is focus'),
|
_('article is focus'),
|
||||||
blank = True,
|
|
||||||
default = False,
|
default = False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -495,20 +479,17 @@ class Program (Publication):
|
||||||
parent = models.ForeignKey(
|
parent = models.ForeignKey(
|
||||||
Article,
|
Article,
|
||||||
verbose_name = _('parent'),
|
verbose_name = _('parent'),
|
||||||
blank = True,
|
blank = True, null = True,
|
||||||
null = True,
|
|
||||||
help_text = _('parent article'),
|
help_text = _('parent article'),
|
||||||
)
|
)
|
||||||
email = models.EmailField(
|
email = models.EmailField(
|
||||||
_('email'),
|
_('email'),
|
||||||
max_length = 128,
|
max_length = 128,
|
||||||
null = True,
|
null = True, blank = True,
|
||||||
blank = True,
|
|
||||||
)
|
)
|
||||||
url = models.URLField(
|
url = models.URLField(
|
||||||
_('website'),
|
_('website'),
|
||||||
blank = True,
|
blank = True, null = True,
|
||||||
null = True,
|
|
||||||
)
|
)
|
||||||
non_stop = models.BooleanField(
|
non_stop = models.BooleanField(
|
||||||
_('non-stop'),
|
_('non-stop'),
|
||||||
|
@ -568,8 +549,7 @@ class Diffusion (Model):
|
||||||
"""
|
"""
|
||||||
episode = models.ForeignKey (
|
episode = models.ForeignKey (
|
||||||
Episode,
|
Episode,
|
||||||
blank = True,
|
blank = True, null = True,
|
||||||
null = True,
|
|
||||||
verbose_name = _('episode'),
|
verbose_name = _('episode'),
|
||||||
)
|
)
|
||||||
program = models.ForeignKey (
|
program = models.ForeignKey (
|
||||||
|
@ -583,8 +563,7 @@ class Diffusion (Model):
|
||||||
begin = models.DateTimeField( _('start of the diffusion') )
|
begin = models.DateTimeField( _('start of the diffusion') )
|
||||||
end = models.DateTimeField(
|
end = models.DateTimeField(
|
||||||
_('end of the diffusion'),
|
_('end of the diffusion'),
|
||||||
blank = True,
|
blank = True, null = True,
|
||||||
null = True,
|
|
||||||
)
|
)
|
||||||
stream = models.SmallIntegerField(
|
stream = models.SmallIntegerField(
|
||||||
verbose_name = _('stream'),
|
verbose_name = _('stream'),
|
||||||
|
@ -605,4 +584,3 @@ class Diffusion (Model):
|
||||||
verbose_name = _('Diffusion')
|
verbose_name = _('Diffusion')
|
||||||
verbose_name_plural = _('Diffusions')
|
verbose_name_plural = _('Diffusions')
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user