Exemple #1
0
def form_to_session(trackid, sessionkey, formdata):

    session = formdata.copy()
    trackname = get_trackname(trackid)

    session['tracks'] = trackname
    for track in formdata['tracks'].split(","):
        track = track.strip().capitalize()
        if is_valid_track(track):
            session['tracks'] = "%s, %s" % (session['tracks'], track)

    # Fishbowl can specify a name
    if session_type(sessionkey) == 'FISHBOWL':
        if not session['name'].startswith(trackname+": "):
            session['name'] = trackname + ": " + session['name']

    # Workrooms have a mandatory name
    if session_type(sessionkey) == 'WORKROOM':
        session['name'] = WORKROOM_TITLE % trackname

    # Meetups have a mandatory name and description
    if session_type(sessionkey) == 'MEETUP':
        session['name'] = MEETUP_TITLE % trackname
        session['description'] = MEETUP_DESCRIPTION % trackname
        if formdata['urllink']:
            session['description'] += MEETUP_LINK % formdata['urllink']

    session['description'] = session['description'].replace('\n', '<br />')
    return session
Exemple #2
0
def session_to_form(trackid, sessionkey, session):
    form = session.copy()

    try:
        form['description'] = form['description'].replace('<br />', '\n')
    except KeyError:
        form['description'] = "tbd"

    trackname = get_trackname(trackid)

    form['event_type'] = form['event_type'].replace(trackname,"")
    form['event_type'] = form['event_type'].strip(" ,")

    # Fishbowls keep their name, trackname is mandatory
    if form['sessiontype'] == 'FISHBOWL':
        if form['name'].startswith(trackname+": "):
            form['name'] = form['name'][len(trackname+": "):]
    else:
        # Workrooms & meetups have a mandatory name
        if form['sessiontype'] == 'WORKROOM':
            form['name'] = WORKROOM_TITLE % trackname
        if form['sessiontype'] == 'MEETUP':
            form['name'] = MEETUP_TITLE % trackname
            start = session['description'].find("<a href='")
            end = session['description'].find("here</a>")
            if start != -1 and end != -1:
                form['urllink'] = session['description'][start+9:end-2]
            else:
                form['urllink'] = ''

    return form