profiled view finished

This commit is contained in:
Remy Moll
2021-10-31 02:14:05 +01:00
parent 045fd54891
commit 73ef0d5931
11 changed files with 379 additions and 179 deletions

View File

@@ -1,16 +1,22 @@
class Event:
coordinates = []
id = 0
location_name = []
location_coordinates = []
reviews = []
category = []
weather_requirements = 0
trip_to = ""
date = ""
duration = "" # datetime object
trip_to = "" # Trip object
trip_back = ""
def __init__(self, **kwargs):
pass
self.id = kwargs.pop("id")
self.location_name = kwargs.pop("location_name")
self.location_coordinates = kwargs.pop("location_coordinates")
self.date = kwargs.pop("date")
def find_optimal_trip(self):
pass
@@ -19,6 +25,12 @@ class Event:
def trip_is_good(self):
pass
@property
def co2_savings(self):
try:
return self.trip_to.co2_savings + self.trip_back.co2_savings
except:
return 5
class Review:
@@ -35,4 +47,16 @@ class Review:
def add_photo(self, photo):
pass
class Events:
_events = []
def add_event(self, **kwargs):
self._events.append(Event(**kwargs))
def get_by_id(self, id):
for e in self.events:
if e.id == id:
return e
def __iter__(self):
return iter(self._events)

View File

@@ -7,8 +7,7 @@ class User:
group_size = 0
min_age = 0
max_age = 0
travel_history = [] # (Name, coordinates)
co2_savings = []
travel_history = [] # (list of Events)
def __init__(self, **kwargs):
self.id = kwargs.pop("id")
@@ -27,7 +26,8 @@ class User:
@property
def total_co2_savings(self):
return sum(self.co2_savings)
return sum([e.co2_savings for e in self.travel_history])
class Users: