Skip to content

Commit

Permalink
custom error message if not wharton student
Browse files Browse the repository at this point in the history
  • Loading branch information
ezwang committed Mar 31, 2019
1 parent 979c406 commit dd701ae
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions penn/wharton.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def book_reservation(self, sessionid, roomid, start, end):
format = "%Y-%m-%dT%H:%M:%S-{}".format(self.get_dst_gmt_timezone())
booking_url = "{}/reserve/{}/{}/?d={}".format(BASE_URL, roomid, start.strftime(format), duration)
resp = requests.get(booking_url, cookies={"sessionid": sessionid})

if resp.status_code == 403:
return {"success": False, "error": "Your account does not have permission to book Wharton GSRs!"}

resp.raise_for_status()

csrfheader = re.search(r"csrftoken=(.*?);", resp.headers["Set-Cookie"]).group(1)
Expand Down

0 comments on commit dd701ae

Please sign in to comment.