Skip to content

Commit

Permalink
Merge pull request #76 from Hacksburg/use-zeffy-for-RSVPs
Browse files Browse the repository at this point in the history
add support for zeffy RSVP links
  • Loading branch information
hunterirving authored Jan 1, 2025
2 parents fc7cd0d + bea0217 commit 433cc6b
Show file tree
Hide file tree
Showing 3 changed files with 220 additions and 1 deletion.
126 changes: 126 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,132 @@ def json_to_html():
data = json.load(json_file)
posts = data['posts']

html = ""
for post in posts:
date = datetime.strptime(f"{post['date']} {datetime.strptime(post['end_time'], '%I:%M%p').strftime('%H:%M')}", '%Y-%m-%d %H:%M')
start_time = post["start_time"]
end_time = post["end_time"]
cancelled = post["cancelled"]

# Header
html += f'\n\t\t\t\t\t<div class="post" data-isodate="{date}">\n'
html += '\t\t\t\t\t\t<div class="post-header">\n'

if date and start_time and end_time:
html += f'\t\t\t\t\t\t\t<div class="calendar-link noselect">\n'
html += f'\t\t\t\t\t\t\t\t<div class="circled-date">{date.day}</div>\n'

month = date.strftime('%B')
html += f'\t\t\t\t\t\t\t\t<div class="month-and-time">{month}<br>\n'

start_time = datetime.strptime(start_time, "%I:%M%p").strftime("%-I:%M%p").lower()
end_time = datetime.strptime(end_time, "%I:%M%p").strftime("%-I:%M%p").lower()
if start_time[-2:] != end_time[-2:]:
time_string = f"{start_time} - {end_time}"
else:
time_string = f"{start_time[:-2]} - {end_time}"
html += f'\t\t\t\t\t\t\t\t\t<div class="time">{time_string}</div>\n'
html += '\t\t\t\t\t\t\t\t</div>\n'
html += '\t\t\t\t\t\t\t</div>\n'

# Title
html += '\t\t\t\t\t\t\t<div class="title-and-subtitle-wrapper">\n'
html += '\t\t\t\t\t\t\t\t<div class="title-and-subtitle">\n'
html += f'\t\t\t\t\t\t\t\t\t<div class="title">'
if cancelled:
html += '(Cancelled) '
html += f'{post["title"]}</div>\n'
html += f'\t\t\t\t\t\t\t\t\t<div class="subtitle">{post["subtitle"]}</div>\n'
html += '\t\t\t\t\t\t\t\t</div>\n'
html += '\t\t\t\t\t\t\t</div>\n'
html += '\t\t\t\t\t\t\t<div class="x-box" onClick="togglePostOpened(this)">\n'
html += '\t\t\t\t\t\t\t\t<div class="x"></div>\n'
html += '\t\t\t\t\t\t\t</div>\n'
html += '\t\t\t\t\t\t</div>\n'

# Image
html += '\t\t\t\t\t\t<div class="closeable">\n'
html += '\t\t\t\t\t\t\t<div class="post-body">\n'
if post["image"]:
html += f'\t\t\t\t\t\t\t\t<img class="post-image" src="/resources/images/{post["image"]}" loading="lazy">\n'
html += f'\t\t\t\t\t\t\t\t<div class="post-text"'
if post["image"]:
html += '>'
else:
html += ' style="width: 100%">'

# Description
if cancelled:
html += f'<s>{post["description"]}</s>\n'
html += '\t\t\t\t\t\t\t\t\t<br><p><b>This event has been cancelled.</b></p>\n'
else:
html += f'{post["description"]}\n'

# Event details (time, location, cost)
if not cancelled:
html += '\t\t\t\t\t\t\t\t\t<p>\n'
if date and start_time and end_time:
formatted_date_str = f"{date.strftime('%A')}, {date.strftime('%B')} {date.day}{date_suffix(date.day)}"
html += f'\t\t\t\t\t\t\t\t\t<b>Time</b>: {formatted_date_str} from {time_string}<br>\n'

location_str = ""
if post["offsite_location"]:
location_str = post["offsite_location"]
elif post["offered_in_person"] and post["offered_online"]:
location_str = 'Online and in person at Hacksburg; <a href="https://www.google.com/maps/dir/?api=1&destination=Hacksburg+Blacksburg,+VA" target="_blank">1872 Pratt Drive Suite 1620</a>.<br>\n\t\t\t\t\t\t\t\t\tEnter through the covered double doors at the back of the building.'
elif post["offered_in_person"]:
location_str = 'In person at Hacksburg; <a href="https://www.google.com/maps/dir/?api=1&destination=Hacksburg+Blacksburg,+VA" target="_blank">1872 Pratt Drive Suite 1620</a>. Enter through the covered double doors at the back of the building.'
elif post["offered_online"]:
location_str = 'Online only.'

if location_str:
html += f'\t\t\t\t\t\t\t\t\t<b>Place</b>: {location_str}<br>\n'

if post["offered_online"]:
html += '\t\t\t\t\t\t\t\t\t<b>URL</b>: '
html += '<a href="https://meet.hacksburg.org/class" target="_blank">meet.hacksburg.org/class</a><br>\n'

if post["member_price"] == 0 and post["non_member_price"] == 0:
html += '\t\t\t\t\t\t\t\t\t<b>Cost</b>: Free!\n'
elif post["member_price"] == 0:
html += f'\t\t\t\t\t\t\t\t\t<b>Cost</b>: Free for Hacksburg members; ${post["non_member_price"]} for non-members. Pay in person or online at <a href="https://paypal.me/hacksburg" target="_blank">paypal.me/hacksburg</a>.\n'
elif post["member_price"] == post["non_member_price"]:
html += f'\t\t\t\t\t\t\t\t\t<b>Cost</b>: ${post["non_member_price"]}. Pay in person or online at <a href="https://paypal.me/hacksburg" target="_blank">paypal.me/hacksburg</a>.\n'
else:
html += f'\t\t\t\t\t\t\t\t\t<b>Cost</b>: ${post["member_price"]} for Hacksburg members; ${post["non_member_price"]} for non-members. Pay in person or online at <a href="https://paypal.me/hacksburg" target="_blank">paypal.me/hacksburg</a>.\n'
html += '\t\t\t\t\t\t\t\t\t</p>\n'

# Determine which platform to use for RSVP
platform_link = None
platform_name = None
if post["zeffy_link"]:
platform_link = post["zeffy_link"]
platform_name = "Zeffy"
elif post["meetup_link"]:
platform_link = post["meetup_link"]
platform_name = "Meetup"

if platform_link:
if not cancelled:
html += f'\t\t\t\t\t\t\t\t\t<a class="button rsvp-button" href="{platform_link}" target="_blank">RSVP on {platform_name}</a>\n'
html += '\t\t\t\t\t\t\t\t\t<div class="below-button-text">\n'
subject = f'RSVP for {post["title"]}'
body = f'I am confirming my RSVP for \"{post["title"]}\" on {formatted_date_str} from {time_string}.'
html += f'\t\t\t\t\t\t\t\t\t\tor <a href="{build_mailto(subject, body)}" target="_blank">RSVP by Email</a>\n'
html += '\t\t\t\t\t\t\t\t\t</div>\n'
else:
html += f'\t\t\t\t\t\t\t\t\t<a class="button rsvp-button" href="{platform_link}" target="_blank">View on {platform_name}</a>\n'

html += '\t\t\t\t\t\t\t\t</div>\n'
html += '\t\t\t\t\t\t\t</div>\n'
html += '\t\t\t\t\t\t</div>\n'
html += '\t\t\t\t\t</div>\n'

return html
with open('posts.json') as json_file:
data = json.load(json_file)
posts = data['posts']

html = ""
for post in posts:
date = datetime.strptime(f"{post['date']} {datetime.strptime(post['end_time'], '%I:%M%p').strftime('%H:%M')}", '%Y-%m-%d %H:%M')
Expand Down
Loading

0 comments on commit 433cc6b

Please sign in to comment.