Skip to content

Commit eddd31f

Browse files
authored
Fix meeting end time logic and improve HTML layout
Updated the calendar generation logic to handle meeting end times correctly and adjusted the HTML rendering for better responsiveness.
1 parent 24c517f commit eddd31f

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

Calendar/Calendar.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def get_events(dt):
1414
FROM Meetings m
1515
LEFT JOIN Organizations o ON m.OrganizationId = o.OrganizationId
1616
17-
WHERE m.MeetingDate < DATEADD(day, 1, '{0}') AND m.MeetingEnd > '{0}'
17+
WHERE m.MeetingDate < DATEADD(day, 1, '{0}') AND COALESCE(m.MeetingEnd, m.MeetingDate) > '{0}'
1818
ORDER BY MeetingDate, o.DivisionId
1919
'''.format(dt))
2020

@@ -94,7 +94,7 @@ def generate_calendar_html(date):
9494
if ev.Featured:
9595
classes.append('feat')
9696

97-
html.append("<a href='/Meeting/%s'>" % ev.MeetingId)
97+
html.append("<a href='/Meeting/MeetingDetails/%s'>" % ev.MeetingId)
9898

9999
html.append("<div class='%s'>" % ' '.join(classes))
100100

@@ -120,7 +120,7 @@ def generate_calendar_week_html(start_date):
120120
start_of_week = start_date - datetime.timedelta(days=start_date.weekday() + 1 if start_date.weekday() != 6 else 0)
121121
days = [start_of_week + datetime.timedelta(days=i) for i in range(7)]
122122

123-
hour_height = 60 # pixels per hour (so 30 min = 30px)
123+
hour_height = 6 # vh per hour
124124
day_start = 0
125125
day_end = 24
126126

@@ -137,7 +137,7 @@ def generate_calendar_week_html(start_date):
137137
html.append("<style>")
138138
html.append("div#main { width: 100% !important;}")
139139
html.append(".week-container { height: calc(100vh - 10em); overflow-y: scroll; border: 1px solid #999; }")
140-
html.append(".week { display: flex; min-height: %dpx; position: relative; padding-left:3em; }" % ((day_end - day_start) * hour_height))
140+
html.append(".week { display: flex; min-height: %dvh; position: relative; padding-left:3em; }" % ((day_end - day_start) * hour_height))
141141
html.append(".daycol { flex: 3; border-left: 1px solid #999; position: relative; }")
142142
html.append(".daycol.sun { flex: 4; }")
143143
html.append(".dayheader { background: #eee; text-align: center; padding: 4px; font-weight: bold; position: sticky; top: 0; z-index: 2; }")
@@ -149,14 +149,6 @@ def generate_calendar_week_html(start_date):
149149
html.append(".nav-c { text-align:center; }")
150150
html.append(".nav-r { text-align:right; }")
151151
html.append("</style>")
152-
153-
# JavaScript to scroll to 8am
154-
html.append("<script>")
155-
html.append("window.addEventListener('load', function(){")
156-
html.append(" var container = document.querySelector('.week-container');")
157-
html.append(" if(container){ container.scrollTop = %d; }" % (8 * hour_height))
158-
html.append("});")
159-
html.append("</script>")
160152

161153
html.append("<div class='nav'>")
162154

@@ -182,10 +174,10 @@ def generate_calendar_week_html(start_date):
182174
# Time grid lines (shared across all days)
183175
for h in range(day_start, day_end + 1):
184176
top = (h - day_start) * hour_height
185-
html.append("<div class='timegrid' style='top:%dpx'>%02d:00</div>" % (top, h))
177+
html.append("<div class='timegrid' style='top:%dvh'>%02d:00</div>" % (top, h))
186178
# half-hour line
187179
if h < day_end:
188-
html.append("<div class='timegrid' style='top:%dpx'></div>" % (top + hour_height // 2))
180+
html.append("<div class='timegrid' style='top:%dvh'></div>" % (top + hour_height // 2))
189181

190182
for day in days:
191183
events = get_events(day)
@@ -232,8 +224,8 @@ def generate_calendar_week_html(start_date):
232224
if ev.Featured:
233225
classes.append('feat')
234226

235-
html.append("<a href='/Meeting/%s' title=\"%s\">" % (ev.MeetingId, ev.MeetingName))
236-
html.append("<div class='%s' style='top:%dpx; height:%dpx; left:%.2f%%; width:%.2f%%'>" % (
227+
html.append("<a href='/Meeting/MeetingDetails/%s' title=\"%s\">" % (ev.MeetingId, ev.MeetingName))
228+
html.append("<div class='%s' style='top:%dvh; height:%dvh; left:%.2f%%; width:%.2f%%'>" % (
237229
' '.join(classes), top, height, left, width))
238230
html.append("%s<br><small>%s - %s</small>" % (
239231
ev.MeetingName,
@@ -245,6 +237,15 @@ def generate_calendar_week_html(start_date):
245237
html.append("</div>") # end daycol
246238

247239
html.append("</div></div>") # end week and container
240+
241+
# JavaScript to scroll to 8am
242+
html.append("<script>")
243+
html.append("window.addEventListener('load', function(){")
244+
html.append(" var container = document.querySelector('.week-container');")
245+
html.append(" if(container){ container.scrollTop = container.clientHeight / 2; }")
246+
html.append("});")
247+
html.append("</script>")
248+
248249
return "\n".join(html)
249250

250251

0 commit comments

Comments
 (0)