Skip to content

Commit 8be653d

Browse files
committed
Simplify events calendar code
1 parent ef9e3ba commit 8be653d

File tree

3 files changed

+67
-75
lines changed

3 files changed

+67
-75
lines changed

templates/calendar.html

+65-57
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,75 @@
11
{% load static %}
2-
<div class="container">
3-
{% load custom_filters %}
4-
{% if events %}
5-
<div class="columns is-multiline is-variable is-4">
6-
{% for event in events %}
7-
<div class="column is-12-mobile is-12-tablet is-6-desktop">
8-
<div class="box" style="padding: 1.5rem;">
9-
<div class="mb-4">
10-
<!-- Event Title -->
11-
<h2 class="title is-5 mb-2">{{ event.summary }}</h2>
12-
<!-- Date/Time Subtitle -->
13-
<div class="is-flex" style="align-items: center;">
14-
<span class="icon has-text-grey" style="flex: 0 0 auto;">
15-
<i class="fas fa-fw fa-clock"></i>
16-
</span>
17-
{% if event.start.dateTime %}
18-
{% with event.start.dateTime|parse_iso as start_dt %}
19-
{% if event.end.dateTime %}
20-
{% with event.end.dateTime|parse_iso as end_dt %}
2+
<section id="upcoming-events" class="section">
3+
<div class="container">
4+
<div class="content">
5+
<a href="{% url 'events' %}"><p class="title">Upcoming Events</p></a>
6+
<p class="subtitle is-6 mt-2">Use <a href="https://calendar.google.com/calendar/r?cid=berkeley.edu_rv641pmt9o13qnh1ss4uib78bs%40group.calendar.google.com" target="_blank">this link</a> to subscribe to the calendar.</p>
7+
<div class="container">
8+
{% load custom_filters %}
9+
{% if events %}
10+
<div class="columns is-multiline is-variable is-4">
11+
{% for event in events %}
12+
<div class="column is-12-mobile is-12-tablet is-6-desktop">
13+
<div class="box" style="padding: 1.5rem;">
14+
<div class="mb-4">
15+
<!-- Event Title -->
16+
<h2 class="title is-5 mb-2">{{ event.summary }}</h2>
17+
<!-- Date/Time Subtitle -->
18+
<div class="is-flex" style="align-items: center;">
19+
<span class="icon has-text-grey" style="flex: 0 0 auto;">
20+
<i class="fas fa-fw fa-clock"></i>
21+
</span>
22+
{% if event.start.dateTime %}
23+
{% with event.start.dateTime|parse_iso as start_dt %}
24+
{% if event.end.dateTime %}
25+
{% with event.end.dateTime|parse_iso as end_dt %}
26+
<span class="has-text-weight-semibold" style="flex: 1; margin-left: 0.5rem;">
27+
{{ start_dt|date:"l, F jS" }}, {{ start_dt|date:"g:i A" }} – {{ end_dt|date:"g:i A" }}
28+
</span>
29+
{% endwith %}
30+
{% else %}
31+
<span class="has-text-weight-semibold" style="flex: 1; margin-left: 0.5rem;">
32+
{{ start_dt|date:"l, F jS" }}, {{ start_dt|date:"g:i A" }}
33+
</span>
34+
{% endif %}
35+
{% endwith %}
36+
{% elif event.start.date %}
37+
{% with event.start.date|parse_iso as start_date %}
2138
<span class="has-text-weight-semibold" style="flex: 1; margin-left: 0.5rem;">
22-
{{ start_dt|date:"l, F jS" }}, {{ start_dt|date:"g:i A" }} – {{ end_dt|date:"g:i A" }}
39+
{{ start_date|date:"l, F jS" }}, All Day
2340
</span>
2441
{% endwith %}
25-
{% else %}
26-
<span class="has-text-weight-semibold" style="flex: 1; margin-left: 0.5rem;">
27-
{{ start_dt|date:"l, F jS" }}, {{ start_dt|date:"g:i A" }}
42+
{% endif %}
43+
</div>
44+
<!-- Event Location (if available) -->
45+
{% if event.location %}
46+
<div class="is-flex" style="align-items: center;">
47+
<span class="icon has-text-grey" style="flex: 0 0 auto;">
48+
<i class="fas fa-fw fa-map-marker-alt"></i>
49+
</span>
50+
<span class="has-text-weight-semibold"
51+
style="flex: 1; margin-left: 0.5rem;">
52+
{{ event.location }}
2853
</span>
54+
</div>
2955
{% endif %}
30-
{% endwith %}
31-
{% elif event.start.date %}
32-
{% with event.start.date|parse_iso as start_date %}
33-
<span class="has-text-weight-semibold" style="flex: 1; margin-left: 0.5rem;">
34-
{{ start_date|date:"l, F jS" }}, All Day
35-
</span>
36-
{% endwith %}
37-
{% endif %}
38-
</div>
39-
<!-- Event Location (if available) -->
40-
{% if event.location %}
41-
<div class="is-flex" style="align-items: center;">
42-
<span class="icon has-text-grey" style="flex: 0 0 auto;">
43-
<i class="fas fa-fw fa-map-marker-alt"></i>
44-
</span>
45-
<span class="has-text-weight-semibold"
46-
style="flex: 1; margin-left: 0.5rem;">
47-
{{ event.location }}
48-
</span>
49-
</div>
50-
{% endif %}
56+
</div>
57+
<!-- Event Description -->
58+
{% if event.description %}
59+
<div class="content">{{ event.description|safe|linebreaks }}</div>
60+
{% else %}
61+
<div class="content"><em>No description available.</em></div>
62+
{% endif %}
63+
</div>
5164
</div>
52-
<!-- Event Description -->
53-
{% if event.description %}
54-
<div class="content">{{ event.description|safe|linebreaks }}</div>
55-
{% else %}
56-
<div class="content"><em>No description available.</em></div>
57-
{% endif %}
58-
</div>
65+
{% endfor %}
66+
</div>
67+
{% else %}
68+
<div class="notification is-info is-light">
69+
No events currently scheduled.
5970
</div>
60-
{% endfor %}
71+
{% endif %}
6172
</div>
62-
{% else %}
63-
<div class="notification is-info is-light">
64-
No events currently scheduled.
6573
</div>
66-
{% endif %}
67-
</div>
74+
</div>
75+
</section>

templates/events.html

+1-9
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@
33
{% block content %}
44
{% include "hero_with_bg_img.html" with title="Events" subtitle="The CSUA hosts a large variety of social events, tech talks, networking events, workshops, and hackathons for the CS community." size="is-small" %}
55
{% load calendar_tags %}
6-
<section class="section">
7-
<div class="content">
8-
<div class="columns is-centered">
9-
<div class="column is-full">
10-
{% calendar %}
11-
</div>
12-
</div>
13-
</div>
14-
</section>
6+
{% calendar %}
157
{% endblock %}
168
{# vim:set et sw=4: #}

templates/index.html

+1-9
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,7 @@ <h2>
125125
</section>
126126

127127
{% load calendar_tags %}
128-
<section id="upcoming-events" class="section">
129-
<div class="container">
130-
<div class="content">
131-
<a href="{% url 'events' %}"><p class="title">Upcoming Events</p></a>
132-
<p class="subtitle is-6 mt-2">Use <a href="https://calendar.google.com/calendar/r?cid=berkeley.edu_rv641pmt9o13qnh1ss4uib78bs%40group.calendar.google.com" target="_blank">this link</a> to subscribe to the calendar.</p>
133-
{% calendar %}
134-
</div>
135-
</div>
136-
</section>
128+
{% calendar %}
137129

138130
<section id="people" class="section has-background-light">
139131
<div class="container">

0 commit comments

Comments
 (0)