chore(api): rename show models fields

This commit is contained in:
jo 2022-06-29 19:59:33 +02:00 committed by Kyle Robbertze
parent 4d037bb624
commit 8ceb1419a0
3 changed files with 369 additions and 213 deletions

View File

@ -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()

View File

@ -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",
]

View File

@ -6634,19 +6634,23 @@ components:
name:
type: string
maxLength: 255
url:
type: string
nullable: true
maxLength: 255
genre:
type: string
nullable: true
maxLength: 255
description:
type: string
nullable: true
maxLength: 8192
color:
genre:
type: string
nullable: true
maxLength: 255
url:
type: string
nullable: true
maxLength: 255
image:
type: string
nullable: true
maxLength: 255
foreground_color:
type: string
nullable: true
maxLength: 6
@ -6656,20 +6660,16 @@ components:
maxLength: 6
linked:
type: boolean
is_linkable:
linkable:
type: boolean
image_path:
type: string
nullable: true
maxLength: 255
has_autoplaylist:
type: boolean
autoplaylist_repeat:
type: boolean
autoplaylist:
auto_playlist:
type: string
format: uri
nullable: true
auto_playlist_enabled:
type: boolean
auto_playlist_repeat:
type: boolean
PatchedShowDays:
type: object
properties:
@ -6677,10 +6677,10 @@ components:
type: string
format: uri
readOnly: true
first_show:
first_show_on:
type: string
format: date
last_show:
last_show_on:
type: string
format: date
nullable: true
@ -6693,24 +6693,29 @@ components:
duration:
type: string
maxLength: 1024
day:
type: integer
maximum: 32767
minimum: -32768
record_enabled:
nullable: true
repeat_type:
type: integer
maximum: 32767
minimum: -32768
next_pop_date:
maximum: 32767
oneOf:
- $ref: "#/components/schemas/RecordEnabledEnum"
- $ref: "#/components/schemas/NullEnum"
week_day:
nullable: true
minimum: -32768
maximum: 32767
oneOf:
- $ref: "#/components/schemas/WeekDayEnum"
- $ref: "#/components/schemas/NullEnum"
repeat_kind:
allOf:
- $ref: "#/components/schemas/RepeatKindEnum"
minimum: -32768
maximum: 32767
repeat_next_on:
type: string
format: date
nullable: true
record:
type: integer
maximum: 32767
minimum: -32768
nullable: true
show:
type: string
format: uri
@ -6724,7 +6729,7 @@ components:
show:
type: string
format: uri
subjs:
user:
type: string
format: uri
PatchedShowInstance:
@ -6737,40 +6742,9 @@ components:
id:
type: integer
readOnly: true
description:
type: string
nullable: true
maxLength: 8192
starts:
created_at:
type: string
format: date-time
ends:
type: string
format: date-time
record:
type: integer
maximum: 32767
minimum: -32768
nullable: true
rebroadcast:
type: integer
maximum: 32767
minimum: -32768
nullable: true
time_filled:
type: string
nullable: true
created:
type: string
format: date-time
last_scheduled:
type: string
format: date-time
nullable: true
modified_instance:
type: boolean
autoplaylist_built:
type: boolean
show:
type: string
format: uri
@ -6781,11 +6755,44 @@ components:
type: string
format: uri
nullable: true
file:
starts_at:
type: string
format: date-time
ends_at:
type: string
format: date-time
filled_time:
type: string
nullable: true
last_scheduled_at:
type: string
format: date-time
nullable: true
description:
type: string
nullable: true
maxLength: 8192
modified:
type: boolean
rebroadcast:
type: integer
maximum: 32767
minimum: -32768
nullable: true
auto_playlist_built:
type: boolean
record_enabled:
nullable: true
minimum: -32768
maximum: 32767
oneOf:
- $ref: "#/components/schemas/RecordEnabledEnum"
- $ref: "#/components/schemas/NullEnum"
record_file:
type: string
format: uri
nullable: true
file_id:
record_file_id:
type: integer
readOnly: true
PatchedShowRebroadcast:
@ -7396,6 +7403,19 @@ components:
- item_url
- key
- user
RecordEnabledEnum:
enum:
- 0
- 1
type: integer
RepeatKindEnum:
enum:
- 0
- 1
- 4
- 5
- 2
type: integer
RoleEnum:
enum:
- G
@ -7511,19 +7531,23 @@ components:
name:
type: string
maxLength: 255
url:
type: string
nullable: true
maxLength: 255
genre:
type: string
nullable: true
maxLength: 255
description:
type: string
nullable: true
maxLength: 8192
color:
genre:
type: string
nullable: true
maxLength: 255
url:
type: string
nullable: true
maxLength: 255
image:
type: string
nullable: true
maxLength: 255
foreground_color:
type: string
nullable: true
maxLength: 6
@ -7533,26 +7557,22 @@ components:
maxLength: 6
linked:
type: boolean
is_linkable:
linkable:
type: boolean
image_path:
type: string
nullable: true
maxLength: 255
has_autoplaylist:
type: boolean
autoplaylist_repeat:
type: boolean
autoplaylist:
auto_playlist:
type: string
format: uri
nullable: true
auto_playlist_enabled:
type: boolean
auto_playlist_repeat:
type: boolean
required:
- autoplaylist_repeat
- has_autoplaylist
- auto_playlist_enabled
- auto_playlist_repeat
- id
- is_linkable
- item_url
- linkable
- linked
- name
ShowDays:
@ -7562,10 +7582,10 @@ components:
type: string
format: uri
readOnly: true
first_show:
first_show_on:
type: string
format: date
last_show:
last_show_on:
type: string
format: date
nullable: true
@ -7578,32 +7598,37 @@ components:
duration:
type: string
maxLength: 1024
day:
type: integer
maximum: 32767
minimum: -32768
record_enabled:
nullable: true
repeat_type:
type: integer
maximum: 32767
minimum: -32768
next_pop_date:
maximum: 32767
oneOf:
- $ref: "#/components/schemas/RecordEnabledEnum"
- $ref: "#/components/schemas/NullEnum"
week_day:
nullable: true
minimum: -32768
maximum: 32767
oneOf:
- $ref: "#/components/schemas/WeekDayEnum"
- $ref: "#/components/schemas/NullEnum"
repeat_kind:
allOf:
- $ref: "#/components/schemas/RepeatKindEnum"
minimum: -32768
maximum: 32767
repeat_next_on:
type: string
format: date
nullable: true
record:
type: integer
maximum: 32767
minimum: -32768
nullable: true
show:
type: string
format: uri
required:
- duration
- first_show
- first_show_on
- item_url
- repeat_type
- repeat_kind
- show
- start_time
- timezone
@ -7617,13 +7642,13 @@ components:
show:
type: string
format: uri
subjs:
user:
type: string
format: uri
required:
- item_url
- show
- subjs
- user
ShowInstance:
type: object
properties:
@ -7634,40 +7659,9 @@ components:
id:
type: integer
readOnly: true
description:
type: string
nullable: true
maxLength: 8192
starts:
created_at:
type: string
format: date-time
ends:
type: string
format: date-time
record:
type: integer
maximum: 32767
minimum: -32768
nullable: true
rebroadcast:
type: integer
maximum: 32767
minimum: -32768
nullable: true
time_filled:
type: string
nullable: true
created:
type: string
format: date-time
last_scheduled:
type: string
format: date-time
nullable: true
modified_instance:
type: boolean
autoplaylist_built:
type: boolean
show:
type: string
format: uri
@ -7678,24 +7672,57 @@ components:
type: string
format: uri
nullable: true
file:
starts_at:
type: string
format: date-time
ends_at:
type: string
format: date-time
filled_time:
type: string
nullable: true
last_scheduled_at:
type: string
format: date-time
nullable: true
description:
type: string
nullable: true
maxLength: 8192
modified:
type: boolean
rebroadcast:
type: integer
maximum: 32767
minimum: -32768
nullable: true
auto_playlist_built:
type: boolean
record_enabled:
nullable: true
minimum: -32768
maximum: 32767
oneOf:
- $ref: "#/components/schemas/RecordEnabledEnum"
- $ref: "#/components/schemas/NullEnum"
record_file:
type: string
format: uri
nullable: true
file_id:
record_file_id:
type: integer
readOnly: true
required:
- autoplaylist_built
- created
- ends
- file_id
- auto_playlist_built
- created_at
- ends_at
- id
- item_url
- modified_instance
- modified
- record_file_id
- show
- show_id
- starts
- starts_at
ShowRebroadcast:
type: object
properties:
@ -8056,6 +8083,16 @@ components:
- item_url
- schedule
- starts_at
WeekDayEnum:
enum:
- 0
- 1
- 2
- 3
- 4
- 5
- 6
type: integer
securitySchemes:
basicAuth:
type: http