Skip to content

Commit

Permalink
availabile field was inversed, fixed endtime bug
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdoman committed Feb 14, 2019
1 parent d2cf008 commit 80f3fd4
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions penn/wharton.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import requests
import datetime

from bs4 import BeautifulSoup
from .base import APIError
Expand Down Expand Up @@ -81,14 +82,13 @@ def delete_booking(self, sessionid, booking_id):
return "success"


def get_wharton_gsrs(self, sessionid, request):
time = request.args.get('date')
if time:
time += " 05:00"
def get_wharton_gsrs(self, sessionid, date):
if date:
date += " 05:00"
else:
time = datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%S")
date = datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%S")
resp = requests.get('https://apps.wharton.upenn.edu/gsr/api/app/grid_view/', params={
'search_time': time
'search_time': date
}, cookies={
'sessionid': sessionid
})
Expand All @@ -111,10 +111,13 @@ def switch_format(self, gsr):
for entry in time:
entry["name"] = "GSR " + entry["room_number"]
del entry["room_number"]
start_time_str = entry["start_time"]
end_time = datetime.datetime.strptime(start_time_str[:-6], '%Y-%m-%dT%H:%M:%S') + datetime.timedelta(minutes=30)
end_time_str = end_time.strftime("%Y-%m-%dT%H:%M:%S") + "-05:00"
time = {
"available": entry["reserved"],
"end": entry["end_time"],
"start": entry["start_time"]
"available": not entry["reserved"],
"start": entry["start_time"],
"end": end_time_str,
}
exists = False
for room in rooms["rooms"]:
Expand Down Expand Up @@ -142,5 +145,5 @@ def switch_format(self, gsr):


def get_wharton_gsrs_formatted(self, sessionid):
gsrs = self.get_wharton_gsrs(sessionid)
gsrs = self.get_wharton_gsrs(sessionid, None)
return self.switch_format(gsrs)

0 comments on commit 80f3fd4

Please sign in to comment.