Compare commits
No commits in common. "e71fd48975e785316899bbeae130d257267843f5" and "5478518d5189b1a0c82078bcc87cdd2e754649d9" have entirely different histories.
e71fd48975
...
5478518d51
@ -9,34 +9,30 @@ from .config import Config
|
|||||||
|
|
||||||
|
|
||||||
def format_event(event_details, truncate: bool):
|
def format_event(event_details, truncate: bool):
|
||||||
try:
|
url = (
|
||||||
url = (
|
"https://claremontmakerspace.org/events/#!event/register/"
|
||||||
"https://claremontmakerspace.org/events/#!event/register/"
|
+ event_details["url"]
|
||||||
+ event_details["url"]
|
)
|
||||||
|
if "lgo" in event_details:
|
||||||
|
img = (
|
||||||
|
f"""<img class="alignleft" width="400" src="{event_details['lgo']['l']}">"""
|
||||||
)
|
)
|
||||||
if "lgo" in event_details:
|
else:
|
||||||
img = f"""<img class="alignleft" width="400" src="{event_details['lgo']['l']}">"""
|
img = ""
|
||||||
else:
|
# print(json.dumps(event_details))
|
||||||
img = ""
|
out = f"""<h2 style="text-align: center;">
|
||||||
# print(json.dumps(event_details))
|
|
||||||
out = f"""<h2 style="text-align: center;">
|
|
||||||
<a href="{url}">{img}{event_details['ttl']}</a>
|
<a href="{url}">{img}{event_details['ttl']}</a>
|
||||||
</h2>
|
</h2>
|
||||||
<div><i>{event_details['szp']} — {event_details['ezp']}</i></div>
|
<div><i>{event_details['szp']} — {event_details['ezp']}</i></div>
|
||||||
"""
|
"""
|
||||||
if not truncate:
|
if not truncate:
|
||||||
out += f"""
|
out += f"""
|
||||||
<div>
|
<div>
|
||||||
{event_details['dtl']}
|
{event_details['dtl']}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a href="{url}">Register for this class now!</a>"""
|
<a href="{url}">Register for this class now!</a>"""
|
||||||
return out
|
return out
|
||||||
except KeyError as e:
|
|
||||||
print(
|
|
||||||
f"Event '{event_details.get('ttl')}' missing required property: '{e.args[0]}'"
|
|
||||||
)
|
|
||||||
raise
|
|
||||||
|
|
||||||
|
|
||||||
def format_section(title: str, blurb: str, events, truncate: bool):
|
def format_section(title: str, blurb: str, events, truncate: bool):
|
||||||
@ -66,31 +62,24 @@ def generate_post():
|
|||||||
full_events = []
|
full_events = []
|
||||||
upcoming_events = []
|
upcoming_events = []
|
||||||
for event in events["evt"]:
|
for event in events["evt"]:
|
||||||
try:
|
# ignore hidden events
|
||||||
# ignore hidden events
|
if event["cal"] == 0:
|
||||||
if event["cal"] == 0:
|
continue
|
||||||
continue
|
event_details = membershipworks.get_event_by_eid(event["eid"])
|
||||||
event_details = membershipworks.get_event_by_eid(event["eid"])
|
|
||||||
|
|
||||||
# registration has already ended
|
# registration has already ended
|
||||||
if (
|
if (
|
||||||
"erd" in event_details
|
"erd" in event_details
|
||||||
and datetime.fromtimestamp(event_details["erd"]) < now
|
and datetime.fromtimestamp(event_details["erd"]) < now
|
||||||
):
|
):
|
||||||
ongoing_events.append(event_details)
|
ongoing_events.append(event_details)
|
||||||
# class is full
|
# class is full
|
||||||
elif event_details["cnt"] >= event_details["cap"]:
|
elif event_details["cnt"] >= event_details["cap"]:
|
||||||
full_events.append(event_details)
|
full_events.append(event_details)
|
||||||
else:
|
else:
|
||||||
upcoming_events.append(event_details)
|
upcoming_events.append(event_details)
|
||||||
except KeyError as e:
|
|
||||||
print(
|
|
||||||
f"Event '{event.get('ttl')}' missing required property: '{e.args[0]}'"
|
|
||||||
)
|
|
||||||
raise
|
|
||||||
|
|
||||||
# header
|
header = """<p><img class="aligncenter size-medium wp-image-2319" src="https://claremontmakerspace.org/wp-content/uploads/2019/03/CMS-Logo-b-y-g-300x168.png" alt="" width="300" height="168" /></a></p>
|
||||||
yield """<p><img class="aligncenter size-medium wp-image-2319" src="https://claremontmakerspace.org/wp-content/uploads/2019/03/CMS-Logo-b-y-g-300x168.png" alt="" width="300" height="168" /></a></p>
|
|
||||||
<p>Greetings Upper Valley Makers:</p>
|
<p>Greetings Upper Valley Makers:</p>
|
||||||
<p>We have an exciting list of upcoming classes at the Claremont MakerSpace that we think might interest you.</p>
|
<p>We have an exciting list of upcoming classes at the Claremont MakerSpace that we think might interest you.</p>
|
||||||
<strong>For most classes and events, CMS MEMBERSHIP IS NOT REQUIRED.</strong> That said, members receive a discount on registration and there are some classes/events that are for members only (this will be clearly noted in the event description).
|
<strong>For most classes and events, CMS MEMBERSHIP IS NOT REQUIRED.</strong> That said, members receive a discount on registration and there are some classes/events that are for members only (this will be clearly noted in the event description).
|
||||||
@ -104,6 +93,15 @@ def generate_post():
|
|||||||
<hr />
|
<hr />
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
footer = """<div style="clear: both;">
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<div>Happy Makin’!</div>
|
||||||
|
<div>We are grateful for all of the public support that our 501(c)(3), non-profit organization receives. If you’d like to make a donation,please visit the <a href="https://claremontmakerspace.org/support/"><strong>Support Us page</strong></a> of our website.</div>
|
||||||
|
</div>
|
||||||
|
"""
|
||||||
|
|
||||||
|
yield header
|
||||||
yield format_section(
|
yield format_section(
|
||||||
"Upcoming Events",
|
"Upcoming Events",
|
||||||
"Events that are currently open for registration.",
|
"Events that are currently open for registration.",
|
||||||
@ -125,14 +123,7 @@ def generate_post():
|
|||||||
truncate=True,
|
truncate=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
# footer
|
yield (footer)
|
||||||
yield """<div style="clear: both;">
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<div>Happy Makin’!</div>
|
|
||||||
<div>We are grateful for all of the public support that our 501(c)(3), non-profit organization receives. If you’d like to make a donation,please visit the <a href="https://claremontmakerspace.org/support/"><strong>Support Us page</strong></a> of our website.</div>
|
|
||||||
</div>
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
Reference in New Issue
Block a user