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'])
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"
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/')
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/')
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())
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, '注册成功'
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'))
def enrollment(dept, term): return jsonify(Student.enrollment_list(dept, term))
def students_dept(dept): return jsonify(Student.student_list(dept))
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])
def registered_corses(year, term): s = Student(session['id']) return jsonify(s.my_courses(term, year))
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"
def admin(): s = Student(0) return render_template('admin.html', title='Admin', user=s)