示例#1
0
def field():
    default_timerange = get_default_timerange()
    default_field_dict = get_default_field_dict()
    default_field_enname, default_field_zhname = get_default_field_name()
    if 'logged_in' in session and session['logged_in']:
        if session['user'] == 'admin':
            during = request.args.get('during', None)
            if not during or during == '':
                during = MinInterval
            else:
                during = str2ts(during)
            
            dur_time = request.args.get('time', None)
            dur_time = _utf_encode(dur_time)
            if not dur_time or dur_time == '':
                start_ts, end_ts = _default_time_zone()
            else:
                start_ts, end_ts = _time_zone(dur_time)

            field_name = request.args.get('field_name', '')
            if field_name == '':
                return render_template('moodlens/index.html', time_range=default_timerange, field_en=default_field_enname, \
                                       field_zh=default_field_zhname, field_dict=default_field_dict)
            else:
                print field_name
                field_en = DOMAIN_LIST[DOMAIN_ZH_LIST.index(field_name)]
                print field_en           
                                   #对field_emtion页面进行渲染
            return render_template('moodlens/field_emotion.html', start_ts=start_ts, end_ts=end_ts, during=during,field_en=field_en)
            
        else:
            pass

    else:
        return redirect('/')
示例#2
0
def field():
    if 'logged_in' in session and session['logged_in']:
        if session['user'] == 'admin':
            during = request.args.get('during', None)
            if not during or during == '':
                during = MinInterval
            else:
                during = str2ts(during)
            
            dur_time = request.args.get('time', None)
            dur_time = _utf_encode(dur_time)
            if not dur_time or dur_time == '':
                start_ts, end_ts = _default_time_zone()
            else:
                start_ts, end_ts = _time_zone(dur_time)

            field_name = request.args.get('field_name', '')
            if field_name == '':
                return render_template('moodlens/index.html', active='moodlens')
            else:
                field_en = DOMAIN_LIST[DOMAIN_ZH_LIST.index(field_name)]

            return render_template('moodlens/field_emotion.html', start_ts=start_ts, end_ts=end_ts, during=during,field_en=field_en)
            
        else:
            pass

    else:
        return redirect('/')