From dfa0945632cac3cad973d9ff10a43cfd8c933a6c Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Thu, 31 Oct 2024 21:46:55 +0100 Subject: [PATCH] move room detection to room uuid --- .../static/pretalx_broadcast_tools/generic.js | 8 +++-- .../pretalx_broadcast_tools/orga.html | 32 +++++++++---------- pretalx_broadcast_tools/views/event_info.py | 4 +++ pretalx_broadcast_tools/views/orga.py | 8 ----- 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/pretalx_broadcast_tools/static/pretalx_broadcast_tools/generic.js b/pretalx_broadcast_tools/static/pretalx_broadcast_tools/generic.js index b9190f1..b1d5976 100644 --- a/pretalx_broadcast_tools/static/pretalx_broadcast_tools/generic.js +++ b/pretalx_broadcast_tools/static/pretalx_broadcast_tools/generic.js @@ -61,14 +61,16 @@ function get_next_talk() { } function get_room_name() { - room_name = null; try { hash = decodeURIComponent(window.location.hash.substring(1)); - room_name = hash; } catch (e) { console.error(e); } - return room_name; + if (event_info && event_info["rooms"].hasOwnProperty(hash)) { + return event_info["rooms"][hash]; + } + // XXX remove fallback when releasing 3.0.0 + return hash; } function format_time_from_pretalx(from_pretalx) { diff --git a/pretalx_broadcast_tools/templates/pretalx_broadcast_tools/orga.html b/pretalx_broadcast_tools/templates/pretalx_broadcast_tools/orga.html index 8a01071..1804bbf 100644 --- a/pretalx_broadcast_tools/templates/pretalx_broadcast_tools/orga.html +++ b/pretalx_broadcast_tools/templates/pretalx_broadcast_tools/orga.html @@ -7,25 +7,23 @@

{% translate "broadcasting tools" %}

- {% if localized_rooms %} - - +
+ + + + + + + + {% for room in request.event.rooms.all %} - - + + + - - - {% for room in localized_rooms %} - - - - - - {% endfor %} - -
{% translate "room" %}{% translate "Feature" %}
{% translate "room" %}{% translate "Feature" %}{{ room.name }}{% translate "Lower Thirds" %}{% translate "Room Info" %}
{{ room }}{% translate "Lower Thirds" %}{% translate "Room Info" %}
- {% endif %} + {% endfor %} + +

{% translate "Placeholders" %}

{% translate "pretalx will automatically replace some placeholders in your custom content:" %}

diff --git a/pretalx_broadcast_tools/views/event_info.py b/pretalx_broadcast_tools/views/event_info.py index 6415f74..c6e3adf 100644 --- a/pretalx_broadcast_tools/views/event_info.py +++ b/pretalx_broadcast_tools/views/event_info.py @@ -21,6 +21,10 @@ class BroadcastToolsEventInfoView(View): else False ), }, + "rooms": { + str(room.uuid): room.name.localize(self.request.event.locale) + for room in self.request.event.rooms.all() + }, "slug": self.request.event.slug, "start": self.request.event.date_from.isoformat(), "end": self.request.event.date_to.isoformat(), diff --git a/pretalx_broadcast_tools/views/orga.py b/pretalx_broadcast_tools/views/orga.py index 6eba32a..3bf28e6 100644 --- a/pretalx_broadcast_tools/views/orga.py +++ b/pretalx_broadcast_tools/views/orga.py @@ -12,14 +12,6 @@ class BroadcastToolsOrgaView(PermissionRequired, FormView): def get_success_url(self): return self.request.path - def get_context_data(self, **kwargs): - context = super().get_context_data(**kwargs) - context["localized_rooms"] = [ - room.name.localize(self.request.event.locale) - for room in self.request.event.rooms.all() - ] - return context - def form_valid(self, form): form.save() return super().form_valid(form)