2021-11-20 08:05:08 +00:00
|
|
|
import datetime as dt
|
|
|
|
|
2021-11-21 07:06:35 +00:00
|
|
|
import pytz
|
|
|
|
from django.http import JsonResponse
|
2021-11-20 16:46:05 +00:00
|
|
|
from django.views.generic import FormView
|
2021-11-20 08:05:08 +00:00
|
|
|
from django.views.generic.base import TemplateView
|
|
|
|
from pretalx.agenda.views.schedule import ScheduleMixin
|
2021-11-21 12:30:31 +00:00
|
|
|
from pretalx.common.mixins.views import EventPermissionRequired, PermissionRequired
|
2021-11-20 08:05:08 +00:00
|
|
|
from pretalx.schedule.exporters import ScheduleData
|
|
|
|
|
2021-11-22 11:09:01 +00:00
|
|
|
from .forms import BroadcastToolsSettingsForm
|
2021-11-20 16:46:05 +00:00
|
|
|
|
2021-11-20 08:05:08 +00:00
|
|
|
|
2021-11-22 11:09:01 +00:00
|
|
|
class BroadcastToolsLowerThirdsView(TemplateView):
|
|
|
|
template_name = "pretalx_broadcast_tools/lower_thirds.html"
|
2021-11-20 08:05:08 +00:00
|
|
|
|
|
|
|
|
2021-11-22 11:09:01 +00:00
|
|
|
class BroadcastToolsOrgaView(PermissionRequired, FormView):
|
|
|
|
form_class = BroadcastToolsSettingsForm
|
2021-11-21 07:06:35 +00:00
|
|
|
permission_required = "orga.change_settings"
|
2021-11-22 11:09:01 +00:00
|
|
|
template_name = "pretalx_broadcast_tools/orga.html"
|
2021-11-20 16:46:05 +00:00
|
|
|
|
|
|
|
def get_success_url(self):
|
|
|
|
return self.request.path
|
|
|
|
|
|
|
|
def form_valid(self, form):
|
|
|
|
form.save()
|
|
|
|
return super().form_valid(form)
|
|
|
|
|
|
|
|
def get_object(self):
|
|
|
|
return self.request.event
|
|
|
|
|
|
|
|
def get_form_kwargs(self):
|
|
|
|
kwargs = super().get_form_kwargs()
|
2021-11-21 07:06:35 +00:00
|
|
|
return {
|
|
|
|
"obj": self.request.event,
|
|
|
|
"attribute_name": "settings",
|
2021-11-21 12:07:19 +00:00
|
|
|
"locales": self.request.event.locales,
|
2021-11-21 07:06:35 +00:00
|
|
|
**kwargs,
|
|
|
|
}
|
2021-11-20 16:46:05 +00:00
|
|
|
|
|
|
|
|
2021-11-22 11:09:01 +00:00
|
|
|
class BroadcastToolsEventInfoView(TemplateView):
|
2021-11-22 09:14:25 +00:00
|
|
|
def get(self, request, *args, **kwargs):
|
2021-11-22 09:26:49 +00:00
|
|
|
color = self.request.event.primary_color or "#3aa57c"
|
2021-11-22 09:14:25 +00:00
|
|
|
return JsonResponse(
|
|
|
|
{
|
|
|
|
"slug": self.request.event.slug,
|
|
|
|
"name": str(self.request.event.name),
|
|
|
|
"no_talk": str(self.request.event.settings.lower_thirds_no_talk_info),
|
|
|
|
"color": color,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-11-22 11:09:01 +00:00
|
|
|
class BroadcastToolsScheduleView(EventPermissionRequired, ScheduleMixin, TemplateView):
|
2021-11-20 08:05:08 +00:00
|
|
|
permission_required = "agenda.view_schedule"
|
|
|
|
|
|
|
|
def get(self, request, *args, **kwargs):
|
|
|
|
schedule = ScheduleData(
|
|
|
|
event=self.request.event,
|
|
|
|
schedule=self.schedule,
|
|
|
|
)
|
|
|
|
tz = pytz.timezone(schedule.event.timezone)
|
2021-11-21 09:06:45 +00:00
|
|
|
infoline = str(schedule.event.settings.infoline or "")
|
2021-11-20 08:05:08 +00:00
|
|
|
return JsonResponse(
|
|
|
|
{
|
2021-11-21 07:06:35 +00:00
|
|
|
"rooms": sorted(
|
|
|
|
{
|
|
|
|
str(room["name"])
|
|
|
|
for day in schedule.data
|
|
|
|
for room in day["rooms"]
|
|
|
|
}
|
|
|
|
),
|
2021-11-20 08:05:08 +00:00
|
|
|
"talks": [
|
|
|
|
{
|
|
|
|
"id": talk.submission.id,
|
|
|
|
"start": talk.start.astimezone(tz).isoformat(),
|
2021-11-21 12:30:31 +00:00
|
|
|
"end": (talk.start + dt.timedelta(minutes=talk.duration))
|
|
|
|
.astimezone(tz)
|
|
|
|
.isoformat(),
|
2021-11-20 08:05:08 +00:00
|
|
|
"slug": talk.frab_slug,
|
|
|
|
"title": talk.submission.title,
|
2021-11-21 07:06:35 +00:00
|
|
|
"persons": sorted(
|
|
|
|
{
|
|
|
|
person.get_display_name()
|
|
|
|
for person in talk.submission.speakers.all()
|
|
|
|
}
|
|
|
|
),
|
2021-11-20 08:05:08 +00:00
|
|
|
"track": {
|
|
|
|
"color": talk.submission.track.color,
|
|
|
|
"name": str(talk.submission.track.name),
|
2021-11-21 07:06:35 +00:00
|
|
|
}
|
|
|
|
if talk.submission.track
|
|
|
|
else None,
|
2021-11-20 08:05:08 +00:00
|
|
|
"room": str(room["name"]),
|
2021-11-21 09:06:45 +00:00
|
|
|
"infoline": infoline.format(
|
2021-11-20 16:46:05 +00:00
|
|
|
EVENT_SLUG=str(schedule.event.slug),
|
|
|
|
TALK_SLUG=talk.frab_slug,
|
|
|
|
CODE=talk.submission.code,
|
|
|
|
),
|
2021-11-20 08:05:08 +00:00
|
|
|
}
|
|
|
|
for day in schedule.data
|
|
|
|
for room in day["rooms"]
|
|
|
|
for talk in room["talks"]
|
|
|
|
],
|
|
|
|
},
|
|
|
|
)
|