def update_future_events(): url = '{0}/export/categ/0.json?ak={1}&from=now&limit=20'.format( current_app.config['SERVER_URL'], current_app.config['API_KEY']) f = urllib2.urlopen(url) events = json.loads(f.read().decode('utf-8'))['results'] for event in events: if db.Event.find({'id': event['id']}).count() == 0: # store event event_tt = fetch_timetable(event['id']) store_event(event, event_tt)
def update_future_events(): url = "{0}/export/categ/0.json?ak={1}&from=1d&limit=50".format( current_app.config["SERVER_URL"], current_app.config["API_KEY"] ) f = urllib2.urlopen(url) events = json.loads(f.read().decode("utf-8"))["results"] for event in events: if db.Event.find({"id": event["id"]}).count() == 0: # store event event_tt = fetch_timetable(event["id"]) store_event(event, event_tt)
def with_event(): """ Gets executed before every request in this blueprint """ event_id = request.view_args.get('event_id') if event_id: event_http = get_event_info(event_id) event_db = db.Event.find_one({'id': event_id}) if not event_db: event_tt = fetch_timetable(event_id) store_event(event_http, event_tt) elif utc.localize(event_db['modificationDate']) < dt_from_indico(event_http['modificationDate']): Event.cleanup(event_id) event_tt = fetch_timetable(event_id) store_event(event_http, event_tt)
def with_event(event_id=None): """ Gets executed before every request in this blueprint """ event_id = request.view_args.get("event_id") if event_id: event_http = get_event_info(event_id) if not "error" in event_http: event_db = db.Event.find_one({"id": event_id}) if not event_db: event_tt = fetch_timetable(event_id) store_event(event_http, event_tt) elif utc.localize(event_db["modificationDate"]) < dt_from_indico(event_http["modificationDate"]): Event().cleanup(event_id) event_tt = fetch_timetable(event_id) store_event(event_http, event_tt) else: abort(401)