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:
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"

View File

@ -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,
)

View File

@ -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",
}
]

View File

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

View File

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

View File

@ -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<event>[{SLUG_CHARS}]+)/p/lower-thirds/$",
views.LowerThirdsOrgaView.as_view(),

View File

@ -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,

View File

@ -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",