Skip to content
Snippets Groups Projects
Commit e5257db2 authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

refactor: move ProgramEntry into models

parent 261e297c
No related branches found
No related tags found
1 merge request!52new program endpoint
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
import dataclasses
import datetime
import jsonschema import jsonschema
from rest_framework.exceptions import ValidationError from rest_framework.exceptions import ValidationError
from versatileimagefield.fields import PPOIField, VersatileImageField from versatileimagefield.fields import PPOIField, VersatileImageField
...@@ -687,3 +690,12 @@ class RadioSettings(models.Model): ...@@ -687,3 +690,12 @@ class RadioSettings(models.Model):
def __str__(self): def __str__(self):
return self.station_name return self.station_name
@dataclasses.dataclass()
class ProgramEntry:
id: str
start: datetime.datetime
end: datetime.datetime
show: Show
timeslot: TimeSlot | None
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
import copy import copy
from collections.abc import Iterator from collections.abc import Iterator
from datetime import datetime, time, timedelta from datetime import datetime, time, timedelta
from typing import TypedDict
from dateutil.relativedelta import relativedelta from dateutil.relativedelta import relativedelta
from dateutil.rrule import rrule from dateutil.rrule import rrule
...@@ -33,6 +32,7 @@ from django.utils import timezone ...@@ -33,6 +32,7 @@ from django.utils import timezone
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from program.models import ( from program.models import (
Note, Note,
ProgramEntry,
RadioSettings, RadioSettings,
RRule, RRule,
Schedule, Schedule,
...@@ -699,14 +699,6 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts: ...@@ -699,14 +699,6 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts:
return conflicts return conflicts
class ProgramEntry(TypedDict):
id: str
start: datetime
end: datetime
show: Show
timeslot: TimeSlot | None
def generate_program_entries( def generate_program_entries(
queryset: QuerySet[TimeSlot], queryset: QuerySet[TimeSlot],
*, *,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment