Add upcomingEvents script to format MembershipWorks events to WordPress post
This commit is contained in:
parent
3595a24d85
commit
97c4dbc1ee
72
memberPlumbing/upcomingEvents.py
Normal file
72
memberPlumbing/upcomingEvents.py
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
from .config import Config
|
||||||
|
from .MembershipWorks import MembershipWorks
|
||||||
|
|
||||||
|
|
||||||
|
def format_event(membershipworks: MembershipWorks, event):
|
||||||
|
event_details = membershipworks.get_event_by_eid(event["eid"])
|
||||||
|
url = (
|
||||||
|
"https://claremontmakerspace.org/events/#!event/register/"
|
||||||
|
+ event_details["url"]
|
||||||
|
)
|
||||||
|
if "lgo" in event_details:
|
||||||
|
img = f"""<img class="aligncenter" width="500" height="500" src="{event_details['lgo']['l']}">"""
|
||||||
|
else:
|
||||||
|
img = ""
|
||||||
|
# print(json.dumps(event_details))
|
||||||
|
return f"""<h2 style="text-align: center;">
|
||||||
|
<a href="{url}">
|
||||||
|
{img}
|
||||||
|
{event_details['ttl']}
|
||||||
|
</a>
|
||||||
|
</h2>
|
||||||
|
<div>{event_details['szp']} — {event_details['ezp']}</div>
|
||||||
|
<div>
|
||||||
|
{event_details['dtl']}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a href="{url}">Register for this class now!</a>"""
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
config = Config()
|
||||||
|
|
||||||
|
membershipworks = config.membershipworks
|
||||||
|
events = membershipworks.get_events_list(datetime.now())
|
||||||
|
events_list = "\n<hr />\n\n".join(
|
||||||
|
format_event(membershipworks, event)
|
||||||
|
for event in events["evt"]
|
||||||
|
if event["ttl"] != "[TEMPLATE FOR COPYING]"
|
||||||
|
)
|
||||||
|
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>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>Class policies</strong> (liability waiver, withdrawal, cancellation, etc.) can be found <a href="https://claremontmakerspace.org/class-policies/" data-wpel-link="internal">here</a>.
|
||||||
|
|
||||||
|
<strong>Please note: </strong>The Claremont MakerSpace currently requires masks for all visitors and members.
|
||||||
|
|
||||||
|
<strong>Instructors:</strong> Interested in teaching a class at CMS? Please fill out our <a href="https://docs.google.com/forms/d/e/1FAIpQLSdJyEVRJxzIczG784VkOm_DsNyv-VXRXYzlis8qlMdEOvHGpQ/viewform" target="_blank" rel="noreferrer noopener external" data-wpel-link="external">Class Proposal Form</a><a href="https://docs.google.com/forms/d/e/1FAIpQLSdJyEVRJxzIczG784VkOm_DsNyv-VXRXYzlis8qlMdEOvHGpQ/viewform" target="_blank" rel="noreferrer noopener external" data-wpel-link="external">.</a>
|
||||||
|
|
||||||
|
<strong>Tours:</strong> Want to see what the Claremont MakerSpace is all about? Tours are by appointment only due to COVID-19 restrictions. <a href="https://tickets.claremontmakerspace.org/open.php" target="_blank" rel="noreferrer noopener external" data-wpel-link="external">Contact Us</a> to schedule your tour where you can learn about all the awesome tools that the CMS offers access to, as well as how membership, classes, and studio spaces work.
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
"""
|
||||||
|
|
||||||
|
footer = """
|
||||||
|
<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>
|
||||||
|
"""
|
||||||
|
|
||||||
|
print(header, events_list, footer)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
@ -33,6 +33,7 @@ doorUpdater = 'memberPlumbing.doorUpdater:main'
|
|||||||
hidEvents = 'memberPlumbing.hidEvents:main'
|
hidEvents = 'memberPlumbing.hidEvents:main'
|
||||||
sqlExport = 'memberPlumbing.sqlExport:main'
|
sqlExport = 'memberPlumbing.sqlExport:main'
|
||||||
ucsAccounts = 'memberPlumbing.ucsAccounts:main'
|
ucsAccounts = 'memberPlumbing.ucsAccounts:main'
|
||||||
|
upcomingEvents = 'memberPlumbing.upcomingEvents:main'
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry>=0.12"]
|
requires = ["poetry>=0.12"]
|
||||||
|
Reference in New Issue
Block a user