Пример #1
0
def store_event(event_http, event_tt):
    convert_dates(event_http)
    clean_html_tags(event_http)

    event_id = event_http['id']
    store_material(event_http)
    store_chairs(event_http)

    event_db = db.Event()
    event_db.update(event_http)
    event_db.pop('_type')
    event_db.pop('visibility')
    event_db.save()

    for day, day_content in event_tt.get(event_id, {}).iteritems():
        entries = []

        for _, block_content in day_content.iteritems():
            if block_content['_type'] == 'LinkedTimeSchEntry':
                entry = store_slot(block_content, event_db)
            else:
                entry = store_contribution(block_content, event_db)
            entries.append(ref(entry))
        if len(day_content.keys()) > 0:
            date = datetime.strptime(day, '%Y%M%d').strftime('%Y-%M-%d').decode('utf-8')
            day = db.Day()
            day['date'] = date
            day['conferenceId'] = event_id
            day['entries'] = entries
            day.save()
Пример #2
0
def store_slot(slot, event):
    convert_dates(slot)
    clean_html_tags(slot)

    is_poster = slot['isPoster']
    slot_id = slot['id']
    color = slot['color']

    slot['event'] = ref(event)
    slot.pop('conveners')
    slot.pop('_type')

    db_slot = db.SessionSlot()
    db_slot.update(slot)
    db_slot['entries'] = []

    db_slot=db.SessionSlot.find_and_modify({'conferenceId': db_slot["conferenceId"], 'id': slot_id}, db_slot, upsert=True, new=True)


    entries = []

    for _, block_content in slot.get('entries', {}).iteritems():
        if block_content['_type'] == 'ContribSchEntry':
            entries.append(ref(store_contribution(block_content, event, color, is_poster, db_slot)))
    db_slot['entries'] = entries
    if len(db_slot['entries']) > 0:
        db_slot=db.SessionSlot.find_and_modify({'conferenceId': db_slot["conferenceId"], 'id': slot_id}, db_slot, upsert=True, new=True)
        store_material(slot)
    return db_slot
Пример #3
0
def store_event(event_http, event_tt):
    convert_dates(event_http)
    clean_html_tags(event_http)

    event_id = event_http['id']
    store_material(event_http)
    store_chairs(event_http)

    event_db = db.Event()
    event_db.update(event_http)
    event_db.pop('_type')
    event_db.pop('visibility')
    saved_event = db.Event.find_and_modify({'id': event_id}, event_db, upsert=True, new=True)

    for day, day_content in event_tt.get(event_id, {}).iteritems():
        entries = []

        for _, block_content in day_content.iteritems():
            if block_content['entryType'] == 'Block':
                entry = store_slot(block_content, saved_event)
            else:
                entry = store_contribution(block_content, saved_event)
            entries.append(ref(entry))
        if len(day_content.keys()) > 0:
            date = datetime.strptime(day, '%Y%M%d').strftime('%Y-%M-%d').decode('utf-8')
            day = db.Day()
            day['date'] = date
            day['conferenceId'] = event_id
            day['entries'] = entries
            db.Day.find_and_modify({'conferenceId': event_id, 'date': date}, day, upsert=True)
Пример #4
0
def store_slot(slot, event):
    convert_dates(slot)
    clean_html_tags(slot)

    session_id = slot['sessionId']
    is_poster = slot['isPoster']
    slot_id = slot['id']
    color = slot['color']

    slot['event'] = ref(event)
    slot.pop('conveners')
    slot.pop('_type')

    db_slot = db.SessionSlot()
    db_slot.update(slot)
    db_slot['entries'] = []

    db_slot.save()

    entries = []

    for contribution, block_content in slot.get('entries', {}).iteritems():
        if block_content['_type'] == 'ContribSchEntry':
            entries.append(ref(store_contribution(block_content, event, color, is_poster, db_slot)))
    db_slot['entries'] = entries
    if len(db_slot['entries']) > 0:
        db_slot.save()
        store_material(slot)
    return db_slot
Пример #5
0
def store_slot(slot, event):
    convert_dates(slot)
    clean_html_tags(slot)

    is_poster = slot['isPoster']
    slot_id = slot['id']
    color = slot['color']

    slot['event'] = ref(event)
    slot.pop('conveners')
    slot.pop('_type')

    db_slot = db.SessionSlot()
    db_slot.update(slot)
    db_slot['entries'] = []

    db_slot = db.SessionSlot.find_and_modify(
        {
            'conferenceId': db_slot["conferenceId"],
            'id': slot_id
        },
        db_slot,
        upsert=True,
        new=True)

    entries = []

    for _, block_content in slot.get('entries', {}).iteritems():
        if block_content['_type'] == 'ContribSchEntry':
            entries.append(
                ref(
                    store_contribution(block_content, event, color, is_poster,
                                       db_slot)))
    db_slot['entries'] = entries
    if len(db_slot['entries']) > 0:
        db_slot = db.SessionSlot.find_and_modify(
            {
                'conferenceId': db_slot["conferenceId"],
                'id': slot_id
            },
            db_slot,
            upsert=True,
            new=True)
        store_material(slot)
    return db_slot
Пример #6
0
def store_event(event_http, event_tt):
    convert_dates(event_http)
    clean_html_tags(event_http)

    event_id = event_http['id']
    store_material(event_http)
    store_chairs(event_http)

    event_db = db.Event()
    event_db.update(event_http)
    event_db.pop('_type')
    event_db.pop('visibility')
    saved_event = db.Event.find_and_modify({'id': event_id},
                                           event_db,
                                           upsert=True,
                                           new=True)

    for day, day_content in event_tt.get(event_id, {}).iteritems():
        entries = []

        for _, block_content in day_content.iteritems():
            if block_content['_type'] == 'LinkedTimeSchEntry':
                entry = store_slot(block_content, saved_event)
            else:
                entry = store_contribution(block_content, saved_event)
            entries.append(ref(entry))
        if len(day_content.keys()) > 0:
            date = datetime.strptime(
                day, '%Y%M%d').strftime('%Y-%M-%d').decode('utf-8')
            day = db.Day()
            day['date'] = date
            day['conferenceId'] = event_id
            day['entries'] = entries
            db.Day.find_and_modify({
                'conferenceId': event_id,
                'date': date
            },
                                   day,
                                   upsert=True)