chore(api): rename show models fields
This commit is contained in:
parent
4d037bb624
commit
8ceb1419a0
3 changed files with 369 additions and 213 deletions
|
@ -3,46 +3,157 @@ from django.db import models
|
|||
|
||||
class Show(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
url = models.CharField(max_length=255, blank=True, null=True)
|
||||
genre = models.CharField(max_length=255, blank=True, null=True)
|
||||
description = models.CharField(max_length=8192, blank=True, null=True)
|
||||
color = models.CharField(max_length=6, blank=True, null=True)
|
||||
background_color = models.CharField(max_length=6, blank=True, null=True)
|
||||
live_stream_using_airtime_auth = models.BooleanField(blank=True, null=True)
|
||||
live_stream_using_custom_auth = models.BooleanField(blank=True, null=True)
|
||||
live_stream_user = models.CharField(max_length=255, blank=True, null=True)
|
||||
live_stream_pass = models.CharField(max_length=255, blank=True, null=True)
|
||||
genre = models.CharField(max_length=255, blank=True, null=True)
|
||||
url = models.CharField(max_length=255, blank=True, null=True)
|
||||
|
||||
image = models.CharField(
|
||||
max_length=255,
|
||||
blank=True,
|
||||
null=True,
|
||||
db_column="image_path",
|
||||
)
|
||||
foreground_color = models.CharField(
|
||||
max_length=6,
|
||||
blank=True,
|
||||
null=True,
|
||||
db_column="color",
|
||||
)
|
||||
background_color = models.CharField(
|
||||
max_length=6,
|
||||
blank=True,
|
||||
null=True,
|
||||
)
|
||||
|
||||
live_auth_registered = models.BooleanField(
|
||||
blank=True,
|
||||
null=True,
|
||||
db_column="live_stream_using_airtime_auth",
|
||||
)
|
||||
live_auth_custom = models.BooleanField(
|
||||
blank=True,
|
||||
null=True,
|
||||
db_column="live_stream_using_custom_auth",
|
||||
)
|
||||
live_auth_custom_user = models.CharField(
|
||||
max_length=255,
|
||||
blank=True,
|
||||
null=True,
|
||||
db_column="live_stream_user",
|
||||
)
|
||||
live_auth_custom_password = models.CharField(
|
||||
max_length=255,
|
||||
blank=True,
|
||||
null=True,
|
||||
db_column="live_stream_pass",
|
||||
)
|
||||
|
||||
# A show is linkable if it has never been linked before. Once
|
||||
# a show becomes unlinked it can not be linked again.
|
||||
linked = models.BooleanField()
|
||||
is_linkable = models.BooleanField()
|
||||
image_path = models.CharField(max_length=255, blank=True, null=True)
|
||||
has_autoplaylist = models.BooleanField()
|
||||
autoplaylist = models.ForeignKey(
|
||||
linkable = models.BooleanField(db_column="is_linkable")
|
||||
|
||||
auto_playlist = models.ForeignKey(
|
||||
"schedule.Playlist",
|
||||
on_delete=models.DO_NOTHING,
|
||||
blank=True,
|
||||
null=True,
|
||||
db_column="autoplaylist_id",
|
||||
)
|
||||
auto_playlist_enabled = models.BooleanField(db_column="has_autoplaylist")
|
||||
auto_playlist_repeat = models.BooleanField(db_column="autoplaylist_repeat")
|
||||
|
||||
hosts = models.ManyToManyField(
|
||||
"core.User",
|
||||
through="ShowHost",
|
||||
)
|
||||
autoplaylist_repeat = models.BooleanField()
|
||||
|
||||
def get_owner(self):
|
||||
return self.showhost_set.all()
|
||||
return self.hosts.all()
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = "cc_show"
|
||||
|
||||
|
||||
class ShowHost(models.Model):
|
||||
show = models.ForeignKey(
|
||||
"schedule.Show",
|
||||
on_delete=models.DO_NOTHING,
|
||||
)
|
||||
user = models.ForeignKey(
|
||||
"core.User",
|
||||
on_delete=models.DO_NOTHING,
|
||||
db_column="subjs_id",
|
||||
)
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = "cc_show_hosts"
|
||||
|
||||
|
||||
# TODO: Replace record choices with a boolean
|
||||
class Record(models.IntegerChoices):
|
||||
NO = 0, "No"
|
||||
YES = 1, "Yes"
|
||||
|
||||
|
||||
class ShowDays(models.Model):
|
||||
first_show = models.DateField()
|
||||
last_show = models.DateField(blank=True, null=True)
|
||||
show = models.ForeignKey("schedule.Show", on_delete=models.DO_NOTHING)
|
||||
|
||||
first_show_on = models.DateField(
|
||||
db_column="first_show",
|
||||
)
|
||||
last_show_on = models.DateField(
|
||||
blank=True,
|
||||
null=True,
|
||||
db_column="last_show",
|
||||
)
|
||||
start_time = models.TimeField()
|
||||
|
||||
timezone = models.CharField(max_length=1024)
|
||||
duration = models.CharField(max_length=1024)
|
||||
day = models.SmallIntegerField(blank=True, null=True)
|
||||
repeat_type = models.SmallIntegerField()
|
||||
next_pop_date = models.DateField(blank=True, null=True)
|
||||
show = models.ForeignKey("schedule.Show", on_delete=models.DO_NOTHING)
|
||||
record = models.SmallIntegerField(blank=True, null=True)
|
||||
|
||||
record_enabled = models.SmallIntegerField(
|
||||
choices=Record.choices,
|
||||
default=Record.NO,
|
||||
blank=True,
|
||||
null=True,
|
||||
db_column="record",
|
||||
)
|
||||
|
||||
class WeekDay(models.IntegerChoices):
|
||||
MONDAY = 0, "Monday"
|
||||
TUESDAY = 1, "Tuesday"
|
||||
WEDNESDAY = 2, "Wednesday"
|
||||
THURSDAY = 3, "Thursday"
|
||||
FRIDAY = 4, "Friday"
|
||||
SATURDAY = 5, "Saturday"
|
||||
SUNDAY = 6, "Sunday"
|
||||
|
||||
week_day = models.SmallIntegerField(
|
||||
choices=WeekDay.choices,
|
||||
blank=True,
|
||||
null=True,
|
||||
db_column="day",
|
||||
)
|
||||
|
||||
class RepeatKind(models.IntegerChoices):
|
||||
WEEKLY = 0, "Every week"
|
||||
WEEKLY_2 = 1, "Every 2 weeks"
|
||||
WEEKLY_3 = 4, "Every 3 weeks"
|
||||
WEEKLY_4 = 5, "Every 4 weeks"
|
||||
MONTHLY = 2, "Every month"
|
||||
|
||||
repeat_kind = models.SmallIntegerField(
|
||||
choices=RepeatKind.choices,
|
||||
db_column="repeat_type",
|
||||
)
|
||||
repeat_next_on = models.DateField(
|
||||
blank=True,
|
||||
null=True,
|
||||
db_column="next_pop_date",
|
||||
)
|
||||
|
||||
def get_owner(self):
|
||||
return self.show.get_owner()
|
||||
|
@ -52,39 +163,47 @@ class ShowDays(models.Model):
|
|||
db_table = "cc_show_days"
|
||||
|
||||
|
||||
class ShowHost(models.Model):
|
||||
show = models.ForeignKey("schedule.Show", on_delete=models.DO_NOTHING)
|
||||
subjs = models.ForeignKey("core.User", on_delete=models.DO_NOTHING)
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = "cc_show_hosts"
|
||||
|
||||
|
||||
class ShowInstance(models.Model):
|
||||
description = models.CharField(max_length=8192, blank=True, null=True)
|
||||
starts = models.DateTimeField()
|
||||
ends = models.DateTimeField()
|
||||
created_at = models.DateTimeField(db_column="created")
|
||||
|
||||
show = models.ForeignKey("schedule.Show", on_delete=models.DO_NOTHING)
|
||||
record = models.SmallIntegerField(blank=True, null=True)
|
||||
rebroadcast = models.SmallIntegerField(blank=True, null=True)
|
||||
instance = models.ForeignKey(
|
||||
"self",
|
||||
on_delete=models.DO_NOTHING,
|
||||
blank=True,
|
||||
null=True,
|
||||
)
|
||||
file = models.ForeignKey(
|
||||
|
||||
starts_at = models.DateTimeField(db_column="starts")
|
||||
ends_at = models.DateTimeField(db_column="ends")
|
||||
filled_time = models.DurationField(blank=True, null=True, db_column="time_filled")
|
||||
|
||||
last_scheduled_at = models.DateTimeField(
|
||||
blank=True,
|
||||
null=True,
|
||||
db_column="last_scheduled",
|
||||
)
|
||||
|
||||
description = models.CharField(max_length=8192, blank=True, null=True)
|
||||
modified = models.BooleanField(db_column="modified_instance")
|
||||
rebroadcast = models.SmallIntegerField(blank=True, null=True)
|
||||
|
||||
auto_playlist_built = models.BooleanField(db_column="autoplaylist_built")
|
||||
|
||||
record_enabled = models.SmallIntegerField(
|
||||
choices=Record.choices,
|
||||
default=Record.NO,
|
||||
blank=True,
|
||||
null=True,
|
||||
db_column="record",
|
||||
)
|
||||
record_file = models.ForeignKey(
|
||||
"storage.File",
|
||||
on_delete=models.DO_NOTHING,
|
||||
blank=True,
|
||||
null=True,
|
||||
db_column="file_id",
|
||||
)
|
||||
time_filled = models.DurationField(blank=True, null=True)
|
||||
created = models.DateTimeField()
|
||||
last_scheduled = models.DateTimeField(blank=True, null=True)
|
||||
modified_instance = models.BooleanField()
|
||||
autoplaylist_built = models.BooleanField()
|
||||
|
||||
def get_owner(self):
|
||||
return self.show.get_owner()
|
||||
|
@ -95,9 +214,9 @@ class ShowInstance(models.Model):
|
|||
|
||||
|
||||
class ShowRebroadcast(models.Model):
|
||||
show = models.ForeignKey("schedule.Show", on_delete=models.DO_NOTHING)
|
||||
day_offset = models.CharField(max_length=1024)
|
||||
start_time = models.TimeField()
|
||||
show = models.ForeignKey("schedule.Show", on_delete=models.DO_NOTHING)
|
||||
|
||||
def get_owner(self):
|
||||
return self.show.get_owner()
|
||||
|
|
|
@ -10,17 +10,17 @@ class ShowSerializer(serializers.HyperlinkedModelSerializer):
|
|||
"item_url",
|
||||
"id",
|
||||
"name",
|
||||
"url",
|
||||
"genre",
|
||||
"description",
|
||||
"color",
|
||||
"genre",
|
||||
"url",
|
||||
"image",
|
||||
"foreground_color",
|
||||
"background_color",
|
||||
"linked",
|
||||
"is_linkable",
|
||||
"image_path",
|
||||
"has_autoplaylist",
|
||||
"autoplaylist_repeat",
|
||||
"autoplaylist",
|
||||
"linkable",
|
||||
"auto_playlist",
|
||||
"auto_playlist_enabled",
|
||||
"auto_playlist_repeat",
|
||||
]
|
||||
|
||||
|
||||
|
@ -38,28 +38,28 @@ class ShowHostSerializer(serializers.HyperlinkedModelSerializer):
|
|||
|
||||
class ShowInstanceSerializer(serializers.HyperlinkedModelSerializer):
|
||||
show_id = serializers.IntegerField(source="show.id", read_only=True)
|
||||
file_id = serializers.IntegerField(source="file.id", read_only=True)
|
||||
record_file_id = serializers.IntegerField(source="record_file.id", read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = ShowInstance
|
||||
fields = [
|
||||
"item_url",
|
||||
"id",
|
||||
"description",
|
||||
"starts",
|
||||
"ends",
|
||||
"record",
|
||||
"rebroadcast",
|
||||
"time_filled",
|
||||
"created",
|
||||
"last_scheduled",
|
||||
"modified_instance",
|
||||
"autoplaylist_built",
|
||||
"created_at",
|
||||
"show",
|
||||
"show_id",
|
||||
"instance",
|
||||
"file",
|
||||
"file_id",
|
||||
"starts_at",
|
||||
"ends_at",
|
||||
"filled_time",
|
||||
"last_scheduled_at",
|
||||
"description",
|
||||
"modified",
|
||||
"rebroadcast",
|
||||
"auto_playlist_built",
|
||||
"record_enabled",
|
||||
"record_file",
|
||||
"record_file_id",
|
||||
]
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue