def main(): nm = NotificationManager() bs = BackendService() ids = bs.expired_ids() email_to = bs.get_active_users() subject = 'kończące się umowy' body = nm.generate_body('notification', ids, context={'subject': subject}) # send mail to users nm.notify(subject, body, email_to)
from notification_manager import NotificationManager from pprint import pprint data_manager = DataManager() sheet_data = data_manager.get_destination_data() flight_search = FlightSearch() notification_manager = NotificationManager() ORIGIN_CITY_IATA = "YYZ" if sheet_data[0]["iataCode"] == "": for row in sheet_data: row["iataCode"] = flight_search.get_destination_code(row["city"]) data_manager.destination_data = sheet_data data_manager.update_destination_codes() tomorrow = datetime.now() + timedelta(days=1) six_month_from_today = datetime.now() + timedelta(days=(6 * 30)) pprint(sheet_data) for destination in sheet_data: flight = flight_search.check_flights( ORIGIN_CITY_IATA, destination["iataCode"], from_time=tomorrow, to_time=six_month_from_today ) if flight: if int(flight.price)< int(destination['lowestPrice']): notification_manager.notify(flight)