Skip to content

Commit

Permalink
Changed app.py to match main
Browse files Browse the repository at this point in the history
  • Loading branch information
MinhPhan8803 committed Nov 28, 2022
1 parent 022db54 commit d07ddca
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,29 @@ def userpage():
"""Handles userpage requests"""
if session.get("username", None) is None:
return "user does not exist", 404
username = session.get("username")
page = UserPage(username)
name = session.get("username") or ""
page = UserPage(name)
if request.method == "POST":
json_form = request.get_json(force=True) # deserialize data
json_form = request.get_json(force=True) or {} # deserialize data
# see which field was True and therefore should be changed
is_password = json_form.get("is_password", False)
is_email = json_form.get("is_email", False)
is_phone = json_form.get("is_phone", False)
is_get_liked = json_form.get("is_get_liked", False)
result = False
if is_password:
result = page.update_password(json_form.get("password"))
result = page.update_password(json_form.get("password") or "")
elif is_email:
result = page.update_email(json_form.get("email"))
result = page.update_email(json_form.get("email") or "")
elif is_phone:
result = page.update_phone(json_form.get("phone"))
result = page.update_phone(json_form.get("phone") or "")
elif is_get_liked:
liked_apts = page.get_liked(json_form.get("user_id"))
liked_apts = page.get_liked(json_form.get("user_id") or 0)
return dataclasses_into_json(liked_apts), 201
if not result:
return result, 400
return result, 201
user = page.get_user(username) # request.method == "GET"
return "invalid request", 400
return "success", 201
user = page.get_user(name) # request.method == "GET"
data_dict = dataclasses.asdict(user)
return json.dumps(data_dict), 201

Expand Down

3 comments on commit d07ddca

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCover
app.py1320100%
config.py10100%
decorators.py270100%
dataholders
   apt.py90100%
   mainpage_get.py150100%
   review.py70100%
   user.py80100%
pages
   login.py290100%
   mainpage.py1000100%
   userpage.py540100%
TOTAL3820100%

Tests Skipped Failures Errors Time
48 0 💤 1 ❌ 0 🔥 0.817s ⏱️

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCover
app.py1320100%
config.py10100%
decorators.py270100%
dataholders
   apt.py90100%
   mainpage_get.py150100%
   review.py70100%
   user.py80100%
pages
   login.py290100%
   mainpage.py1000100%
   userpage.py540100%
TOTAL3820100%

Tests Skipped Failures Errors Time
48 0 💤 1 ❌ 0 🔥 0.902s ⏱️

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCover
app.py1320100%
config.py10100%
decorators.py270100%
dataholders
   apt.py90100%
   mainpage_get.py150100%
   review.py70100%
   user.py80100%
pages
   login.py290100%
   mainpage.py1000100%
   userpage.py540100%
TOTAL3820100%

Tests Skipped Failures Errors Time
48 0 💤 1 ❌ 0 🔥 1.162s ⏱️

Please sign in to comment.