Skip to content

Commit

Permalink
Add configuration to suppress live media for specified events
Browse files Browse the repository at this point in the history
  • Loading branch information
hancush committed Jul 25, 2024
1 parent 866e6d9 commit 444f940
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
2 changes: 2 additions & 0 deletions councilmatic/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
DJANGO_SECRET_KEY=(str, "replacethiswithsomethingsecret"),
DJANGO_DEBUG=(bool, True),
DJANGO_ALLOWED_HOSTS=(list, ["localhost", "127.0.0.1", "0.0.0.0"]),
COUNCILMATIC_SUPPRESS_LIVE_MEDIA=(list, []),
DATABASE_URL=(str, "postgis://postgres:postgres@postgres:5432/lametro"),
SEARCH_URL=(str, "http://elasticsearch:9200"),
SHOW_TEST_EVENTS=(bool, False),
Expand Down Expand Up @@ -49,6 +50,7 @@
DEBUG = env.bool("DJANGO_DEBUG")
SHOW_TEST_EVENTS = env.bool("SHOW_TEST_EVENTS")
ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS")
COUNCILMATIC_SUPPRESS_LIVE_MEDIA = env.list("COUNCILMATIC_SUPPRESS_LIVE_MEDIA")

if env("LOCAL_DOCKER"):
import socket
Expand Down
7 changes: 6 additions & 1 deletion lametro/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,9 @@ def _valid(self, media_url):

@property
def english_live_media_url(self):
if self.slug in settings.COUNCILMATIC_SUPPRESS_LIVE_MEDIA:
return None

guid = self.extras["guid"]
english_url = self.BASE_MEDIA_URL + "event_id={guid}".format(guid=guid)

Expand All @@ -573,6 +576,9 @@ def english_live_media_url(self):

@property
def spanish_live_media_url(self):
if self.slug in settings.COUNCILMATIC_SUPPRESS_LIVE_MEDIA:
return None

"""
If there is not an associated Spanish event, there will not be
Spanish audio for the event, e.g., return None.
Expand Down Expand Up @@ -704,7 +710,6 @@ def _streaming_meeting(cls):
Hit the endpoint, and return the corresponding meeting, or an empty
queryset.
"""

running_events = cache.get("running_events")
if not running_events:
try:
Expand Down
2 changes: 1 addition & 1 deletion lametro/templates/event/event.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h1>
{{event.name}}
{% endif %}

{% if event.is_ongoing %}
{% if event.is_ongoing and event.english_live_media_url %}
<a class="btn btn-salmon" href="{{ event.english_live_media_url }}" target="_blank">
<i class="fa fa-headphones" aria-hidden="true"></i>
Watch in English
Expand Down
25 changes: 13 additions & 12 deletions lametro/templates/index/_meeting_details_current.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,19 @@ <h4>
<!-- Buttons -->
<div class="text-center">
<div style="display:inline-block;">
<a class="btn btn-sm btn-salmon current-meeting-info" href="{{ current_meeting.first.english_live_media_url }}" target="_blank" >
<i class="fa fa-headphones" aria-hidden="true"></i>
Watch in English
</a>

{% if bilingual %}
<a class="btn btn-sm btn-salmon current-meeting-info" href="{{ current_meeting.first.spanish_live_media_url }}" target="_blank">
<i class="fa fa-headphones" aria-hidden="true"></i>
Ver en Español
</a>
{% endif %}
{% if current_meeting.first.english_live_media_url %}
<a class="btn btn-sm btn-salmon current-meeting-info" href="{{ current_meeting.first.english_live_media_url }}" target="_blank" >
<i class="fa fa-headphones" aria-hidden="true"></i>
Watch in English
</a>

{% if bilingual %}
<a class="btn btn-sm btn-salmon current-meeting-info" href="{{ current_meeting.first.spanish_live_media_url }}" target="_blank">
<i class="fa fa-headphones" aria-hidden="true"></i>
Ver en Español
</a>
{% endif %}
{% endif %}

{% if USING_ECOMMENT %}
<a class="btn btn-sm btn-salmon current-meeting-info" href="{{ current_meeting.first.ecomment_url }}" target="_blank">
Expand All @@ -119,4 +121,3 @@ <h4>
{% endif %}
</div>
</div>

0 comments on commit 444f940

Please sign in to comment.