def notification_check(): now = datetime.now() events_to_notify = TripEvent.select().where( (TripEvent.notification_sent == False) & (now.year - TripEvent.date_time.year == 0) & (now.month - TripEvent.date_time.month == 0) & (now.day - TripEvent.date_time.day == 0) & (now.hour - TripEvent.date_time.hour == 0)) notify_events(events_to_notify)
def events(trip_id): selected_events = TripEvent.select().where( TripEvent.parent_trip_id == trip_id).order_by( TripEvent.date_time.desc()) event_list = [] for e in selected_events: event_list.append(e.as_dict()) result = jsonify({'data': event_list}) return result
}, { 'parent_trip': Trip.select().first().id + 3, 'date_time': datetime(2019, 4, 2), 'location': 'Florida' }] for te in tripevent_list: TripEvent.create(parent_trip=te['parent_trip'], date_time=te['date_time'], location=te['location']) # File Attachments from models.file_attachment import FileAttachment file_list = [{ 'parent_event': TripEvent.select().first().id, 'url': 'uploadplace.com/files/test_file1.file' }, { 'parent_event': TripEvent.select().first().id + 1, 'url': 'uploadplace.com/files/test_file2.file' }, { 'parent_event': TripEvent.select().first().id + 1, 'url': 'uploadplace.com/files/test_file.txt' }, { 'parent_event': TripEvent.select().first().id + 3, 'url': 'uploadplace.com/files/another_test_file.file' }, { 'parent_event': TripEvent.select().first().id + 3, 'url': 'uploadplace.com/files/some_file.file' }, { 'parent_event': TripEvent.select().first().id + 4,
def index(): trip_event_list = [t.as_dict() for t in TripEvent.select()] result = jsonify({'data': trip_event_list}) return result