profiled view finished
This commit is contained in:
@@ -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)
|
@@ -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:
|
||||
|
Reference in New Issue
Block a user