From 4d037bb62466f8e690efdf646e29784f7187baa9 Mon Sep 17 00:00:00 2001 From: jo Date: Wed, 29 Jun 2022 19:41:57 +0200 Subject: [PATCH] chore(api): rename smart_block models fields --- .../schedule/models/smart_block.py | 53 +++++--- api/schema.yml | 121 ++++++++++-------- 2 files changed, 105 insertions(+), 69 deletions(-) diff --git a/api/libretime_api/schedule/models/smart_block.py b/api/libretime_api/schedule/models/smart_block.py index 4b353e3cd..425c53fd6 100644 --- a/api/libretime_api/schedule/models/smart_block.py +++ b/api/libretime_api/schedule/models/smart_block.py @@ -2,21 +2,36 @@ from django.db import models class SmartBlock(models.Model): + created_at = models.DateTimeField(blank=True, null=True, db_column="utime") + updated_at = models.DateTimeField(blank=True, null=True, db_column="mtime") + name = models.CharField(max_length=255) - mtime = models.DateTimeField(blank=True, null=True) - utime = models.DateTimeField(blank=True, null=True) - creator = models.ForeignKey( + description = models.CharField(max_length=512, blank=True, null=True) + length = models.DurationField(blank=True, null=True) + + class Kind(models.TextChoices): + STATIC = "static", "Static" + DYNAMIC = "dynamic", "Dynamic" + + kind = models.CharField( + choices=Kind.choices, + default=Kind.DYNAMIC, + max_length=7, + blank=True, + null=True, + db_column="type", + ) + + owner = models.ForeignKey( "core.User", on_delete=models.DO_NOTHING, blank=True, null=True, + db_column="creator_id", ) - description = models.CharField(max_length=512, blank=True, null=True) - length = models.DurationField(blank=True, null=True) - type = models.CharField(max_length=7, blank=True, null=True) def get_owner(self): - return self.creator + return self.owner class Meta: managed = False @@ -46,13 +61,14 @@ class SmartBlockContent(models.Model): blank=True, null=True, ) + position = models.IntegerField(blank=True, null=True) - trackoffset = models.FloatField() - cliplength = models.DurationField(blank=True, null=True) - cuein = models.DurationField(blank=True, null=True) - cueout = models.DurationField(blank=True, null=True) - fadein = models.TimeField(blank=True, null=True) - fadeout = models.TimeField(blank=True, null=True) + offset = models.FloatField(db_column="trackoffset") + length = models.DurationField(blank=True, null=True, db_column="cliplength") + cue_in = models.DurationField(blank=True, null=True, db_column="cuein") + cue_out = models.DurationField(blank=True, null=True, db_column="cueout") + fade_in = models.TimeField(blank=True, null=True, db_column="fadein") + fade_out = models.TimeField(blank=True, null=True, db_column="fadeout") def get_owner(self): return self.block.get_owner() @@ -73,12 +89,17 @@ class SmartBlockContent(models.Model): class SmartBlockCriteria(models.Model): + block = models.ForeignKey("schedule.SmartBlock", on_delete=models.DO_NOTHING) + group = models.IntegerField( + blank=True, + null=True, + db_column="criteriagroup", + ) + criteria = models.CharField(max_length=32) - modifier = models.CharField(max_length=16) + condition = models.CharField(max_length=16, db_column="modifier") value = models.CharField(max_length=512) extra = models.CharField(max_length=512, blank=True, null=True) - criteriagroup = models.IntegerField(blank=True, null=True) - block = models.ForeignKey("schedule.SmartBlock", on_delete=models.DO_NOTHING) def get_owner(self): return self.block.get_owner() diff --git a/api/schema.yml b/api/schema.yml index c02814467..0394133cc 100644 --- a/api/schema.yml +++ b/api/schema.yml @@ -5468,6 +5468,9 @@ paths: description: No response body components: schemas: + BlankEnum: + enum: + - "" CeleryTask: type: object properties: @@ -5794,7 +5797,7 @@ components: - item_url - override_album - podcast - KindEnum: + Kind1d2Enum: enum: - 0 - 1 @@ -5893,6 +5896,9 @@ components: required: - item_url - mount_name + NullEnum: + enum: + - null PatchedCeleryTask: type: object properties: @@ -6310,7 +6316,7 @@ components: readOnly: true kind: allOf: - - $ref: "#/components/schemas/KindEnum" + - $ref: "#/components/schemas/Kind1d2Enum" minimum: -32768 maximum: 32767 position: @@ -6805,17 +6811,17 @@ components: type: string format: uri readOnly: true + created_at: + type: string + format: date-time + nullable: true + updated_at: + type: string + format: date-time + nullable: true name: type: string maxLength: 255 - mtime: - type: string - format: date-time - nullable: true - utime: - type: string - format: date-time - nullable: true description: type: string nullable: true @@ -6823,11 +6829,13 @@ components: length: type: string nullable: true - type: - type: string + kind: nullable: true - maxLength: 7 - creator: + oneOf: + - $ref: "#/components/schemas/SmartBlockKindEnum" + - $ref: "#/components/schemas/BlankEnum" + - $ref: "#/components/schemas/NullEnum" + owner: type: string format: uri nullable: true @@ -6843,23 +6851,23 @@ components: maximum: 2147483647 minimum: -2147483648 nullable: true - trackoffset: + offset: type: number format: double - cliplength: + length: type: string nullable: true - cuein: + cue_in: type: string nullable: true - cueout: + cue_out: type: string nullable: true - fadein: + fade_in: type: string format: time nullable: true - fadeout: + fade_out: type: string format: time nullable: true @@ -6878,10 +6886,15 @@ components: type: string format: uri readOnly: true + group: + type: integer + maximum: 2147483647 + minimum: -2147483648 + nullable: true criteria: type: string maxLength: 32 - modifier: + condition: type: string maxLength: 16 value: @@ -6891,11 +6904,6 @@ components: type: string nullable: true maxLength: 512 - criteriagroup: - type: integer - maximum: 2147483647 - minimum: -2147483648 - nullable: true block: type: string format: uri @@ -7121,7 +7129,7 @@ components: readOnly: true kind: allOf: - - $ref: "#/components/schemas/KindEnum" + - $ref: "#/components/schemas/Kind1d2Enum" minimum: -32768 maximum: 32767 position: @@ -7716,17 +7724,17 @@ components: type: string format: uri readOnly: true + created_at: + type: string + format: date-time + nullable: true + updated_at: + type: string + format: date-time + nullable: true name: type: string maxLength: 255 - mtime: - type: string - format: date-time - nullable: true - utime: - type: string - format: date-time - nullable: true description: type: string nullable: true @@ -7734,11 +7742,13 @@ components: length: type: string nullable: true - type: - type: string + kind: nullable: true - maxLength: 7 - creator: + oneOf: + - $ref: "#/components/schemas/SmartBlockKindEnum" + - $ref: "#/components/schemas/BlankEnum" + - $ref: "#/components/schemas/NullEnum" + owner: type: string format: uri nullable: true @@ -7757,23 +7767,23 @@ components: maximum: 2147483647 minimum: -2147483648 nullable: true - trackoffset: + offset: type: number format: double - cliplength: + length: type: string nullable: true - cuein: + cue_in: type: string nullable: true - cueout: + cue_out: type: string nullable: true - fadein: + fade_in: type: string format: time nullable: true - fadeout: + fade_out: type: string format: time nullable: true @@ -7787,7 +7797,7 @@ components: nullable: true required: - item_url - - trackoffset + - offset SmartBlockCriteria: type: object properties: @@ -7795,10 +7805,15 @@ components: type: string format: uri readOnly: true + group: + type: integer + maximum: 2147483647 + minimum: -2147483648 + nullable: true criteria: type: string maxLength: 32 - modifier: + condition: type: string maxLength: 16 value: @@ -7808,20 +7823,20 @@ components: type: string nullable: true maxLength: 512 - criteriagroup: - type: integer - maximum: 2147483647 - minimum: -2147483648 - nullable: true block: type: string format: uri required: - block + - condition - criteria - item_url - - modifier - value + SmartBlockKindEnum: + enum: + - static + - dynamic + type: string StationPodcast: type: object properties: