Пример #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 remove_contribution(event_id, contribution_id):
    user_id = flask_session['indico_user']
    favorites_contribution = db_contribution.get_favorites_contribution(user_id, event_id, contribution_id)
    contribution_db = db_contribution.get_contribution(event_id, contribution_id)
    session_id = None
    if contribution_db['slot']:
        session_id = contribution_db['slot']['sessionId']
    if favorites_contribution:
        db_contribution.remove_contribution_from_favorites(user_id, event_id, contribution_id)
    elif db_event.get_favorites_event(user_id, event_id):
        db_event.remove_event_from_favorites(user_id, event_id)
        contributions = db_contribution.get_event_contributions(event_id, {'contributionId': {'$ne': contribution_id}})
        for contribution in contributions:
            add_contribution(event_id, contribution['contributionId'])
    elif session_id:
        if  db_contribution.get_favorites_contribution(user_id, event_id, session_id):
            contributions = db_contribution.get_event_contributions(event_id, {'slot':{'$ne': None}, 'contributionId': {'$ne': contribution_id}}, True)
            db_session.remove_session_from_favorites(user_id, event_id, session_id)
            for contribution in contributions:
                if contribution['slot']['sessionId'] == session_id:
                    add_contribution(event_id, contribution['contributionId'])
    return ''
Пример #3
0
def remove_contribution(event_id, contribution_id):
    user_id = flask_session['indico_user']
    favorites_contribution = db_contribution.get_favorites_contribution(
        user_id, event_id, contribution_id)
    contribution_db = db_contribution.get_contribution(event_id,
                                                       contribution_id)
    session_id = None
    if contribution_db['slot']:
        session_id = contribution_db['slot']['sessionId']
    if favorites_contribution:
        db_contribution.remove_contribution_from_favorites(
            user_id, event_id, contribution_id)
    elif db_event.get_favorites_event(user_id, event_id):
        db_event.remove_event_from_favorites(user_id, event_id)
        contributions = db_contribution.get_event_contributions(
            event_id, {'contributionId': {
                '$ne': contribution_id
            }})
        for contribution in contributions:
            add_contribution(event_id, contribution['contributionId'])
    elif session_id:
        if db_contribution.get_favorites_contribution(user_id, event_id,
                                                      session_id):
            contributions = db_contribution.get_event_contributions(
                event_id, {
                    'slot': {
                        '$ne': None
                    },
                    'contributionId': {
                        '$ne': contribution_id
                    }
                }, True)
            db_session.remove_session_from_favorites(user_id, event_id,
                                                     session_id)
            for contribution in contributions:
                if contribution['slot']['sessionId'] == session_id:
                    add_contribution(event_id, contribution['contributionId'])
    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 ''