From 69024f4c48b894a9b2430acb59b7b857b2b7c2a1 Mon Sep 17 00:00:00 2001 From: Greg V Date: Wed, 16 Oct 2024 21:03:34 -0700 Subject: [PATCH] [Hackathon Request] Support requests for hackathons anywhere in the world! --- api/messages/messages_service.py | 24 +++++++++++++++++++++++- api/messages/messages_views.py | 6 ++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/api/messages/messages_service.py b/api/messages/messages_service.py index 13fba27..877f355 100644 --- a/api/messages/messages_service.py +++ b/api/messages/messages_service.py @@ -1173,7 +1173,28 @@ def update_hackathon_volunteers(event_id, volunteer_type, json, propel_id): return Message( "Updated Hackathon Volunteers" ) - + +def create_hackathon(json): + db = get_db() # this connects to our Firestore database + logger.debug("Hackathon Create") + send_slack_audit(action="create_hackathon", message="Creating", payload=json) + + # Save payload for potential hackathon in the database under the hackathon_requests collection + doc_id = uuid.uuid1().hex + collection = db.collection('hackathon_requests') + insert_res = collection.document(doc_id).set(json) + + if "contactEmail" in json and "contactName" in json: + send_welcome_email(json["contactName"], json["contactEmail"]) + + send_slack( + message=":rocket: New Hackathon Request :rocket: with json: " + str(json), channel="log-hackathon-requests", icon_emoji=":rocket:") + logger.debug(f"Insert Result: {insert_res}") + + return Message( + "Created Hackathon" + ) + @limits(calls=50, period=ONE_MINUTE) def save_hackathon(json): @@ -1583,6 +1604,7 @@ def send_welcome_email(name, email): params = { "from": "Opportunity Hack ", "to": f"{name} <{email}>", + "bcc": "greg@ohack.org", "subject": subject, "html": html_content, } diff --git a/api/messages/messages_views.py b/api/messages/messages_views.py index 26403df..622a8e5 100644 --- a/api/messages/messages_views.py +++ b/api/messages/messages_views.py @@ -29,6 +29,7 @@ single_add_volunteer, get_single_hackathon_id, save_hackathon, + create_hackathon, update_hackathon_volunteers, get_teams_list, get_team, @@ -467,4 +468,9 @@ def get_giveaway(): @auth.require_org_member_with_permission("volunteer.admin", req_to_org_id=getOrgId) def admin_get_all_giveaways(): return get_all_giveaways() + + +@bp.route("/create-hackathon", methods=["POST"]) +def submit_create_hackathon(): + return vars(create_hackathon(request.get_json())) \ No newline at end of file