예제 #1
0
def register():
    if request.method == 'POST' and request.form:
        password = request.form['password']
        sid = request.form['sid']
        s = Student(sid)
        if s.register(password):
            return redirect('/login/')
        else:
            return "registration error"
    elif request.method == 'GET':
        return render_template('register.html',
                               title='register',
                               login=session['logged_in'])
예제 #2
0
def login():
    if request.method == 'GET':
        return render_template('login.html')
    elif request.method == 'POST':
        s = Student(request.form['sid'])
        if s.login(request.form['password']):
            session['logged_in'] = True
            session['id'] = request.form['sid']
            return redirect('/home/')
        else:
            session['logged_in'] = False
            return "wrong"
    else:
        return "something bad happened"
예제 #3
0
def schedule():
    if session.get('logged_in'):
        s = Student(session['id'])
        d = Department()
        return render_template('schedule.html', user=s, dept=d)
    else:
        return redirect('/login/')
예제 #4
0
def fees():
    if session.get('logged_in'):
        s = Student(session.get('id'))
        return render_template('fees.html',
                               user=s,
                               title='Fees',
                               userid=session.get('id'))
    else:
        return redirect('/login/')
예제 #5
0
def home():
    if not session.get('logged_in'):
        return redirect('/login/')
    else:
        if request.method == 'GET':
            return render_template('home.html',
                                   login=session['logged_in'],
                                   user=Student(session['id']),
                                   depts=Department.getdepts())
예제 #6
0
def register_interface(name, password):
    user = db_handler.select(STATUS, name)
    if user:
        return False, '用户已经存在'
    else:
        from lib.Student import Student
        new_manager = Student(name, password)
        db_handler.save(STATUS, new_manager)
        user_logger.info('%s 注册了' % name)
        return True, '注册成功'
예제 #7
0
    path = setting.BASE_USER_DB
    save(path, obj)


# 获取user列表
def get_user_list():
    path = setting.BASE_USER_DB
    return listdir(path)


def select_group_chat(name):
    path = setting.BASE_GROUP_CHAT_DB
    return select(path, name)


def save_group_chat(obj):
    path = setting.BASE_GROUP_CHAT_DB
    save(path, obj)


# 获取群聊列表
def get_group_chat_list():
    path = setting.BASE_GROUP_CHAT_DB
    return listdir(path)


if __name__ == '__main__':
    from lib.Student import Student
    us = Student('xm', '123')
    print(save_user('student', us))
    print(select_user('student', 'xm'))
예제 #8
0
def enrollment(dept, term):
    return jsonify(Student.enrollment_list(dept, term))
예제 #9
0
def students_dept(dept):
    return jsonify(Student.student_list(dept))
예제 #10
0
def count_courses():
    if request.json:
        s = Student(session.get('id'))
        count = s.count_courses(request.json['term'], request.json['year'])
        print(count)
        return jsonify(count[0])
예제 #11
0
def registered_corses(year, term):
    s = Student(session['id'])
    return jsonify(s.my_courses(term, year))
예제 #12
0
def deregister_course():
    term, year, crn = request.json['term'], request.json['year'], request.json[
        'crn']
    s = Student(session['id'])
    s.drop_course(term, year, crn)
    return "success"
예제 #13
0
def admin():
    s = Student(0)
    return render_template('admin.html', title='Admin', user=s)