diff --git a/pretalx_lower_thirds/apps.py b/pretalx_lower_thirds/apps.py index 87d227c..3ba30b2 100644 --- a/pretalx_lower_thirds/apps.py +++ b/pretalx_lower_thirds/apps.py @@ -9,7 +9,11 @@ class PluginApp(AppConfig): class PretalxPluginMeta: name = gettext_lazy("Lower Thirds") 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 version = "0.0.0" diff --git a/pretalx_lower_thirds/forms.py b/pretalx_lower_thirds/forms.py index b8eb5da..79ac844 100644 --- a/pretalx_lower_thirds/forms.py +++ b/pretalx_lower_thirds/forms.py @@ -5,13 +5,16 @@ from hierarkey.forms import HierarkeyForm class LowerThirdsSettingsForm(HierarkeyForm): lower_thirds_no_talk_info = forms.CharField( - help_text='Will be shown as talk title if there\'s currently no talk running.', - initial = 'Sorry, there\'s currently no talk running', - label='"no talk running" information', + help_text=_( + "Will be shown as talk title if there's currently no talk " + "running." + ), + initial="Sorry, there's currently no talk running", + label=_('"no talk running" information'), required=True, ) lower_thirds_info_string = forms.CharField( - initial='', - label='info line', + initial="", + label=_("info line"), required=False, ) diff --git a/pretalx_lower_thirds/signals.py b/pretalx_lower_thirds/signals.py index ed713a7..ebc2a45 100644 --- a/pretalx_lower_thirds/signals.py +++ b/pretalx_lower_thirds/signals.py @@ -7,12 +7,18 @@ from pretalx.orga.signals import nav_event_settings @receiver(nav_event_settings) def navbar_info(sender, request, **kwargs): 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 [{ - 'label': _('lower thirds'), - 'url': reverse('plugins:pretalx_lower_thirds:orga', kwargs={ - 'event': request.event.slug, - }), - 'active': url.namespace == 'plugins:pretalx_lower_thirds' and url.url_name == 'orga', - }] + return [ + { + "label": _("lower thirds"), + "url": reverse( + "plugins:pretalx_lower_thirds:orga", + kwargs={ + "event": request.event.slug, + }, + ), + "active": url.namespace == "plugins:pretalx_lower_thirds" + and url.url_name == "orga", + } + ] diff --git a/pretalx_lower_thirds/templates/pretalx_lower_thirds/lower_thirds.html b/pretalx_lower_thirds/templates/pretalx_lower_thirds/lower_thirds.html index ff715ca..1d8d27f 100644 --- a/pretalx_lower_thirds/templates/pretalx_lower_thirds/lower_thirds.html +++ b/pretalx_lower_thirds/templates/pretalx_lower_thirds/lower_thirds.html @@ -6,7 +6,7 @@ {{ request.event.name }} lower thirds {% compress js %} - + {% endcompress %} diff --git a/pretalx_lower_thirds/templates/pretalx_lower_thirds/orga.html b/pretalx_lower_thirds/templates/pretalx_lower_thirds/orga.html index 11717a0..63ad0db 100644 --- a/pretalx_lower_thirds/templates/pretalx_lower_thirds/orga.html +++ b/pretalx_lower_thirds/templates/pretalx_lower_thirds/orga.html @@ -23,12 +23,12 @@

{% if request.event.rooms %} -

{% trans "room list" %}

- +

{% trans "room list" %}

+ {% endif %}
diff --git a/pretalx_lower_thirds/urls.py b/pretalx_lower_thirds/urls.py index c672a10..9c44df7 100644 --- a/pretalx_lower_thirds/urls.py +++ b/pretalx_lower_thirds/urls.py @@ -1,5 +1,4 @@ from django.urls import re_path - from pretalx.event.models.event import SLUG_CHARS from . import views @@ -15,7 +14,6 @@ urlpatterns = [ views.ScheduleView.as_view(), name="schedule", ), - re_path( f"^orga/event/(?P[{SLUG_CHARS}]+)/p/lower-thirds/$", views.LowerThirdsOrgaView.as_view(), diff --git a/pretalx_lower_thirds/views.py b/pretalx_lower_thirds/views.py index cc701bd..f3e3fdb 100644 --- a/pretalx_lower_thirds/views.py +++ b/pretalx_lower_thirds/views.py @@ -1,23 +1,14 @@ import datetime as dt -import json -import pytz -import random -from django.contrib import messages -from django.db.models import Case, OuterRef, Subquery, When -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 _ +import pytz +from django.http import JsonResponse from django.views.generic import FormView from django.views.generic.base import TemplateView -from django_context_decorator import context - from pretalx.agenda.views.schedule import ScheduleMixin -from pretalx.common.mixins.views import EventPermissionRequired, PermissionRequired -from pretalx.common.signals import register_data_exporters +from pretalx.common.mixins.views import ( + EventPermissionRequired, + PermissionRequired, +) from pretalx.schedule.exporters import ScheduleData from .forms import LowerThirdsSettingsForm @@ -29,7 +20,7 @@ class LowerThirdsView(TemplateView): class LowerThirdsOrgaView(PermissionRequired, FormView): form_class = LowerThirdsSettingsForm - permission_required = 'orga.change_settings' + permission_required = "orga.change_settings" template_name = "pretalx_lower_thirds/orga.html" def get_success_url(self): @@ -44,7 +35,11 @@ class LowerThirdsOrgaView(PermissionRequired, FormView): def get_form_kwargs(self): 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): @@ -63,27 +58,38 @@ class ScheduleView(EventPermissionRequired, ScheduleMixin, TemplateView): "name": str(schedule.event.name), "no_talk": str(schedule.event.settings.lower_thirds_no_talk_info), }, - "rooms": sorted({ - str(room["name"]) - for day in schedule.data - for room in day["rooms"] - }), + "rooms": sorted( + { + str(room["name"]) + for day in schedule.data + for room in day["rooms"] + } + ), "talks": [ { "id": talk.submission.id, "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, "title": talk.submission.title, - "persons": sorted({ - person.get_display_name() for person in talk.submission.speakers.all() - }), + "persons": sorted( + { + person.get_display_name() + for person in talk.submission.speakers.all() + } + ), "track": { "color": talk.submission.track.color, "name": str(talk.submission.track.name), - } if talk.submission.track else None, + } + if talk.submission.track + else None, "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), TALK_SLUG=talk.frab_slug, CODE=talk.submission.code, diff --git a/setup.py b/setup.py index 043fd30..6473dd8 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,11 @@ cmdclass = {"build": CustomBuild} setup( name="pretalx-plugin-lower-thirds", 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, url="https://git.franzi.business/kunsi/pretalx-plugin-lower-thirds", author="kunsi",