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): class Show(models.Model):
name = models.CharField(max_length=255) 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) description = models.CharField(max_length=8192, blank=True, null=True)
color = models.CharField(max_length=6, blank=True, null=True) genre = models.CharField(max_length=255, blank=True, null=True)
background_color = models.CharField(max_length=6, blank=True, null=True) url = models.CharField(max_length=255, 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) image = models.CharField(
live_stream_user = models.CharField(max_length=255, blank=True, null=True) max_length=255,
live_stream_pass = models.CharField(max_length=255, blank=True, null=True) 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() linked = models.BooleanField()
is_linkable = models.BooleanField() linkable = models.BooleanField(db_column="is_linkable")
image_path = models.CharField(max_length=255, blank=True, null=True)
has_autoplaylist = models.BooleanField() auto_playlist = models.ForeignKey(
autoplaylist = models.ForeignKey(
"schedule.Playlist", "schedule.Playlist",
on_delete=models.DO_NOTHING, on_delete=models.DO_NOTHING,
blank=True, blank=True,
null=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): def get_owner(self):
return self.showhost_set.all() return self.hosts.all()
class Meta: class Meta:
managed = False managed = False
db_table = "cc_show" 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): class ShowDays(models.Model):
first_show = models.DateField() show = models.ForeignKey("schedule.Show", on_delete=models.DO_NOTHING)
last_show = models.DateField(blank=True, null=True)
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() start_time = models.TimeField()
timezone = models.CharField(max_length=1024) timezone = models.CharField(max_length=1024)
duration = models.CharField(max_length=1024) duration = models.CharField(max_length=1024)
day = models.SmallIntegerField(blank=True, null=True)
repeat_type = models.SmallIntegerField() record_enabled = models.SmallIntegerField(
next_pop_date = models.DateField(blank=True, null=True) choices=Record.choices,
show = models.ForeignKey("schedule.Show", on_delete=models.DO_NOTHING) default=Record.NO,
record = models.SmallIntegerField(blank=True, null=True) 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): def get_owner(self):
return self.show.get_owner() return self.show.get_owner()
@ -52,39 +163,47 @@ class ShowDays(models.Model):
db_table = "cc_show_days" 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): class ShowInstance(models.Model):
description = models.CharField(max_length=8192, blank=True, null=True) created_at = models.DateTimeField(db_column="created")
starts = models.DateTimeField()
ends = models.DateTimeField()
show = models.ForeignKey("schedule.Show", on_delete=models.DO_NOTHING) 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( instance = models.ForeignKey(
"self", "self",
on_delete=models.DO_NOTHING, on_delete=models.DO_NOTHING,
blank=True, blank=True,
null=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", "storage.File",
on_delete=models.DO_NOTHING, on_delete=models.DO_NOTHING,
blank=True, blank=True,
null=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): def get_owner(self):
return self.show.get_owner() return self.show.get_owner()
@ -95,9 +214,9 @@ class ShowInstance(models.Model):
class ShowRebroadcast(models.Model): class ShowRebroadcast(models.Model):
show = models.ForeignKey("schedule.Show", on_delete=models.DO_NOTHING)
day_offset = models.CharField(max_length=1024) day_offset = models.CharField(max_length=1024)
start_time = models.TimeField() start_time = models.TimeField()
show = models.ForeignKey("schedule.Show", on_delete=models.DO_NOTHING)
def get_owner(self): def get_owner(self):
return self.show.get_owner() return self.show.get_owner()

View File

@ -10,17 +10,17 @@ class ShowSerializer(serializers.HyperlinkedModelSerializer):
"item_url", "item_url",
"id", "id",
"name", "name",
"url",
"genre",
"description", "description",
"color", "genre",
"url",
"image",
"foreground_color",
"background_color", "background_color",
"linked", "linked",
"is_linkable", "linkable",
"image_path", "auto_playlist",
"has_autoplaylist", "auto_playlist_enabled",
"autoplaylist_repeat", "auto_playlist_repeat",
"autoplaylist",
] ]
@ -38,28 +38,28 @@ class ShowHostSerializer(serializers.HyperlinkedModelSerializer):
class ShowInstanceSerializer(serializers.HyperlinkedModelSerializer): class ShowInstanceSerializer(serializers.HyperlinkedModelSerializer):
show_id = serializers.IntegerField(source="show.id", read_only=True) 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: class Meta:
model = ShowInstance model = ShowInstance
fields = [ fields = [
"item_url", "item_url",
"id", "id",
"description", "created_at",
"starts",
"ends",
"record",
"rebroadcast",
"time_filled",
"created",
"last_scheduled",
"modified_instance",
"autoplaylist_built",
"show", "show",
"show_id", "show_id",
"instance", "instance",
"file", "starts_at",
"file_id", "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: name:
type: string type: string
maxLength: 255 maxLength: 255
url:
type: string
nullable: true
maxLength: 255
genre:
type: string
nullable: true
maxLength: 255
description: description:
type: string type: string
nullable: true nullable: true
maxLength: 8192 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 type: string
nullable: true nullable: true
maxLength: 6 maxLength: 6
@ -6656,20 +6660,16 @@ components:
maxLength: 6 maxLength: 6
linked: linked:
type: boolean type: boolean
is_linkable: linkable:
type: boolean type: boolean
image_path: auto_playlist:
type: string
nullable: true
maxLength: 255
has_autoplaylist:
type: boolean
autoplaylist_repeat:
type: boolean
autoplaylist:
type: string type: string
format: uri format: uri
nullable: true nullable: true
auto_playlist_enabled:
type: boolean
auto_playlist_repeat:
type: boolean
PatchedShowDays: PatchedShowDays:
type: object type: object
properties: properties:
@ -6677,10 +6677,10 @@ components:
type: string type: string
format: uri format: uri
readOnly: true readOnly: true
first_show: first_show_on:
type: string type: string
format: date format: date
last_show: last_show_on:
type: string type: string
format: date format: date
nullable: true nullable: true
@ -6693,24 +6693,29 @@ components:
duration: duration:
type: string type: string
maxLength: 1024 maxLength: 1024
day: record_enabled:
type: integer
maximum: 32767
minimum: -32768
nullable: true nullable: true
repeat_type:
type: integer
maximum: 32767
minimum: -32768 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 type: string
format: date format: date
nullable: true nullable: true
record:
type: integer
maximum: 32767
minimum: -32768
nullable: true
show: show:
type: string type: string
format: uri format: uri
@ -6724,7 +6729,7 @@ components:
show: show:
type: string type: string
format: uri format: uri
subjs: user:
type: string type: string
format: uri format: uri
PatchedShowInstance: PatchedShowInstance:
@ -6737,40 +6742,9 @@ components:
id: id:
type: integer type: integer
readOnly: true readOnly: true
description: created_at:
type: string
nullable: true
maxLength: 8192
starts:
type: string type: string
format: date-time 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: show:
type: string type: string
format: uri format: uri
@ -6781,11 +6755,44 @@ components:
type: string type: string
format: uri format: uri
nullable: true 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 type: string
format: uri format: uri
nullable: true nullable: true
file_id: record_file_id:
type: integer type: integer
readOnly: true readOnly: true
PatchedShowRebroadcast: PatchedShowRebroadcast:
@ -7396,6 +7403,19 @@ components:
- item_url - item_url
- key - key
- user - user
RecordEnabledEnum:
enum:
- 0
- 1
type: integer
RepeatKindEnum:
enum:
- 0
- 1
- 4
- 5
- 2
type: integer
RoleEnum: RoleEnum:
enum: enum:
- G - G
@ -7511,19 +7531,23 @@ components:
name: name:
type: string type: string
maxLength: 255 maxLength: 255
url:
type: string
nullable: true
maxLength: 255
genre:
type: string
nullable: true
maxLength: 255
description: description:
type: string type: string
nullable: true nullable: true
maxLength: 8192 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 type: string
nullable: true nullable: true
maxLength: 6 maxLength: 6
@ -7533,26 +7557,22 @@ components:
maxLength: 6 maxLength: 6
linked: linked:
type: boolean type: boolean
is_linkable: linkable:
type: boolean type: boolean
image_path: auto_playlist:
type: string
nullable: true
maxLength: 255
has_autoplaylist:
type: boolean
autoplaylist_repeat:
type: boolean
autoplaylist:
type: string type: string
format: uri format: uri
nullable: true nullable: true
auto_playlist_enabled:
type: boolean
auto_playlist_repeat:
type: boolean
required: required:
- autoplaylist_repeat - auto_playlist_enabled
- has_autoplaylist - auto_playlist_repeat
- id - id
- is_linkable
- item_url - item_url
- linkable
- linked - linked
- name - name
ShowDays: ShowDays:
@ -7562,10 +7582,10 @@ components:
type: string type: string
format: uri format: uri
readOnly: true readOnly: true
first_show: first_show_on:
type: string type: string
format: date format: date
last_show: last_show_on:
type: string type: string
format: date format: date
nullable: true nullable: true
@ -7578,32 +7598,37 @@ components:
duration: duration:
type: string type: string
maxLength: 1024 maxLength: 1024
day: record_enabled:
type: integer
maximum: 32767
minimum: -32768
nullable: true nullable: true
repeat_type:
type: integer
maximum: 32767
minimum: -32768 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 type: string
format: date format: date
nullable: true nullable: true
record:
type: integer
maximum: 32767
minimum: -32768
nullable: true
show: show:
type: string type: string
format: uri format: uri
required: required:
- duration - duration
- first_show - first_show_on
- item_url - item_url
- repeat_type - repeat_kind
- show - show
- start_time - start_time
- timezone - timezone
@ -7617,13 +7642,13 @@ components:
show: show:
type: string type: string
format: uri format: uri
subjs: user:
type: string type: string
format: uri format: uri
required: required:
- item_url - item_url
- show - show
- subjs - user
ShowInstance: ShowInstance:
type: object type: object
properties: properties:
@ -7634,40 +7659,9 @@ components:
id: id:
type: integer type: integer
readOnly: true readOnly: true
description: created_at:
type: string
nullable: true
maxLength: 8192
starts:
type: string type: string
format: date-time 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: show:
type: string type: string
format: uri format: uri
@ -7678,24 +7672,57 @@ components:
type: string type: string
format: uri format: uri
nullable: true 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 type: string
format: uri format: uri
nullable: true nullable: true
file_id: record_file_id:
type: integer type: integer
readOnly: true readOnly: true
required: required:
- autoplaylist_built - auto_playlist_built
- created - created_at
- ends - ends_at
- file_id
- id - id
- item_url - item_url
- modified_instance - modified
- record_file_id
- show - show
- show_id - show_id
- starts - starts_at
ShowRebroadcast: ShowRebroadcast:
type: object type: object
properties: properties:
@ -8056,6 +8083,16 @@ components:
- item_url - item_url
- schedule - schedule
- starts_at - starts_at
WeekDayEnum:
enum:
- 0
- 1
- 2
- 3
- 4
- 5
- 6
type: integer
securitySchemes: securitySchemes:
basicAuth: basicAuth:
type: http type: http