Skip to content
Snippets Groups Projects
Commit 749a984d authored by Benjamin Hättasch's avatar Benjamin Hättasch Committed by Nadja Geisler
Browse files

Scheduling: Load events and availabilities using API

Introduce fullcalendar JSON encoding for events and background events/constraints/availabilities
Add them to API endpoints
Use these endpoints instead of static encoding
parent 945411f2
No related branches found
No related tags found
No related merge requests found
...@@ -12,18 +12,32 @@ api_router.register('ak', views.AKViewSet, basename='AK') ...@@ -12,18 +12,32 @@ api_router.register('ak', views.AKViewSet, basename='AK')
api_router.register('room', views.RoomViewSet, basename='Room') api_router.register('room', views.RoomViewSet, basename='Room')
api_router.register('akslot', views.AKSlotViewSet, basename='AKSlot') api_router.register('akslot', views.AKSlotViewSet, basename='AKSlot')
extra_paths = []
if apps.is_installed("AKScheduling"): if apps.is_installed("AKScheduling"):
from AKScheduling.api import ResourcesViewSet from AKScheduling.api import ResourcesViewSet, RoomAvailabilitiesView, EventsView
api_router.register('scheduling-resources', ResourcesViewSet, basename='scheduling-resources') api_router.register('scheduling-resources', ResourcesViewSet, basename='scheduling-resources')
extra_paths = [
path('api/scheduling-events/', EventsView.as_view(), name='scheduling-events'),
path('api/scheduling-room-availabilities/', RoomAvailabilitiesView.as_view(), name='scheduling-room-availabilities'),
]
event_specific_paths = [
path('api/', include(api_router.urls), name='api'),
]
event_specific_paths.extend(extra_paths)
app_name = 'model' app_name = 'model'
urlpatterns = [ urlpatterns = [
path( path(
'<slug:event_slug>/', '<slug:event_slug>/',
include([ include(event_specific_paths)
path('api/', include(api_router.urls), name='api'),
])
), ),
path('user/', views.UserView.as_view(), name="user"), path('user/', views.UserView.as_view(), name="user"),
] ]
...@@ -84,35 +84,9 @@ ...@@ -84,35 +84,9 @@
datesAboveResources: true, datesAboveResources: true,
resourceAreaHeaderContent: '{% trans "Room" %}', resourceAreaHeaderContent: '{% trans "Room" %}',
resources: '{% url "model:scheduling-resources-list" event_slug=event.slug %}', resources: '{% url "model:scheduling-resources-list" event_slug=event.slug %}',
events: [ eventSources: [
{% for slot in akslots %} '{% url "model:scheduling-events" event_slug=event.slug %}',
{% if slot.start %} '{% url "model:scheduling-room-availabilities" event_slug=event.slug %}'
{
'title': '{{ slot.ak.short_name }}',
'description': '{{ slot.ak.name }}',
'start': '{{ slot.start | timezone:event.timezone | date:"Y-m-d H:i:s" }}',
'end': '{{ slot.end | timezone:event.timezone | date:"Y-m-d H:i:s" }}',
'resourceId': '{{ slot.room.title }}',
'backgroundColor': '{{ slot|highlight_change_colors }}',
'borderColor': '{{ slot.ak.category.color }}',
'url': '{% url 'submit:ak_detail' event_slug=event.slug pk=slot.ak.pk %}',
constraint: 'roomAvailable',
},
{% endif %}
{% endfor %}
{% for a in availabilities %}
{% if a.room != None %}
{
title: '',
start: '{{ a.start | timezone:event.timezone | date:"Y-m-d H:i:s" }}',
end: '{{ a.end | timezone:event.timezone | date:"Y-m-d H:i:s" }}',
resourceId: '{{ a.room.title }}',
backgroundColor: '#28B62C',
display: 'background',
groupId: 'roomAvailable',
},
{% endif %}
{% endfor %}
], ],
schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source', schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
dayMinWidth: 100, dayMinWidth: 100,
......
...@@ -33,6 +33,4 @@ class SchedulingAdminView(AdminViewMixin, FilterByEventSlugMixin, ListView): ...@@ -33,6 +33,4 @@ class SchedulingAdminView(AdminViewMixin, FilterByEventSlugMixin, ListView):
context["start"] = self.event.start context["start"] = self.event.start
context["end"] = self.event.end context["end"] = self.event.end
context["availabilities"] = Availability.objects.filter(event=self.event, room__isnull=False)
return context return context
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