Skip to content

Commit

Permalink
Merge pull request #6 from neuromatch/fix-overall
Browse files Browse the repository at this point in the history
Fix API
  • Loading branch information
titipata authored Oct 4, 2021
2 parents 11d6596 + e1539e0 commit 382e43d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
36 changes: 26 additions & 10 deletions backend/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ class Submission(BaseModel):
# fields provided by users
title: str = ""
abstract: str = ""
fullname: str = ""
firstname: str = ""
lastname: str = ""
email: str = ""
coauthors: Optional[str] = None
institution: Optional[str] = None
Expand Down Expand Up @@ -641,10 +642,12 @@ async def create_abstract(
Submit an abstract to Airtable
"""
user_info = get_user_info(authorization)
user_id = get_user_info(authorization).get("user_id")
if user_id is not None:
user = get_data(user_id, user_collection)
submission["firstname"] = submission.get("firstname", "")
submission["lastname"] = submission.get("lastname", "")
submission = submission.dict()
submission["fullname"] = (
submission.get("firstname", "") + " " + submission.get("lastname", "")
).strip()

# look for base_id for a given "edition"
base_id = es_config["editions"][edition].get("airtable_id")
Expand All @@ -669,23 +672,36 @@ async def create_abstract(


@app.put("/api/abstract/{edition}/{submission_id}")
async def update_abstract(submission_id: str, submission: Submission, edition: str):
async def update_abstract(
submission_id: str,
submission: Submission,
edition: str,
authorization: Optional[str] = Header(None),
):
"""
Update an abstract on Airtable with a given submission ID
"""
# only allow some keys to be updated by the presenter
submission = submission.dict()
submission["fullname"] = (
submission.get("firstname", "") + " " + submission.get("lastname", "")
).strip()
user_info = get_user_info(authorization)
user_id = user_info.get("user_id")
print("Usedr Info: ", user_info)
print("User ID: ", user_id)
if user_id is not None:
user = get_data(user_id, user_collection)
print(user)
submission["firstname"] = user.get("firstname", "")
submission["lastname"] = user.get("lastname", "")
print(submission)
submission = {
k: v
for k, v in submission.items()
if k
in [
"title",
"abstract",
"fullname",
"firstname",
"lastname",
"email",
"coauthors",
"institution",
Expand All @@ -705,7 +721,7 @@ async def update_abstract(submission_id: str, submission: Submission, edition: s
table = Table(api_key=airtable_key, base_id=base_id, table_name=table_name)
r = table.update(submission_id, submission) # update submission
print(f"Set the record {r['id']} on Airtable")
return JSONResponse(status=status.HTTP_200_OK)
return JSONResponse(status_code=status.HTTP_200_OK)


@app.post("/api/payment/{option}")
Expand Down
2 changes: 1 addition & 1 deletion sitedata/email-content.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"content": [
{
"type": "text/html",
"value": "<p>Dear participant,</p><p>Thank you for submitting your abstract to Neuromatch Conference 4 (NMC4). We look forward to have you in the conference. We will send you a confirmation email after we review after abstracts after the deadline.</p><p>Best,<br>NMC Organizers</p>"
"value": "<p>Dear participant,</p><p>Thank you for submitting your abstract to Neuromatch Conference 4 (NMC4). We look forward to have you in the conference. We will send you a confirmation email, time, and your talk format after we review abstracts after the deadline.</p><p>Best,<br>NMC Organizers</p>"
}
]
},
Expand Down

0 comments on commit 382e43d

Please sign in to comment.