diff --git a/src/core/models/rooms.py b/src/core/models/rooms.py index 5543aaa592aaf36ed90cf211528029b306de5188..b39912814d09aa8c1e4a318ff58ab419e1cd818f 100644 --- a/src/core/models/rooms.py +++ b/src/core/models/rooms.py @@ -10,7 +10,8 @@ from django.contrib.contenttypes.fields import GenericRelation from django.contrib.postgres.fields import DateTimeRangeField from django.core.exceptions import ValidationError from django.db import models -from django.db.models import Q, QuerySet +from django.db.models import ObjectDoesNotExist, Q, QuerySet +from django.utils import timezone from django.utils.text import slugify from django.utils.translation import gettext_lazy as _ @@ -421,6 +422,24 @@ class Room(BackendMixin, ActivityLogMixin, models.Model): obj.clean() return obj + def get_current_event(self): + now = timezone.now() + + try: + event = self.events.conference_accessible(self.conference).get(schedule_start__lte=now, schedule_end__gte=now) + return event + except ObjectDoesNotExist: + return None + + def get_next_event(self): + now = timezone.now() + + try: + event = self.events.conference_accessible(self.conference).filter(schedule_start__gt=now).order_by('schedule_start').first() + return event + except ObjectDoesNotExist: + return None + class RoomShare(models.Model): class Meta: diff --git a/src/plainui/jinja2/plainui/index.html.j2 b/src/plainui/jinja2/plainui/index.html.j2 index 2dfb5392eebdc3a9db0113c1d29d8b05a1526623..dde0372bc8ff1ae2472e0a010629c95d42712521 100644 --- a/src/plainui/jinja2/plainui/index.html.j2 +++ b/src/plainui/jinja2/plainui/index.html.j2 @@ -23,10 +23,26 @@ {% if conf.is_running and public_streams %} <div class="hub-hlayout"> {% for stream in public_streams %} - <div class="hub-card hub-layout-equal"> - <h2 class="hub-section-title">{{ stream.name }}</h2> - {{ integrations.vocPlayer(playerId="player-" ~ stream.slug) }} - </div> + {% with event = stream.get_current_event() %} + <div class="hub-card hub-layout-equal hub-vlayout"> + {{ integrations.vocPlayer(playerId="player-" ~ stream.slug) }} + <small class="hub-index-stream__name"> + {% if event %} + {{ _("Now: %(name)", name=event.name) }} + {% else %} + {% with next_event = stream.get_next_event() %} + {% if next_event %} + {% set next_event_time = next_event.schedule_start | strftimehm %} + {{ _("Next (%(time)s): %(name)s", time=next_event_time, name=next_event.name) }} + {% endif %} + {% endwith %} + {% endif %} + </small> + <div> + <a class="hub-btn" href="{{ url('plainui:room', stream.slug) }}">{{ stream.name }}</a> + </div> + </div> + {% endwith %} {% endfor %} </div> {% endif %} diff --git a/src/plainui/locale/de/LC_MESSAGES/django.po b/src/plainui/locale/de/LC_MESSAGES/django.po index 352e3ff8b64945aff06a57c982ebe8d8fba80102..bae6a2b1903a26e6d68dd02c37001b954f36b2e9 100644 --- a/src/plainui/locale/de/LC_MESSAGES/django.po +++ b/src/plainui/locale/de/LC_MESSAGES/django.po @@ -1010,6 +1010,13 @@ msgstr "" msgid "Your timezone is configured to %(user_timezone)s, conference timezone is %(conf_timezone)s, showing times in your timezone" msgstr "Deine Zeitzone ist auf %(user_timezone)s konfiguriert, die Konferenz findet jedoch in %(conf_timezone)s statt - zeige die Uhrzeiten in deiner Zeitzone" +msgid "Now: %(name)" +msgstr "Jetzt: %(name)s" + +#, python-format +msgid "Next (%(time)s): %(name)s" +msgstr "Nächster (%(time)s): %(name)s" + #, python-format msgid "%(conf)s - Login" msgstr "" diff --git a/src/plainui/locale/en/LC_MESSAGES/django.po b/src/plainui/locale/en/LC_MESSAGES/django.po index bc0842d8cc44bebd4d7cc0e46ba520903be26f7c..3ee541037543de0fb5dffa923d371b03369b6f73 100644 --- a/src/plainui/locale/en/LC_MESSAGES/django.po +++ b/src/plainui/locale/en/LC_MESSAGES/django.po @@ -1010,6 +1010,13 @@ msgstr "" msgid "Your timezone is configured to %(user_timezone)s, conference timezone is %(conf_timezone)s, showing times in your timezone" msgstr "" +msgid "Now: %(name)" +msgstr "" + +#, python-format +msgid "Next (%(time)s): %(name)s" +msgstr "" + #, python-format msgid "%(conf)s - Login" msgstr "" diff --git a/src/plainui/styles/_components.scss b/src/plainui/styles/_components.scss index 48b838305f909418ab2df5660256a25d589f4885..65795da5b2b795cdf23a1d592bbe3524e7739a6f 100644 --- a/src/plainui/styles/_components.scss +++ b/src/plainui/styles/_components.scss @@ -15,6 +15,7 @@ @import "./components/player"; @import "./components/slider"; @import "./components/static-pages"; +@import "./components/streams"; @import "./components/syntaxhilite"; @import "./components/tags"; @import "./components/tile-board"; diff --git a/src/plainui/styles/components/_streams.scss b/src/plainui/styles/components/_streams.scss new file mode 100644 index 0000000000000000000000000000000000000000..a369a578e09029493f2cdc8d01e67a055f53a4ff --- /dev/null +++ b/src/plainui/styles/components/_streams.scss @@ -0,0 +1,10 @@ +.hub-index-stream__name { + box-orient: vertical; + -webkit-box-orient: vertical; + display: -webkit-box; + height: 2lh; + line-clamp: 2; + -webkit-line-clamp: 2; + overflow: hidden; + text-overflow: ellipsis; +}