Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • add-playlists
  • ci-trigger-aura-tests
  • feat/249-episodes
  • feat/site-data
  • feature/extended-database-env-configuration
  • fix-aura-sysuser
  • fix-push-latest-with-tag
  • fix/media_id_source
  • kmohrf/fix-configuration-error-api-responses
  • kmohrf/id-filters
  • kmohrf/program-calendar-populate-filter
  • kmohrf/virtual-timeslot-fixes
  • main
  • refactor-playout-endpoint-210
  • rename-playlist-playlistentry
  • 1.0.0-alpha1
  • 1.0.0-alpha2
  • 1.0.0-alpha3
  • 1.0.0-alpha4
  • 1.0.0-alpha5
  • 1.0.0-alpha6
21 results

Target

Select target project
  • aura/steering
  • kmohrf/steering
2 results
Select Git revision
  • add-playlists
  • ci-trigger-aura-tests
  • feat/249-episodes
  • feat/site-data
  • feature/extended-database-env-configuration
  • fix-aura-sysuser
  • fix-push-latest-with-tag
  • fix/media_id_source
  • kmohrf/fix-configuration-error-api-responses
  • kmohrf/id-filters
  • kmohrf/program-calendar-populate-filter
  • kmohrf/virtual-timeslot-fixes
  • main
  • refactor-playout-endpoint-210
  • rename-playlist-playlistentry
  • 1.0.0-alpha1
  • 1.0.0-alpha2
  • 1.0.0-alpha3
  • 1.0.0-alpha4
  • 1.0.0-alpha5
  • 1.0.0-alpha6
21 results
Show changes
Commits on Source (20)
...@@ -37,7 +37,7 @@ Setting up the environment ...@@ -37,7 +37,7 @@ Setting up the environment
Create a virtual environment where the dependencies will live:: Create a virtual environment where the dependencies will live::
$ python3 -m venv python $ python3.8 -m venv python
$ source python/bin/activate $ source python/bin/activate
(python)$ (python)$
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
"email": "musikredaktion@helsinki.at", "email": "musikredaktion@helsinki.at",
"website": null, "website": null,
"cba_series_id": null, "cba_series_id": null,
"default_id": null, "default_playlist_id": null,
"created": "1969-12-31T22:00:00Z", "created": "1969-12-31T22:00:00Z",
"last_updated": "1969-12-31T22:00:00Z", "last_updated": "1969-12-31T22:00:00Z",
"is_active": true, "is_active": true,
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
# #
import json import json
import logging
from datetime import date, datetime, time, timedelta from datetime import date, datetime, time, timedelta
from django.contrib.auth.models import User from django.contrib.auth.models import User
...@@ -37,6 +38,7 @@ from program.serializers import TypeSerializer, LanguageSerializer, MusicFocusSe ...@@ -37,6 +38,7 @@ from program.serializers import TypeSerializer, LanguageSerializer, MusicFocusSe
UserSerializer UserSerializer
from program.utils import get_cached_shows from program.utils import get_cached_shows
logger = logging.getLogger(__name__)
def json_day_schedule(request, year=None, month=None, day=None): def json_day_schedule(request, year=None, month=None, day=None):
if year is None and month is None and day is None: if year is None and month is None and day is None:
...@@ -469,9 +471,19 @@ class APIScheduleViewSet(viewsets.ModelViewSet): ...@@ -469,9 +471,19 @@ class APIScheduleViewSet(viewsets.ModelViewSet):
if 'schedule' not in request.data: if 'schedule' not in request.data:
return Response(status=status.HTTP_400_BAD_REQUEST) return Response(status=status.HTTP_400_BAD_REQUEST)
# If we're updating the default playlist id
# TODO: If nothing else than default_playlist_id, automation_id or is_repetition changed -> just save and don't do anything
new_schedule = request.data.get('schedule')
if 'default_playlist_id' in new_schedule:
schedule = get_object_or_404(Schedule, pk=pk, show=show_pk)
schedule.default_playlist_id = int(new_schedule['default_playlist_id'])
schedule.save()
serializer = ScheduleSerializer(schedule)
return Response(serializer.data)
# First update submit -> return projected timeslots and collisions # First update submit -> return projected timeslots and collisions
if 'solutions' not in request.data: if 'solutions' not in request.data:
# TODO: If nothing else than default_playlist_id, automation_id or is_repetition changed -> just save and don't do anything
return Response(Schedule.make_conflicts(request.data['schedule'], pk, show_pk)) return Response(Schedule.make_conflicts(request.data['schedule'], pk, show_pk))
# Otherwise try to resolve # Otherwise try to resolve
...@@ -507,6 +519,7 @@ class APITimeSlotViewSet(viewsets.ModelViewSet): ...@@ -507,6 +519,7 @@ class APITimeSlotViewSet(viewsets.ModelViewSet):
/timeslots/{pk} eturns the given timeslot (GET) /timeslots/{pk} eturns the given timeslot (GET)
/timeslots/?start={start_date}&end={end_date} returns timeslots within the time range (GET) /timeslots/?start={start_date}&end={end_date} returns timeslots within the time range (GET)
/shows/{show_pk}/timeslots returns timeslots of the show (GET, POST) /shows/{show_pk}/timeslots returns timeslots of the show (GET, POST)
/shows/{show_pk}/timeslots?surrounding returns the 10 nearest timeslots for the current date (GET)
/shows/{show_pk}/timeslots/{pk} returns a timeslots by its ID (GET, PUT, DELETE) /shows/{show_pk}/timeslots/{pk} returns a timeslots by its ID (GET, PUT, DELETE)
/shows/{show_pk}/timeslots/?start={start_date}&end={end_date} returns timeslots of the show within the time range /shows/{show_pk}/timeslots/?start={start_date}&end={end_date} returns timeslots of the show within the time range
/shows/{show_pk}/schedules/{schedule_pk}/timeslots returns all timeslots of the schedule (GET, POST) /shows/{show_pk}/schedules/{schedule_pk}/timeslots returns all timeslots of the schedule (GET, POST)
...@@ -522,7 +535,6 @@ class APITimeSlotViewSet(viewsets.ModelViewSet): ...@@ -522,7 +535,6 @@ class APITimeSlotViewSet(viewsets.ModelViewSet):
def get_queryset(self): def get_queryset(self):
show_pk = int_or_none('show_pk', self.kwargs) show_pk = int_or_none('show_pk', self.kwargs)
schedule_pk = int_or_none('schedule_pk', self.kwargs) schedule_pk = int_or_none('schedule_pk', self.kwargs)
# Filters # Filters
# Return next 60 days by default # Return next 60 days by default
...@@ -533,6 +545,25 @@ class APITimeSlotViewSet(viewsets.ModelViewSet): ...@@ -533,6 +545,25 @@ class APITimeSlotViewSet(viewsets.ModelViewSet):
start = datetime.combine(datetime.strptime(self.request.query_params.get('start'), '%Y-%m-%d').date(), time(0, 0)) start = datetime.combine(datetime.strptime(self.request.query_params.get('start'), '%Y-%m-%d').date(), time(0, 0))
end = datetime.combine(datetime.strptime(self.request.query_params.get('end'), '%Y-%m-%d').date(), time(23, 59)) end = datetime.combine(datetime.strptime(self.request.query_params.get('end'), '%Y-%m-%d').date(), time(23, 59))
default_order = '-start'
order = self.request.query_params.get('order', default_order)
# If someone tries to sort by a field that isn't available on the model
# we silently ignore that and use the default sort order.
model_fields = [field.name for field in TimeSlot._meta.get_fields()]
if order.lstrip('-') not in model_fields:
order = default_order
if 'surrounding' in self.request.query_params:
today = datetime.today()
nearest_timeslots_in_future = TimeSlot.objects.filter(start__gte=today).order_by('start').values_list('id', flat=True)[:5]
nearest_timeslots_in_past = TimeSlot.objects.filter(start__lt=today).order_by('-start').values_list('id', flat=True)[:5]
relevant_timeslot_ids = list(nearest_timeslots_in_future) + list(nearest_timeslots_in_past)
return TimeSlot.objects.filter(id__in=relevant_timeslot_ids).order_by(order)
# Endpoints # Endpoints
# #
...@@ -541,7 +572,7 @@ class APITimeSlotViewSet(viewsets.ModelViewSet): ...@@ -541,7 +572,7 @@ class APITimeSlotViewSet(viewsets.ModelViewSet):
# Returns timeslots of the given show and schedule # Returns timeslots of the given show and schedule
# #
if show_pk and schedule_pk: if show_pk and schedule_pk:
return TimeSlot.objects.filter(show=show_pk, schedule=schedule_pk, start__gte=start, end__lte=end).order_by('start') return TimeSlot.objects.filter(show=show_pk, schedule=schedule_pk, start__gte=start, end__lte=end).order_by(order)
# #
# /shows/1/timeslots/ # /shows/1/timeslots/
...@@ -549,7 +580,7 @@ class APITimeSlotViewSet(viewsets.ModelViewSet): ...@@ -549,7 +580,7 @@ class APITimeSlotViewSet(viewsets.ModelViewSet):
# Returns timeslots of the show # Returns timeslots of the show
# #
elif show_pk and schedule_pk is None: elif show_pk and schedule_pk is None:
return TimeSlot.objects.filter(show=show_pk, start__gte=start, end__lte=end).order_by('start') return TimeSlot.objects.filter(show=show_pk, start__gte=start, end__lte=end).order_by(order)
# #
# /timeslots/ # /timeslots/
...@@ -557,12 +588,13 @@ class APITimeSlotViewSet(viewsets.ModelViewSet): ...@@ -557,12 +588,13 @@ class APITimeSlotViewSet(viewsets.ModelViewSet):
# Returns all timeslots # Returns all timeslots
# #
else: else:
return TimeSlot.objects.filter(start__gte=start, end__lte=end).order_by('start') return TimeSlot.objects.filter(start__gte=start, end__lte=end).order_by(order)
def retrieve(self, request, *args, **kwargs): def retrieve(self, request, *args, **kwargs):
pk = int_or_none('pk', self.kwargs) pk = int_or_none('pk', self.kwargs)
show_pk = int_or_none('show_pk', self.kwargs) show_pk = int_or_none('show_pk', self.kwargs)
if show_pk: if show_pk:
timeslot = get_object_or_404(TimeSlot, pk=pk, show=show_pk) timeslot = get_object_or_404(TimeSlot, pk=pk, show=show_pk)
else: else:
......
...@@ -16,10 +16,10 @@ docker="false" ...@@ -16,10 +16,10 @@ docker="false"
# - docker:build # - docker:build
# - docker:push # - docker:push
# - docker:serve # - docker:serve
# #
if [[ $* =~ ^(init|dev|prod|test|build|push|serve)$ ]]; then if [[ $* =~ ^(init|dev|prod|test|build|push|serve)$ ]]; then
mode=$1 mode=$1
fi fi
if [[ "$1" == *"docker:"* ]]; then if [[ "$1" == *"docker:"* ]]; then
...@@ -41,7 +41,9 @@ if [[ $docker == "false" ]]; then ...@@ -41,7 +41,9 @@ if [[ $docker == "false" ]]; then
if [[ $mode == "init" ]]; then if [[ $mode == "init" ]]; then
echo "Creating Python VirtualEnvironment" echo "Creating Python VirtualEnvironment"
virtualenv -p python3.6 python python3.8 -m venv python
echo "Activate Environment"
source python/bin/activate
echo "Install dependencies" echo "Install dependencies"
pip3 install -r requirements.txt pip3 install -r requirements.txt
echo "Next you need to create the configuration, run fixtues, migrations and create a superuser." echo "Next you need to create the configuration, run fixtues, migrations and create a superuser."
......