def get_favorites_event_days(event_id): user_id = flask_session['indico_user'] if db_event.get_favorites_event(user_id, event_id): return Response(json.dumps(list(db_event.get_event_days(event_id))), mimetype='application/json') else: days = [] favorites_sessions = db_session.get_favorites_event_sessions( user_id, event_id) sessions = [] for session in favorites_sessions: current_session = session['session_slot'] for slot in db_session.get_event_session_slots( event_id, current_session['sessionId'], False): sessions.append(slot) contributions = db_contribution.get_favorites_event_contributions( user_id, event_id) for contribution in contributions: current_contribution = contribution['contribution'] date = current_contribution['startDate'].strftime('%Y-%m-%d') if not date in days: days.append(date) for session in sessions: date = session['startDate'].strftime('%Y-%m-%d') if not date in days: days.append(date) results = [] for day in days: results.append(db_event.create_event_day(event_id, day)) return Response(json.dumps(sorted(results, key=lambda x: x['date'])), mimetype='application/json')
def get_favorites_event_days(event_id): user_id = flask_session['indico_user'] if db_event.get_favorites_event(user_id, event_id): return Response(json.dumps(list(db_event.get_event_days(event_id))), mimetype='application/json') else: days = [] favorites_sessions = db_session.get_favorites_event_sessions(user_id, event_id) sessions = [] for session in favorites_sessions: current_session = session['session_slot'] for slot in db_session.get_event_session_slots(event_id, current_session['sessionId'], False): sessions.append(slot) contributions = db_contribution.get_favorites_event_contributions(user_id, event_id) for contribution in contributions: current_contribution = contribution['contribution'] date = current_contribution['startDate'].strftime('%Y-%m-%d') if not date in days: days.append(date) for session in sessions: date = session['startDate'].strftime('%Y-%m-%d') if not date in days: days.append(date) results = [] for day in days: results.append(db_event.create_event_day(event_id, day)) return Response(json.dumps(sorted(results, key=lambda x:x['date'])), mimetype='application/json')
def get_event_days(event_id): return [day for day in db_event.get_event_days(event_id)]