Skip to content

Commit

Permalink
Merge pull request #359 from datamade/better-events
Browse files Browse the repository at this point in the history
better event page: vimeo embed, event agenda
  • Loading branch information
derekeder authored Sep 11, 2023
2 parents 247458d + 7fff722 commit 23ff676
Show file tree
Hide file tree
Showing 5 changed files with 220 additions and 125 deletions.
23 changes: 16 additions & 7 deletions chicago/models.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import re
from datetime import datetime
from operator import attrgetter

import pytz
from councilmatic_core.models import Bill, Event, Organization, Person
from dateutil.relativedelta import relativedelta
from django.conf import settings
from django.db import models
from django.utils import timezone
from django.utils.functional import cached_property
from datetime import datetime
from dateutil.relativedelta import relativedelta

from councilmatic_core.models import Bill, Event, Organization, Person
from opencivicdata.legislative.models import LegislativeSession

from django.conf import settings
from django.db import models
from .helpers import topic_classifier

app_timezone = pytz.timezone(settings.TIME_ZONE)
Expand Down Expand Up @@ -123,7 +123,7 @@ def addresses(self):

return []

@property
@cached_property
def full_text_doc_url(self):
"""
override this if instead of having full text as string stored in
Expand Down Expand Up @@ -172,6 +172,15 @@ def most_recent_past_city_council_meeting(cls):
else:
return None

@cached_property
def video_vimeo_id(self):
try:
link = self.media.first().links.first().url
vimeo_id = re.match(".*?([0-9]+)$", link).group(1)
return vimeo_id
except AttributeError:
return None


class ChicagoPerson(Person):
class Meta:
Expand Down
91 changes: 56 additions & 35 deletions chicago/templates/event.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,56 @@ <h1>{%if event.status == 'cancelled'%}CANCELLED: {% endif %}{{event.name}}</h1>
<i class="fa fa-fw fa-map-marker"></i> {{event.location}}
</p>

{% if event.video_vimeo_id %}
<iframe src="https://player.vimeo.com/video/{{event.video_vimeo_id}}?h=b9331c0f77&title=0" width="640" height="360" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>
<p><a href="https://vimeo.com/{{event.video_vimeo_id}}">View on Vimeo</a></p>
{% endif %}
<hr />
<div class="row-fluid">
<div class="col-sm-6">
{% if event.clean_agenda_items %}
<h4>Agenda</h4>
<p>
<ol>
{% for agenda_item in event.clean_agenda_items %}
{% if agenda_item.description|lower != 'page break' %}
<li>
{% if agenda_item.related_bills.all %}
<a href="/legislation/{{agenda_item.related_bills.first.bill.slug}}/">
{{agenda_item.related_bills.first.bill.friendly_name}}
</a>
<br/>
<div class="row">
<div class="col-sm-10">
{% if event.agenda.all %}
<h4>Agenda: {{event.agenda.all|length}} items</h4>
<table class="table table table-responsive">
<thead>
<tr>
<th>Order</th>
<th>Description</th>
<th>ID</th>
<th>Sponsor(s)</th>
</tr>
</thead>
<tbody>
{% for agenda_item in event.agenda.all %}
<tr>
{% if agenda_item.description|lower != 'page break' %}
<td>{{ forloop.counter }}</td>
<td>{{agenda_item.description}}</td>
{% if agenda_item.bills %}
<td>
<a href="/legislation/{{agenda_item.bills.0.bill.councilmatic_bill.slug}}/">
{{ agenda_item.bills.0.bill.councilmatic_bill.friendly_name }}
</a>
</td>
<td>
{% for s in agenda_item.bills.0.bill.sponsors %}
<span class="nowrap">{{ s.person.councilmatic_person.link_html | safe }}</span>{% if not forloop.last %},{% endif %}
{% endfor %}
</td>
{% else %}
<td></td>
<td></td>
{% endif %}
{{agenda_item.description}}
</li>
{% endif %}
{% endif %}
</tr>
{% endfor %}
</ol>
</p>
</tbody>
</table>
{% endif %}

{% if event.documents.all %}
<h4>Attachments</h4>
<p>
{% for document in event.documents.all %}
<i class='fa fa-fw fa-file-text-o'></i> <a href="{{document.links.first.url}}">{{document.note}}</a><br />
{% endfor %}
</p>
{% endif %}
<div class="modal-links">
<!-- View on legistar -->
{{ event|get_legistar_link|safe }}
</div>
</div>
<div class="col-sm-6">
<!-- only show attendance for past events that weren't cancelled -->
{% if event.status == 'passed' %}
{% if attendance_taken %}
<h4>Attendance: {{attendance_present}} Present, {{attendance_absent}} Absent</h4>
<h4>Alder Attendance: {{attendance_present}} Present, {{attendance_absent}} Absent</h4>
<table class="table">
<tr>
<th></th>
Expand All @@ -88,10 +96,23 @@ <h4>Attendance: {{attendance_present}} Present, {{attendance_absent}} Absent</h4
{% endfor %}
</table>
{% else %}
<h4>Attendance</h4>
<h4>Alder Attendance</h4>
<p>Attendance was not taken for this meeting or has not been posted by the Clerk's office</p>
{% endif %}
{% endif %}

{% if event.documents.all %}
<h4>Attachments</h4>
<p>
{% for document in event.documents.all %}
<i class='fa fa-fw fa-file-text-o'></i> <a href="{{document.links.first.url}}">{{document.note}}</a><br />
{% endfor %}
</p>
{% endif %}
<div class="modal-links">
<!-- View on legistar -->
{{ event|get_legistar_link|safe }}
</div>
</div>
</div>

Expand Down
42 changes: 23 additions & 19 deletions chicago/templates/legislation.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,22 @@ <h1 class="bill-page-title">
<br/>
<p>{{ legislation.title }}</p>

{% if legislation.other_identifiers %}
{% with other_identifiers=legislation.other_identifiers.all %}
{% if other_identifiers %}
<p>
Alternate identifiers:
{% for identifier in legislation.other_identifiers.all %}
{% for identifier in other_identifiers %}
{{ identifier.identifier }}
{% if not forloop.last %} , {% endif %}
{% endfor %}
</p>
{% endif %}
{% endwith %}

<div class="divider"></div>

{% if legislation.sponsorships.all %}
{% with sponsors=sponsors_qs.all %}
{% if sponsors %}
<h3 class="no-pad-bottom"><i class='fa fa-fw fa-users'></i> Sponsors</h3>

<div class="table-responsive">
Expand All @@ -51,8 +54,8 @@ <h3 class="no-pad-bottom"><i class='fa fa-fw fa-users'></i> Sponsors</h3>
<tr>
<th></th>
<th>
{% if legislation.sponsorships.all|length > 1 %}
Sponsors ({{legislation.sponsorships.all|length}})
{% if sponsors|length > 1 %}
Sponsors ({{sponsors|length}})
{% else %}
Sponsor
{% endif %}
Expand All @@ -63,36 +66,36 @@ <h3 class="no-pad-bottom"><i class='fa fa-fw fa-users'></i> Sponsors</h3>
</tr>
</thead>
<tbody>
{% for s in legislation.sponsorships.all %}
{% if s.is_primary %}
{% for s in sponsors %}
{% if s.primary %}
<tr>
<td>
<div class="thumbnail-square">
<img src='{{s.person|get_person_headshot}}' alt='{{s.person.name}}' title='{{s.person.name}}' class='img-responsive' />
<img src='{{s.person.councilmatic_person|get_person_headshot}}' alt='{{s.person.name}}' title='{{s.person.name}}' class='img-responsive' />
</div>
</td>
<td>
{{ s.person.link_html | safe }} <span class="badge badge-default">Primary Sponsor</span>
<a href="{% url 'person' s.person.councilmatic_person.slug %}">{{ s.person.name }}</a><span class="badge badge-default">Primary Sponsor</span>
</td>
<td>
{{s.person.latest_council_membership.post.label}}
{{s.person.council_posts.0.post.label}}
</td>
</tr>
{% endif %}
{% endfor %}
{% for s in legislation.sponsorships.all %}
{% if not s.is_primary %}
{% for s in sponsors %}
{% if not s.primary %}
<tr>
<td>
<div class="thumbnail-square">
<img src='{{s.person|get_person_headshot}}' alt='{{s.person.name}}' title='{{s.person.name}}' class='img-responsive' />
<img src='{{s.person.councilmatic_person|get_person_headshot}}' alt='{{s.person.name}}' title='{{s.person.name}}' class='img-responsive' />
</div>
</td>
<td>
{{ s.person.link_html | safe }}
<a href="{% url 'person' s.person.councilmatic_person.slug %}">{{ s.person.name }}</a>
</td>
<td>
{{s.person.latest_council_membership.post.label}}
{{s.person.council_posts.0.post.label}}
</td>
</tr>
{% endif %}
Expand All @@ -102,8 +105,9 @@ <h3 class="no-pad-bottom"><i class='fa fa-fw fa-users'></i> Sponsors</h3>
</div>
<div class="divider"></div>
{% endif %}
{% endwith %}

{% if actions %}
{% if legislation.actions %}
<h3 class="no-pad-bottom"><i class='fa fa-fw fa-list-ul'></i> History</h3>
<div class="table-responsive">
<table class='table table-responsive' id='committee-actions'>
Expand All @@ -115,7 +119,7 @@ <h3 class="no-pad-bottom"><i class='fa fa-fw fa-list-ul'></i> History</h3>
</tr>
</thead>
<tbody>
{% for action in actions %}
{% for action in legislation.actions.all %}
<tr>
<td class='nowrap text-muted'>
<span datetime='{{action.date }}'>{{action.date}}</span>
Expand Down Expand Up @@ -215,7 +219,7 @@ <h3><i class='fa fa-fw fa-calendar-o'></i> Upcoming {{ CITY_VOCAB.EVENTS }}</h3>

{% for event in legislation.unique_related_upcoming_events %}
<p>
{{event.start_time | date:'M d, Y' }} - {{event.link_html | safe}}
{{event.start_time | date:'M d, Y' }} - <a href="{% url event_detail event.slug %}" title="View Event Details">{{ event.name }}</a>
</p>
{% endfor %}

Expand Down Expand Up @@ -278,7 +282,7 @@ <h3>Legislation not found</h3>
"sourceOrganization": "{{ CITY_COUNCIL_NAME }}",
"name": "{{ legislation.friendly_name }}",
"alternateName": ["{{ legislation.identifier }}", "{{ legislation.identifier.split|join:'' }}"],
{% if actions %}"datePublished": "{{actions.0.date|date:'Y-m-d'}}", {% endif %}
{% if legislation.actions %}"datePublished": "{{legislation.actions.0.date|date:'Y-m-d'}}", {% endif %}
"description": "{{ legislation.description }}",
"text": "{% firstof legislation.full_text legislation.ocr_full_text %}"
}
Expand Down
2 changes: 1 addition & 1 deletion chicago/templates/partials/seo.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta name="description" content="{{seo.site_desc}}">
<meta name="author" content="{{seo.site_author}}">

{% if seo.nofollow %}
{% if seo.noindex %}
<meta name="robots" content="noindex">
{% endif %}

Expand Down
Loading

0 comments on commit 23ff676

Please sign in to comment.