def user_info(): # 修改个人信息 user = query_user_by_name(session.get("user_name")) # 打开修改信息页面,将原来信息展示出来,消息回填 form = InfoForm() if form.validate_on_submit(): current_login_name = session.get("user_name") old_name = user.name new_name = request.form["user_name"] query_user = query_user_by_name(new_name) if query_user == None or current_login_name == query_user.name: # 如果数据库没有这个用户名或者当前登录的用户名和更改的用户名一样(本人操作),都可以更新个人信息 user.name = request.form["user_name"] user.email = request.form["user_email"] user.age = request.form["user_age"] user.birthday = request.form["user_birthday"] user.face = request.form["user_face"] update_user_by_name(old_name, user) flash(message="用户信息已更新!", category="ok") session.pop("user_name", None) # 修改密码后需要重新登录,然后清除session中的数据 session["user_name"] = user.name return redirect(url_for("user_detail")) else: flash(message="用户名已存在!", category="err") return render_template("user_info.html", user=user, form=form)
def create(): form = InfoForm() if form.validate_on_submit(): create = Info(name=request.form["name"], content=request.form["content"]) db.session.add(create) db.session.commit() return redirect(url_for('dashboard')) return render_template('authentication/create.html', form=form)
def create_notification(): form = InfoForm() if form.validate_on_submit(): create = Notice(name=form.name.data, content=form.content.data) db.session.add(create) db.session.commit() return redirect(url_for('dashboard')) return render_template('authentication/create_notification.html', form=form)
def update(id): form = InfoForm() info = Info.query.filter_by(id=id).first() form.name.data = info.name form.content.data = info.content if form.validate_on_submit(): info.name = request.form['name'] info.content = request.form['content'] db.session.commit() return redirect(url_for('dashboard')) return render_template('authentication/update.html', form=form, info=info)
def submit(): form = InfoForm() if form.validate_on_submit(): appendIfNotExist(form.currency.data, form.fromDate.data, form.tillDate.data) session['currency'] = form.currency.data session['fromDate'] = form.fromDate.data session['tillDate'] = form.tillDate.data return redirect(url_for('summary')) return render_template('forms.html', form=form)
def update_meeting_date(): form = InfoForm() dates = MeetingDate.query.first() form.name.data = dates.name form.content.data = dates.content if form.validate_on_submit(): dates.name = request.form['name'] dates.content = request.form['content'] db.session.commit() return redirect(url_for('dashboard')) return render_template('authentication/update_meeting_date.html', form=form, dates=dates)
def user_info(): form = InfoForm() user = query_user_by_name(session.get("user_name")) if form.validate_on_submit(): old_name = user.name user.name = form.data["user_name"] user.email = form.data["user_email"] user.age = form.data["user_edge"] user.birthday = form.data["user_birthday"] user.face = form.data["user_face"] update_user_by_name(old_name, user) session["user_name"] = user.name return redirect(url_for("user_detail")) return render_template("user_info.html", user=user, form=form)
def add(): form = InfoForm() if form.validate_on_submit(): data = form.getDataDict() schoolnum = Info.query.filter_by(name=data['schoolnum']).first() print(schoolnum) if schoolnum: flash(message="student id is exists") else: info = Info() for i in data: if hasattr(info, i): setattr(info, i, data[i]) db.session.add(info) db.session.commit() flash("commit successed!") return render_template("forms.html",form=form)
def register(): # 表单对象 form = InfoForm() if form.validate_on_submit(): user_id = request.form.get('user_id', None) user_name = request.form.get('username', None) password = request.form.get('password', None) sex = request.form.get('sex', None) birthday = request.form.get('birthday', None) # 实现注册,保存信息到User模型中 user = User(user_id) user.save_password(password) user.insert_info(user_name, sex, birthday) login_user(user) app.logger.info('user: '******' sign in') return redirect(url_for('index')) else: return render_template('register.html', form=form)
def edit_info(): form = InfoForm() if form.validate_on_submit(): current_user.name = form.name.data current_user.phone = form.phone.data current_user.gender = form.gender.data current_user.age = form.age.data current_user.about_me = form.about_me.data if session.get('avater_temp') and request.values.get('is_update_avatar',type=bool): x=request.values.get('select_x',type=int) y=request.values.get('select_y',type=int) x2=request.values.get('select_x2',type=int) y2=request.values.get('select_y2',type=int) path=session['avater_temp'] url=get_img_url(cut_img(path,(x,y,x2,y2))) current_user.avatar=url session['avater_temp']=None db.session.add(current_user) db.session.commit() return redirect(url_for('auth.info')) return render_template('auth/edit_info.html', form=form)
def edit(): form = InfoForm() if form.validate_on_submit(): role = Role.query.filter_by(name=form.name.data).first() user_role=g.user.role.all() if user_role==[]: roles= Role(position=form.position.data,name=form.name.data,tel=form.tel.data,author=g.user) db.session.add(roles) db.session.commit() flash(u'信息添加成功!') else: if role is not None: if g.user.role[0].name==role.name: role.position=form.position.data role.tel=form.tel.data db.session.add(role) db.session.commit() flash(u'信息修改成功!') else: flash(u'真实姓名不符,无法修改!') else: flash(u'真实姓名不符,无法修改!') role_list= models.Role.query.all() position_list=[] name_list=[] tel_list=[] positions=[] names=[] tels=[] for role in role_list: position_list.append(role.position) name_list.append(role.name) tel_list.append(role.tel) return render_template('edit.html', title='Home', form=form, position_list=position_list,name_list=name_list,tel_list=tel_list,role_list=role_list)
def submit(): form = InfoForm() if form.validate_on_submit(): infoList =[] for i in form: infoList.append(i.data) print(infoList) eventDf = pd.DataFrame(infoList[0:-2]).transpose() eventDf.columns = ['event_name', 'question1', 'question2', 'question3', 'answer1', 'answer2', 'answer3', 'answer4', 'answer5', 'answer6', 'answer7', 'answer8', 'answer9', ] eventDict = eventDf.to_dict('index')[0] print(eventDict) config = { "apiKey": "AIzaSyCb4oRMVM6s4eFTJ9oMU5p4Xpv_9GQvMCE", "authDomain": "studentgo-76a0d.firebaseapp.com", "databaseURL": "https://studentgo-76a0d.firebaseio.com/", "storageBucket": "studentgo-76a0d.appspot.com" } firebase = pyrebase.initialize_app(config) auth = firebase.auth() db = firebase.database() db.child("Events").push(eventDict) return redirect(url_for('home')) return render_template('form.html', title='Submit', form=form)
def index(): name=False district=False state=False area=False beds= False form = InfoForm() page = request.args.get('page', 1, type=int) print('page: ', page) if request.method == 'POST': name = form.name.data district = form.district.data state = form.state.data area = form.area.data beds = form.beds.data page = 1 print(name) print(district) if request.method == 'GET': name = request.args.get('name') state = request.args.get('state') district = request.args.get('district') area = request.args.get('area') beds = request.args.get('beds') # data = Hospital.query.order_by(Hospital.total_beds.desc()).paginate(per_page=5, page=page) if form.validate_on_submit() and request.method == "POST": print('POST request') #print(request.form['name']) # print(form.name.data) data = Hospital.query.order_by(Hospital.total_beds.desc()).paginate(per_page=5, page=page) # if request.method == "POST": #print(request.form['name']) # if name =='Please Select': # name_avail = False # if district =='Please Select': # district_avail = False # if state =='Please Select': # state_avail = False # if area =='Please Select': # area_avail = False if(name =='Please Select' and district =='Please Select' and state =='Please Select' and area =='Please Select'): if beds == 'total_beds': data = Hospital.query.order_by(Hospital.total_beds.desc()).paginate(per_page=5, page=page) elif beds== 'available_beds': data = Hospital.query.order_by(Hospital.available_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_ward_beds': data = Hospital.query.order_by(Hospital.available_ward_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_ward_beds_with_oxygen': data = Hospital.query.order_by(Hospital.available_ward_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds': data = Hospital.query.order_by(Hospital.available_icu_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds_with_oxygen': data = Hospital.query.order_by(Hospital.available_icu_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif(name != 'Please Select' and district =='Please Select' and state =='Please Select' and area =='Please Select'): if beds == 'total_beds': data = Hospital.query.filter_by(name=name).order_by(Hospital.total_beds.desc()).paginate(per_page=5, page=page) elif beds== 'available_beds': data = Hospital.query.filter_by(name=name).order_by(Hospital.available_beds).paginate(per_page=5, page=page) elif beds == 'available_ward_beds': data = Hospital.query.filter_by(name=name).order_by(Hospital.available_ward_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_ward_beds_with_oxygen': data = Hospital.query.filter_by(name=name).order_by(Hospital.available_ward_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds': data = Hospital.query.filter_by(name=name).order_by(Hospital.available_icu_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds_with_oxygen': data = Hospital.query.filter_by(name=name).order_by(Hospital.available_icu_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif(name == 'Please Select' and district !='Please Select' and state =='Please Select' and area =='Please Select'): if beds == 'total_beds': data = Hospital.query.filter_by(district=district).order_by(Hospital.total_beds.desc()).paginate(per_page=5, page=page) elif beds== 'available_beds': data = Hospital.query.filter_by(district=district).order_by(Hospital.available_beds).paginate(per_page=5, page=page) elif beds == 'available_ward_beds': data = Hospital.query.filter_by(district=district).order_by(Hospital.available_ward_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_ward_beds_with_oxygen': data = Hospital.query.filter_by(district=district).order_by(Hospital.available_ward_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds': data = Hospital.query.filter_by(district=district).order_by(Hospital.available_icu_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds_with_oxygen': data = Hospital.query.filter_by(district=district).order_by(Hospital.available_icu_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif(name == 'Please Select' and district =='Please Select' and state !='Please Select' and area =='Please Select'): if beds == 'total_beds': data = Hospital.query.filter_by(state=state).order_by(Hospital.total_beds.desc()).paginate(per_page=5, page=page) elif beds== 'available_beds': data = Hospital.query.filter_by(state=state).order_by(Hospital.available_beds).paginate(per_page=5, page=page) elif beds == 'available_ward_beds': data = Hospital.query.filter_by(state=state).order_by(Hospital.available_ward_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_ward_beds_with_oxygen': data = Hospital.query.filter_by(state=state).order_by(Hospital.available_ward_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds': data = Hospital.query.filter_by(state=state).order_by(Hospital.available_icu_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds_with_oxygen': data = Hospital.query.filter_by(state=state).order_by(Hospital.available_icu_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif(name == 'Please Select' and district =='Please Select' and state =='Please Select' and area !='Please Select'): if beds == 'total_beds': data = Hospital.query.filter_by(area=area).order_by(Hospital.total_beds.desc()).paginate(per_page=5, page=page) elif beds== 'available_beds': data = Hospital.query.filter_by(area=area).order_by(Hospital.available_beds).paginate(per_page=5, page=page) elif beds == 'available_ward_beds': data = Hospital.query.filter_by(area=area).order_by(Hospital.available_ward_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_ward_beds_with_oxygen': data = Hospital.query.filter_by(area=area).order_by(Hospital.available_ward_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds': data = Hospital.query.filter_by(area=area).order_by(Hospital.available_icu_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds_with_oxygen': data = Hospital.query.filter_by(area=area).order_by(Hospital.available_icu_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif(name != 'Please Select' and district !='Please Select' and state =='Please Select' and area =='Please Select'): if beds == 'total_beds': data = Hospital.query.filter_by(name=name, district=district).order_by(Hospital.total_beds.desc()).paginate(per_page=5, page=page) elif beds== 'available_beds': data = Hospital.query.filter_by(name=name, district=district).order_by(Hospital.available_beds).paginate(per_page=5, page=page) elif beds == 'available_ward_beds': data = Hospital.query.filter_by(name=name, district=district).order_by(Hospital.available_ward_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_ward_beds_with_oxygen': data = Hospital.query.filter_by(name=name, district=district).order_by(Hospital.available_ward_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds': data = Hospital.query.filter_by(name=name, district=district).order_by(Hospital.available_icu_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds_with_oxygen': data = Hospital.query.filter_by(name=name, district=district).order_by(Hospital.available_icu_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif(name != 'Please Select' and district =='Please Select' and state !='Please Select' and area =='Please Select'): if beds == 'total_beds': data = Hospital.query.filter_by(name=name, state=state).order_by(Hospital.total_beds.desc()).paginate(per_page=5, page=page) elif beds== 'available_beds': data = Hospital.query.filter_by(name=name, state=state).order_by(Hospital.available_beds).paginate(per_page=5, page=page) elif beds == 'available_ward_beds': data = Hospital.query.filter_by(name=name, state=state).order_by(Hospital.available_ward_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_ward_beds_with_oxygen': data = Hospital.query.filter_by(name=name, state=state).order_by(Hospital.available_ward_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds': data = Hospital.query.filter_by(name=name, state=state).order_by(Hospital.available_icu_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds_with_oxygen': data = Hospital.query.filter_by(name=name, state=state).order_by(Hospital.available_icu_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif(name != 'Please Select' and district =='Please Select' and state =='Please Select' and area !='Please Select'): if beds == 'total_beds': data = Hospital.query.filter_by(name=name, area=area).order_by(Hospital.total_beds.desc()).paginate(per_page=5, page=page) elif beds== 'available_beds': data = Hospital.query.filter_by(name=name, area=area).order_by(Hospital.available_beds).paginate(per_page=5, page=page) elif beds == 'available_ward_beds': data = Hospital.query.filter_by(name=name, area=area).order_by(Hospital.available_ward_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_ward_beds_with_oxygen': data = Hospital.query.filter_by(name=name, area=area).order_by(Hospital.available_ward_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds': data = Hospital.query.filter_by(name=name, area=area).order_by(Hospital.available_icu_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds_with_oxygen': data = Hospital.query.filter_by(name=name, area=area).order_by(Hospital.available_icu_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif(name == 'Please Select' and district !='Please Select' and state !='Please Select' and area =='Please Select'): if beds == 'total_beds': data = Hospital.query.filter_by(district=district, state=state).order_by(Hospital.total_beds.desc()).paginate(per_page=5, page=page) elif beds== 'available_beds': data = Hospital.query.filter_by(district=district, state=state).order_by(Hospital.available_beds).paginate(per_page=5, page=page) elif beds == 'available_ward_beds': data = Hospital.query.filter_by(district=district, state=state).order_by(Hospital.available_ward_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_ward_beds_with_oxygen': data = Hospital.query.filter_by(district=district, state=state).order_by(Hospital.available_ward_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds': data = Hospital.query.filter_by(district=district, state=state).order_by(Hospital.available_icu_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds_with_oxygen': data = Hospital.query.filter_by(district=district, state=state).order_by(Hospital.available_icu_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif(name == 'Please Select' and district !='Please Select' and state =='Please Select' and area !='Please Select'): if beds == 'total_beds': data = Hospital.query.filter_by(district=district, area=area).order_by(Hospital.total_beds.desc()).paginate(per_page=5, page=page) elif beds== 'available_beds': data = Hospital.query.filter_by(district=district, area=area).order_by(Hospital.available_beds).paginate(per_page=5, page=page) elif beds == 'available_ward_beds': data = Hospital.query.filter_by(district=district, area=area).order_by(Hospital.available_ward_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_ward_beds_with_oxygen': data = Hospital.query.filter_by(district=district, area=area).order_by(Hospital.available_ward_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds': data = Hospital.query.filter_by(district=district, area=area).order_by(Hospital.available_icu_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds_with_oxygen': data = Hospital.query.filter_by(district=district, area=area).order_by(Hospital.available_icu_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif(name == 'Please Select' and district =='Please Select' and state !='Please Select' and area !='Please Select'): if beds == 'total_beds': data = Hospital.query.filter_by(state=state, area=area).order_by(Hospital.total_beds.desc()).paginate(per_page=5, page=page) elif beds== 'available_beds': data = Hospital.query.filter_by(state=state, area=area).order_by(Hospital.available_beds).paginate(per_page=5, page=page) elif beds == 'available_ward_beds': data = Hospital.query.filter_by(state=state, area=area).order_by(Hospital.available_ward_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_ward_beds_with_oxygen': data = Hospital.query.filter_by(state=state, area=area).order_by(Hospital.available_ward_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds': data = Hospital.query.filter_by(state=state, area=area).order_by(Hospital.available_icu_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds_with_oxygen': data = Hospital.query.filter_by(state=state, area=area).order_by(Hospital.available_icu_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif(name != 'Please Select' and district !='Please Select' and state !='Please Select' and area =='Please Select'): if beds == 'total_beds': data = Hospital.query.filter_by(name=name, district=district, state=state).order_by(Hospital.total_beds.desc()).paginate(per_page=5, page=page) elif beds== 'available_beds': data = Hospital.query.filter_by(name=name, district=district, state=state).order_by(Hospital.available_beds).paginate(per_page=5, page=page) elif beds == 'available_ward_beds': data = Hospital.query.filter_by(name=name, district=district, state=state).order_by(Hospital.available_ward_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_ward_beds_with_oxygen': data = Hospital.query.filter_by(name=name, district=district, state=state).order_by(Hospital.available_ward_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds': data = Hospital.query.filter_by(name=name, district=district, state=state).order_by(Hospital.available_icu_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds_with_oxygen': data = Hospital.query.filter_by(name=name, district=district, state=state).order_by(Hospital.available_icu_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif(name != 'Please Select' and district !='Please Select' and state =='Please Select' and area !='Please Select'): if beds == 'total_beds': data = Hospital.query.filter_by(name=name, district=district, area=area).order_by(Hospital.total_beds.desc()).paginate(per_page=5, page=page) elif beds== 'available_beds': data = Hospital.query.filter_by(name=name, district=district, area=area).order_by(Hospital.available_beds).paginate(per_page=5, page=page) elif beds == 'available_ward_beds': data = Hospital.query.filter_by(name=name, district=district, area=area).order_by(Hospital.available_ward_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_ward_beds_with_oxygen': data = Hospital.query.filter_by(name=name, district=district, area=area).order_by(Hospital.available_ward_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds': data = Hospital.query.filter_by(name=name, district=district, area=area).order_by(Hospital.available_icu_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds_with_oxygen': data = Hospital.query.filter_by(name=name, district=district, area=area).order_by(Hospital.available_icu_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif(name != 'Please Select' and district =='Please Select' and state !='Please Select' and area !='Please Select'): if beds == 'total_beds': data = Hospital.query.filter_by(name=name, state=state, area=area).order_by(Hospital.total_beds.desc()).paginate(per_page=5, page=page) elif beds== 'available_beds': data = Hospital.query.filter_by(name=name, state=state, area=area).order_by(Hospital.available_beds).paginate(per_page=5, page=page) elif beds == 'available_ward_beds': data = Hospital.query.filter_by(name=name, state=state, area=area).order_by(Hospital.available_ward_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_ward_beds_with_oxygen': data = Hospital.query.filter_by(name=name, state=state, area=area).order_by(Hospital.available_ward_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds': data = Hospital.query.filter_by(name=name, state=state, area=area).order_by(Hospital.available_icu_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds_with_oxygen': data = Hospital.query.filter_by(name=name, state=state, area=area).order_by(Hospital.available_icu_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif(name == 'Please Select' and district !='Please Select' and state !='Please Select' and area !='Please Select'): if beds == 'total_beds': data = Hospital.query.filter_by(district=district, state=state, area=area).order_by(Hospital.total_beds.desc()).paginate(per_page=5, page=page) elif beds== 'available_beds': data = Hospital.query.filter_by(district=district, state=state, area=area).order_by(Hospital.available_beds).paginate(per_page=5, page=page) elif beds == 'available_ward_beds': data = Hospital.query.filter_by(district=district, state=state, area=area).order_by(Hospital.available_ward_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_ward_beds_with_oxygen': data = Hospital.query.filter_by(district=district, state=state, area=area).order_by(Hospital.available_ward_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds': data = Hospital.query.filter_by(district=district, state=state, area=area).order_by(Hospital.available_icu_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds_with_oxygen': data = Hospital.query.filter_by(district=district, state=state, area=area).order_by(Hospital.available_icu_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif(name != 'Please Select' and district !='Please Select' and state !='Please Select' and area !='Please Select'): if beds == 'total_beds': data = Hospital.query.filter_by(name=name, district=district, state=state, area=area).order_by(Hospital.total_beds.desc()).paginate(per_page=5, page=page) elif beds== 'available_beds': data = Hospital.query.filter_by(name=name, district=district, state=state, area=area).order_by(Hospital.available_beds).paginate(per_page=5, page=page) elif beds == 'available_ward_beds': data = Hospital.query.filter_by(name=name, district=district, state=state, area=area).order_by(Hospital.available_ward_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_ward_beds_with_oxygen': data = Hospital.query.filter_by(name=name, district=district, state=state, area=area).order_by(Hospital.available_ward_beds_with_oxygen.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds': data = Hospital.query.filter_by(name=name, district=district, state=state, area=area).order_by(Hospital.available_icu_beds.desc()).paginate(per_page=5, page=page) elif beds == 'available_icu_beds_with_oxygen': data = Hospital.query.filter_by(name=name, district=district, state=state, area=area).order_by(Hospital.available_icu_beds_with_oxygen.desc()).paginate(per_page=5, page=page) else: data = Hospital.query.order_by(Hospital.total_beds.desc()).paginate(per_page=5, page=page) print("Get Request") form.name.data = name form.district.data = district form.state.data = state form.area.data = area form.beds.data = beds return render_template('index.html', form=form, name=name, district=district, state=state, area=area, beds=beds, hospitals=data)