diff --git a/program/views.py b/program/views.py index 8bf9aa954ed80bbb657d63e0c1f177bfd1348642..83fca0586b747a9a975cbb315537c54bead8fdd1 100644 --- a/program/views.py +++ b/program/views.py @@ -28,13 +28,12 @@ from django_filters.rest_framework import DjangoFilterBackend from drf_spectacular.utils import OpenApiResponse, extend_schema, extend_schema_view from rest_framework import filters as drf_filters from rest_framework import mixins, permissions, status, viewsets -from rest_framework.exceptions import ValidationError from rest_framework.pagination import LimitOffsetPagination from rest_framework.response import Response from django.contrib.auth.models import User from django.db import IntegrityError -from django.http import Http404, HttpResponse, JsonResponse +from django.http import HttpResponse, JsonResponse from django.shortcuts import get_object_or_404 from django.utils import timezone from django.utils.translation import gettext as _ @@ -730,27 +729,6 @@ class APINoteViewSet( else: return Note.objects.filter(timeslot__schedule__show__owners=user) - def _get_timeslot(self): - # TODO: Once we remove nested routes, timeslot ownership - # should be checked in a permission class. - timeslot_pk = self.request.data.get("timeslot_id", None) - if timeslot_pk is None: - timeslot_pk = get_values(self.kwargs, "timeslot_pk") - if timeslot_pk is None: - raise ValidationError({"timeslot_id": [_("This field is required.")]}, code="required") - qs = TimeSlot.objects.all() - if not self.request.user.is_superuser: - qs = qs.filter(schedule__show__owners=self.request.user) - try: - return qs.get(pk=timeslot_pk) - except TimeSlot.DoesNotExist: - raise Http404() - - def perform_create(self, serializer): - # TODO: Once we remove nested routes, this should be removed - # and timeslot should be required in the serializer again. - serializer.save(timeslot=self._get_timeslot()) - class ActiveFilterMixin: filter_class = filters.ActiveFilterSet