Skip to content

Commit

Permalink
added route to get all friends
Browse files Browse the repository at this point in the history
  • Loading branch information
jermxt committed Oct 16, 2022
1 parent baa7040 commit 518e1bb
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions backend/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# username and password fields. If there is already
# a user with the same username it returns { "success" : False}
#
# post body: {"username" : USERNAME, "password", PASSWORD, "address" : ADDRESS, "phone" : PHONE}
# post body: {"name": NAME, "username" : USERNAME, "password", PASSWORD, "address" : ADDRESS, "phone" : PHONE}
# returns: {"success" : BOOLEAN}
@users_bp.route('/newUser/', methods=['POST'])
def addUser():
Expand All @@ -26,7 +26,7 @@ def addUser():
lat, long = geocode(data['address'])

session = Session()
newUser = User(username=data['username'], password=data['password'], \
newUser = User(name=data['name'], username=data['username'], password=data['password'], \
friends=[], oncall=[], lat=lat, long=long, phone=data["phone"])
session.add(newUser)
try:
Expand All @@ -39,6 +39,17 @@ def addUser():
session.close()
return jsonify(ret)

@users_bp.route('/allFriends/', methods=['GET'])
def getAllFriends():
session = Session()
users = session.query(User.name, User.username).all()
session.close()
ret = []
for a, b in users:
ret.append((a,b))
return jsonify(ret)


@users_bp.route('/login/', methods=['POST'])
def loginUser():
data = request.json
Expand Down

0 comments on commit 518e1bb

Please sign in to comment.