Skip to content

Commit

Permalink
[Hackathon Request] Support requests for hackathons anywhere in the w…
Browse files Browse the repository at this point in the history
…orld!
  • Loading branch information
gregv committed Oct 17, 2024
1 parent 7633108 commit 69024f4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
24 changes: 23 additions & 1 deletion api/messages/messages_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -1583,6 +1604,7 @@ def send_welcome_email(name, email):
params = {
"from": "Opportunity Hack <[email protected]>",
"to": f"{name} <{email}>",
"bcc": "[email protected]",
"subject": subject,
"html": html_content,
}
Expand Down
6 changes: 6 additions & 0 deletions api/messages/messages_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
single_add_volunteer,
get_single_hackathon_id,
save_hackathon,
create_hackathon,
update_hackathon_volunteers,
get_teams_list,
get_team,
Expand Down Expand Up @@ -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()))

0 comments on commit 69024f4

Please sign in to comment.