forked from CMS/memberPlumbing
upcomingEvents: Improve error messages for events missing attributes
This commit is contained in:
parent
5478518d51
commit
c0e43dd48e
@ -9,14 +9,13 @@ 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:
|
if "lgo" in event_details:
|
||||||
img = (
|
img = f"""<img class="alignleft" width="400" src="{event_details['lgo']['l']}">"""
|
||||||
f"""<img class="alignleft" width="400" src="{event_details['lgo']['l']}">"""
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
img = ""
|
img = ""
|
||||||
# print(json.dumps(event_details))
|
# print(json.dumps(event_details))
|
||||||
@ -33,6 +32,11 @@ def format_event(event_details, truncate: bool):
|
|||||||
|
|
||||||
<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):
|
||||||
@ -62,6 +66,7 @@ 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
|
||||||
@ -78,6 +83,11 @@ def generate_post():
|
|||||||
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 = """<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>
|
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>
|
||||||
<p>Greetings Upper Valley Makers:</p>
|
<p>Greetings Upper Valley Makers:</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user