예제 #1
0
def remove_session(event_id, session_id):
    user_id = flask_session['indico_user']
    eventInFavorites = db_event.get_favorites_event(user_id, event_id)
    sessionInFavorites = db_session.get_favorites_session(
        user_id, event_id, session_id)
    if eventInFavorites:
        db_event.remove_event_from_favorites(user_id, event_id)
        session_ids = db_session.get_event_sessions(event_id)
        for current_id in session_ids:
            if current_id != session_id:
                session_slot = db_session.get_event_session(
                    event_id, current_id)
                if session_slot:
                    db_session.add_session_to_favorites(user_id, session_slot)
    elif sessionInFavorites:
        db_session.remove_session_from_favorites(user_id, event_id, session_id)
    else:
        contributions = db_contribution.get_favorites_event_contributions(
            user_id, event_id, True)
        for contribution in contributions:
            current_contribution = contribution['contribution']
            if current_contribution['slot']:
                current_slot = current_contribution['slot']
                if current_slot['sessionId'] == session_id:
                    remove_contribution(event_id,
                                        current_contribution['contributionId'])
    return ''
예제 #2
0
def add_session(event_id, session_id):
    user_id = flask_session['indico_user']
    favorites_sessions = db_session.get_favorites_event_sessions(user_id, event_id)
    event_sessions = db_session.get_event_sessions(event_id)
    session = db_session.get_event_session(event_id, session_id)
    if len(event_sessions)-favorites_sessions.count() == 1:
        add_event(event_id)
    elif db_session.get_favorites_session(user_id, event_id, session_id):
        print 'already in favorites'
    else:
        contributions = db_contribution.get_favorites_event_contributions(user_id, event_id, True)
        for contribution in contributions:
            current_contribution = contribution['contribution']
            if current_contribution['slot']:
                if current_contribution['slot']['sessionId'] == session_id:
                    db_contribution.remove_contribution_from_favorites(user_id, event_id, current_contribution['contributionId'])
        db_session.add_session_to_favorites(user_id, session)
    return ''
예제 #3
0
def add_session(event_id, session_id):
    user_id = flask_session['indico_user']
    favorites_sessions = db_session.get_favorites_event_sessions(
        user_id, event_id)
    event_sessions = db_session.get_event_sessions(event_id)
    session = db_session.get_event_session(event_id, session_id)
    if len(event_sessions) - favorites_sessions.count() == 1:
        add_event(event_id)
    elif db_session.get_favorites_session(user_id, event_id, session_id):
        print 'already in favorites'
    else:
        contributions = db_contribution.get_favorites_event_contributions(
            user_id, event_id, True)
        for contribution in contributions:
            current_contribution = contribution['contribution']
            if current_contribution['slot']:
                if current_contribution['slot']['sessionId'] == session_id:
                    db_contribution.remove_contribution_from_favorites(
                        user_id, event_id,
                        current_contribution['contributionId'])
        db_session.add_session_to_favorites(user_id, session)
    return ''
예제 #4
0
def remove_session(event_id, session_id):
    user_id = flask_session['indico_user']
    eventInFavorites = db_event.get_favorites_event(user_id, event_id)
    sessionInFavorites = db_session.get_favorites_session(user_id, event_id, session_id)
    if eventInFavorites:
        db_event.remove_event_from_favorites(user_id, event_id)
        session_ids = db_session.get_event_sessions(event_id)
        for current_id in session_ids:
            if current_id != session_id:
                session_slot = db_session.get_event_session(event_id, current_id)
                if session_slot:
                    db_session.add_session_to_favorites(user_id, session_slot)
    elif sessionInFavorites:
        db_session.remove_session_from_favorites(user_id, event_id, session_id)
    else:
        contributions = db_contribution.get_favorites_event_contributions(user_id, event_id, True)
        for contribution in contributions:
            current_contribution = contribution['contribution']
            if current_contribution['slot']:
                current_slot = current_contribution['slot']
                if current_slot['sessionId'] == session_id:
                    remove_contribution(event_id, current_contribution['contributionId'])
    return ''