1
0
Fork 0
mirror of https://github.com/Kunsi/pretalx-plugin-broadcast-tools synced 2024-11-22 06:01:03 +00:00

fix code style

This commit is contained in:
Franzi 2021-11-21 08:06:35 +01:00
parent e0a2ba53b6
commit 375374d65d
Signed by: kunsi
GPG key ID: 12E3D2136B818350
8 changed files with 73 additions and 52 deletions

View file

@ -9,7 +9,11 @@ class PluginApp(AppConfig):
class PretalxPluginMeta: class PretalxPluginMeta:
name = gettext_lazy("Lower Thirds") name = gettext_lazy("Lower Thirds")
author = "kunsi" author = "kunsi"
description = gettext_lazy("Creates lower thirds from your current schedule. Will show speaker names and talk title using the configured track and event colours.") description = gettext_lazy(
"Creates lower thirds from your current schedule. Will show "
"speaker names and talk title using the configured track and "
"event colours."
)
visible = True visible = True
version = "0.0.0" version = "0.0.0"

View file

@ -5,13 +5,16 @@ from hierarkey.forms import HierarkeyForm
class LowerThirdsSettingsForm(HierarkeyForm): class LowerThirdsSettingsForm(HierarkeyForm):
lower_thirds_no_talk_info = forms.CharField( lower_thirds_no_talk_info = forms.CharField(
help_text='Will be shown as talk title if there\'s currently no talk running.', help_text=_(
initial = 'Sorry, there\'s currently no talk running', "Will be shown as talk title if there's currently no talk "
label='"no talk running" information', "running."
),
initial="Sorry, there's currently no talk running",
label=_('"no talk running" information'),
required=True, required=True,
) )
lower_thirds_info_string = forms.CharField( lower_thirds_info_string = forms.CharField(
initial='', initial="",
label='info line', label=_("info line"),
required=False, required=False,
) )

View file

@ -7,12 +7,18 @@ from pretalx.orga.signals import nav_event_settings
@receiver(nav_event_settings) @receiver(nav_event_settings)
def navbar_info(sender, request, **kwargs): def navbar_info(sender, request, **kwargs):
url = resolve(request.path_info) url = resolve(request.path_info)
if not request.user.has_perm('orga.change_settings', request.event): if not request.user.has_perm("orga.change_settings", request.event):
return [] return []
return [{ return [
'label': _('lower thirds'), {
'url': reverse('plugins:pretalx_lower_thirds:orga', kwargs={ "label": _("lower thirds"),
'event': request.event.slug, "url": reverse(
}), "plugins:pretalx_lower_thirds:orga",
'active': url.namespace == 'plugins:pretalx_lower_thirds' and url.url_name == 'orga', kwargs={
}] "event": request.event.slug,
},
),
"active": url.namespace == "plugins:pretalx_lower_thirds"
and url.url_name == "orga",
}
]

View file

@ -6,7 +6,7 @@
<meta http-equiv="content-type" content="text/html" charset="UTF-8"> <meta http-equiv="content-type" content="text/html" charset="UTF-8">
<title>{{ request.event.name }} lower thirds</title> <title>{{ request.event.name }} lower thirds</title>
{% compress js %} {% compress js %}
<script src="{% static "vendored/jquery-3.1.1.js" %}"></script> <script src="{% static "vendored/jquery-3.1.1.js" %}"></script>
{% endcompress %} {% endcompress %}
<script src="{% static "pretalx_lower_thirds/update.js" %}"></script> <script src="{% static "pretalx_lower_thirds/update.js" %}"></script>
<link rel="stylesheet" href="{% static "pretalx_lower_thirds/frontend.css" %}" /> <link rel="stylesheet" href="{% static "pretalx_lower_thirds/frontend.css" %}" />

View file

@ -23,12 +23,12 @@
</p> </p>
{% if request.event.rooms %} {% if request.event.rooms %}
<h3>{% trans "room list" %}</h3> <h3>{% trans "room list" %}</h3>
<ul> <ul>
{% for room in request.event.rooms.all %} {% for room in request.event.rooms.all %}
<li><a href="{% url 'plugins:pretalx_lower_thirds:lowerthirds' request.event %}#{{ room.name }}">{{ room.name }}</a></li> <li><a href="{% url 'plugins:pretalx_lower_thirds:lowerthirds' request.event %}#{{ room.name }}">{{ room.name }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}
<div class="submit-group panel"> <div class="submit-group panel">

View file

@ -1,5 +1,4 @@
from django.urls import re_path from django.urls import re_path
from pretalx.event.models.event import SLUG_CHARS from pretalx.event.models.event import SLUG_CHARS
from . import views from . import views
@ -15,7 +14,6 @@ urlpatterns = [
views.ScheduleView.as_view(), views.ScheduleView.as_view(),
name="schedule", name="schedule",
), ),
re_path( re_path(
f"^orga/event/(?P<event>[{SLUG_CHARS}]+)/p/lower-thirds/$", f"^orga/event/(?P<event>[{SLUG_CHARS}]+)/p/lower-thirds/$",
views.LowerThirdsOrgaView.as_view(), views.LowerThirdsOrgaView.as_view(),

View file

@ -1,23 +1,14 @@
import datetime as dt import datetime as dt
import json
import pytz
import random
from django.contrib import messages import pytz
from django.db.models import Case, OuterRef, Subquery, When from django.http import JsonResponse
from django.http import Http404, JsonResponse
from django.shortcuts import redirect
from django.urls import reverse
from django.utils.functional import cached_property
from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _
from django.views.generic import FormView from django.views.generic import FormView
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from django_context_decorator import context
from pretalx.agenda.views.schedule import ScheduleMixin from pretalx.agenda.views.schedule import ScheduleMixin
from pretalx.common.mixins.views import EventPermissionRequired, PermissionRequired from pretalx.common.mixins.views import (
from pretalx.common.signals import register_data_exporters EventPermissionRequired,
PermissionRequired,
)
from pretalx.schedule.exporters import ScheduleData from pretalx.schedule.exporters import ScheduleData
from .forms import LowerThirdsSettingsForm from .forms import LowerThirdsSettingsForm
@ -29,7 +20,7 @@ class LowerThirdsView(TemplateView):
class LowerThirdsOrgaView(PermissionRequired, FormView): class LowerThirdsOrgaView(PermissionRequired, FormView):
form_class = LowerThirdsSettingsForm form_class = LowerThirdsSettingsForm
permission_required = 'orga.change_settings' permission_required = "orga.change_settings"
template_name = "pretalx_lower_thirds/orga.html" template_name = "pretalx_lower_thirds/orga.html"
def get_success_url(self): def get_success_url(self):
@ -44,7 +35,11 @@ class LowerThirdsOrgaView(PermissionRequired, FormView):
def get_form_kwargs(self): def get_form_kwargs(self):
kwargs = super().get_form_kwargs() kwargs = super().get_form_kwargs()
return {'obj': self.request.event, 'attribute_name': 'settings', **kwargs} return {
"obj": self.request.event,
"attribute_name": "settings",
**kwargs,
}
class ScheduleView(EventPermissionRequired, ScheduleMixin, TemplateView): class ScheduleView(EventPermissionRequired, ScheduleMixin, TemplateView):
@ -63,27 +58,38 @@ class ScheduleView(EventPermissionRequired, ScheduleMixin, TemplateView):
"name": str(schedule.event.name), "name": str(schedule.event.name),
"no_talk": str(schedule.event.settings.lower_thirds_no_talk_info), "no_talk": str(schedule.event.settings.lower_thirds_no_talk_info),
}, },
"rooms": sorted({ "rooms": sorted(
str(room["name"]) {
for day in schedule.data str(room["name"])
for room in day["rooms"] for day in schedule.data
}), for room in day["rooms"]
}
),
"talks": [ "talks": [
{ {
"id": talk.submission.id, "id": talk.submission.id,
"start": talk.start.astimezone(tz).isoformat(), "start": talk.start.astimezone(tz).isoformat(),
"end": (talk.start + dt.timedelta(minutes=talk.duration)).astimezone(tz).isoformat(), "end": (talk.start + dt.timedelta(minutes=talk.duration))
.astimezone(tz)
.isoformat(),
"slug": talk.frab_slug, "slug": talk.frab_slug,
"title": talk.submission.title, "title": talk.submission.title,
"persons": sorted({ "persons": sorted(
person.get_display_name() for person in talk.submission.speakers.all() {
}), person.get_display_name()
for person in talk.submission.speakers.all()
}
),
"track": { "track": {
"color": talk.submission.track.color, "color": talk.submission.track.color,
"name": str(talk.submission.track.name), "name": str(talk.submission.track.name),
} if talk.submission.track else None, }
if talk.submission.track
else None,
"room": str(room["name"]), "room": str(room["name"]),
"infoline": str(schedule.event.settings.lower_thirds_info_string).format( "infoline": str(
schedule.event.settings.lower_thirds_info_string
).format(
EVENT_SLUG=str(schedule.event.slug), EVENT_SLUG=str(schedule.event.slug),
TALK_SLUG=talk.frab_slug, TALK_SLUG=talk.frab_slug,
CODE=talk.submission.code, CODE=talk.submission.code,

View file

@ -25,7 +25,11 @@ cmdclass = {"build": CustomBuild}
setup( setup(
name="pretalx-plugin-lower-thirds", name="pretalx-plugin-lower-thirds",
version="0.0.0", version="0.0.0",
description="Creates lower thirds from your current schedule. Will show speaker names and talk title using the configured track and event colours.", description=(
"Creates lower thirds from your current schedule. Will show "
"speaker names and talk title using the configured track and "
"event colours."
),
long_description=long_description, long_description=long_description,
url="https://git.franzi.business/kunsi/pretalx-plugin-lower-thirds", url="https://git.franzi.business/kunsi/pretalx-plugin-lower-thirds",
author="kunsi", author="kunsi",