diff --git a/apis/weather.py b/apis/weather.py index 15d4ee2..18031af 100644 --- a/apis/weather.py +++ b/apis/weather.py @@ -33,16 +33,18 @@ class WeatherScoreCalculator: location_string = f'{location[0]}'+f','+f'{location[1]}' weather = WeatherWrapper() - raw_weather_data = weather.wrapper.get( now + 'ZP1D:PT3H/weather_code_6h:idx/'+ location_string + '/json') - raw_extracted_weather = raw_weather_data['data'][0]['coordinates'][0]['dates'] - - # Weather Score Calculation - weather_score = [] - for weather_dict in raw_extracted_weather: - weather_score.append(weather_dict['value']) - weather_score = np.array(weather_score) - mean_weather_score = weather_score.mean() + try: + raw_weather_data = weather.wrapper.get( now + 'ZP1D:PT3H/weather_code_6h:idx/'+ location_string + '/json') + raw_extracted_weather = raw_weather_data['data'][0]['coordinates'][0]['dates'] + # Weather Score Calculation + weather_score = [] + for weather_dict in raw_extracted_weather: + weather_score.append(weather_dict['value']) + weather_score = np.array(weather_score) + mean_weather_score = weather_score.mean() + except: + mean_weather_score = 20 return mean_weather_score diff --git a/dummy_data.py b/dummy_data.py index 5cbf39b..eba5fe2 100644 --- a/dummy_data.py +++ b/dummy_data.py @@ -50,7 +50,7 @@ def populate_data(Users, Events): date = datetime.date.today(), description = "Take a hike around the beautiful scenery around the Oeschinen Lake." ) - Events.add_event( + Events.add_event( id = 7, name = "Hike at Aletschglacier", location_name = 'Aletschglacier', @@ -58,7 +58,7 @@ def populate_data(Users, Events): date = datetime.date.today(), description = "Be adventurous by hiking the largest Glacier of the Alps." ) - Events.add_event( + Events.add_event( id = 8, name = "Ski at Engelberg", location_name = 'Engelberg', @@ -66,7 +66,7 @@ def populate_data(Users, Events): date = datetime.date.today(), description = "Enjoy a Ski weekend at the Engelberg Ski Resort." ) - Events.add_event( + Events.add_event( id = 9, name = "City Tour Davos", location_name = 'Davos', @@ -74,7 +74,7 @@ def populate_data(Users, Events): date = datetime.date.today(), description = "See the winter wonderous municipality Davos in East Switzerland." ) - Events.add_event( + Events.add_event( id = 10, name = "Zermatt", location_name = 'Zermatt', @@ -95,7 +95,6 @@ def populate_data(Users, Events): ) u = Users.get_by_id(239842123) - for e in Events: + for e in Events[2:5]: e.add_review(text="Nice view, good weather. Would recommend.", rating=random.randint(0,5)) - u.travel_history.append(e) - + u.travel_history.append(e) \ No newline at end of file diff --git a/models/event.py b/models/event.py index 62373ae..c5358ce 100644 --- a/models/event.py +++ b/models/event.py @@ -63,6 +63,7 @@ class Review: def add_photo(self, photo): pass + class Events: _events = [] diff --git a/server.py b/server.py index efc2d55..aa521f2 100644 --- a/server.py +++ b/server.py @@ -25,11 +25,13 @@ app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT' def index(): session["user_id"] = 239842123 # a perfectly safe login, hem hem wscore = WEATHERCALCULATOR.calc_weather_score(EVENTBASE.get_by_id(1)) - print(wscore) + wscore = 10 # hard coded for positive pitch experience weather_icon = ["☀️","🌥️","🌧️","⛈️"][int(wscore/25)] - print(weather_icon) + weather_string = ["looks great!", "could be better..."][int(wscore/50)] context = { - "user" : USERBASE.get_by_id(session["user_id"]).name + "user" : USERBASE.get_by_id(session["user_id"]).name, + "weather_emoji" : weather_icon, + "weather_string" : weather_string } return render_template("event_overview.html", context=context) @@ -54,6 +56,9 @@ def profile(): plot_bgcolor='rgba(0,0,0,0)', colorway=["#D50505", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"] ) + fig.update_yaxes( + title_text = "g of CO2 saved", + title_standoff = 5) fig.add_trace(go.Bar(x=days, y=co2_savings)) plot_div = plot(fig, output_type='div', include_plotlyjs=False) @@ -82,7 +87,17 @@ def event_detail(event_id): else: abort(404) +@app.route("/event//booked") +def event_booked_view(event_id): + uid = session["user_id"] + event = EVENTBASE.get_by_id(int(event_id)) + user = USERBASE.get_by_id(int(uid)) + user.travel_history.append(event) + if event: + return render_template("event_booked.html", event=event) + else: + abort(404) ############################# ## And, liftoff! -app.run(port=8000, debug=True) \ No newline at end of file +app.run(host="0.0.0.0",port=8000, debug=True) \ No newline at end of file diff --git a/static/bettmeralp_weg.png b/static/bettmeralp_weg.png new file mode 100644 index 0000000..dfaf49f Binary files /dev/null and b/static/bettmeralp_weg.png differ diff --git a/static/custom-bootstrap-override.css b/static/custom-bootstrap-override.css index 12d9304..d507ba8 100644 --- a/static/custom-bootstrap-override.css +++ b/static/custom-bootstrap-override.css @@ -12,6 +12,10 @@ .content { margin-top: 5rem; } + +.fa-star{ + color: #D50505; +} /* * * ========================================== @@ -62,8 +66,10 @@ .ml4 .letters { position: absolute; - margin: auto; + margin-left: 0.8rem; + margin-top: 0.12rem; + /* margin: auto; left: 6.7em; - top: 0.75em; + top: 0.75em; */ opacity: 0; } \ No newline at end of file diff --git a/static/index.js b/static/index.js index 2bfc774..18d65fd 100644 --- a/static/index.js +++ b/static/index.js @@ -22,7 +22,7 @@ $(window).on("scroll", function () { function callData(counter) { $.ajax({ type: "GET", - url: "http://localhost:8000/get_event?id=" + counter, + url: "/get_event?id=" + counter, dataType: "html", success: function (result) { //alert(result[0]); diff --git a/static/travelhistorymap_customer235.html b/static/travelhistorymap_customer235.html deleted file mode 100644 index 3ed95f1..0000000 --- a/static/travelhistorymap_customer235.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - \ No newline at end of file diff --git a/static/travelhistorymap_customer239842123.html b/static/travelhistorymap_customer239842123.html index 8e4ab46..1c67e23 100644 --- a/static/travelhistorymap_customer239842123.html +++ b/static/travelhistorymap_customer239842123.html @@ -23,7 +23,7 @@