def recover_house(): email = request.args.get('email') password = request.args.get('password') house_id = int(request.args.get('house_id')) Post = [] Deleted = [] if (control.verify(email, password)): user = control.getuser(email) user['deleted_post'].remove(str(house_id)) try: user['property'].append(str(house_id)) except: user['property'] = str(house_id) house.recover_house(house_id) for i in user['property']: Post.append(house.readhouse(i)) for i in user['deleted_post']: Deleted.append(house.read_deleted_house(i)) control.putuser(email, user['user_name'], user['birthday'], password, user['phone number'], user['address'], user['property'], user['deleted_post']) else: return birthday = '-'.join(user['birthday'].split('/')[::-1]) return render_template('person_information_page.html', email=email, password=password, user_name=user['user_name'], birthday=birthday, address=user['address'], phone_number=user['phone number'], Post=Post, Deleted=Deleted)
def log_out(): email = request.args.get('email') password = request.args.get('password') if (control.verify(email, password)): control.offline(email, password) return render_template('search0.html')
def personal_info(): email = request.args.get('email') password = request.args.get('password') # print(email, password) user = dict() Post = [] Deleted = [] if (control.verify(email, password)): user = control.getuser(email) post = user['property'] for i in post: Post.append(house.readhouse(i)) try: for i in user['deleted_post']: Deleted.append(house.read_deleted_house(i)) except: pass else: return birthday = '-'.join(user['birthday'].split('/')[::-1]) return render_template('person_information_page.html', email=email, password=password, user_name=user['user_name'], birthday=birthday, address=user['address'], phone_number=user['phone number'], Post=Post, Deleted=Deleted)
def colloct(): email = request.values.get('email') password = request.values.get('password') house_id = request.values.get('house_id') if (control.verify(email, password)): user = control.getuser(email) try: post_id = user['property'] except: post_id = [] try: deleted_id = user['deleted_post'] except: deleted_id = [] try: collect = user['collect'] except: collect = [] collect.append(house_id) control.putuser(email, user['user_name'], user['birthday'], password, user['phone number'], user['address'], post_id, deleted_id, collect) return 'success' else: return 'fail'
def del_comment(): email = request.args.get('email') password = request.args.get('password') house_id = int(request.args.get('house_id')) comment_id = request.args.get('comment_id') if (control.verify(email, password)): comment.del_comment(house_id, comment_id) return ''
def post_house(): email = request.form.get('email') password = request.form.get('password') if request.method == 'POST': title = request.form.get('title') price = request.form.get('price') guest = request.values.get('guest') bedroom = request.values.get('bedroom') bed = request.values.get('bed') bath = request.values.get('bath') content = request.values.get('content') policy = request.values.get('policy') options1 = request.values.getlist("options1") options2 = request.values.getlist("options2") picname = None try: picname = [request.files['pic']] except: pass max_index = control.puthouse(email, password, picname, title, guest, bedroom, bed, bath, price, options1, options2, policy, content) Post = [] Deleted = [] if (control.verify(email, password)): user = control.getuser(email) user['property'].append(str(max_index)) try: control.putuser(email, user['user_name'], user['birthday'], password, user['phone number'], user['address'], user['property'], user['deleted_post']) except: control.putuser(email, user['user_name'], user['birthday'], password, user['phone number'], user['address'], user['property']) for i in user['property']: Post.append(house.readhouse(i)) print(Post) try: for i in user['deleted_post']: Deleted.append(house.read_deleted_house(i)) except: pass print(Deleted) birthday = '-'.join(user['birthday'].split('/')[::-1]) return render_template('person_information_page.html', email=email, password=password, user_name=user['user_name'], birthday=birthday, address=user['address'], phone_number=user['phone number'], Post=Post, Deleted=Deleted) else: return render_template('person_information_page.html')
def help_login(): if (request.method == 'GET'): email = request.args.get('login_email') password = request.args.get('login_password') if (control.verify(email, password)): return render_template('help1.html', email=email, password=password) else: return render_template('help0.html')
def reply_comment(): email = request.args.get('email') password = request.args.get('password') house_id = request.args.get('house_id') comment_id = request.args.get('comment_id') comment_content = request.args.get('comment_content') print(email, password, house_id, comment_id, comment_content) if (control.verify(email, password)): comment.add_comment(email, house_id, comment_id, comment_content) return ''
def result_list_login(): if (request.method == 'GET'): search = request.args.get('search') email = request.args.get('login_email') password = request.args.get('login_password') if (control.verify(email, password)): return render_template('result_list1.html', search_phrase=search, email=email, password=password) else: return render_template('result_list0.html')
def search_login(): if (request.method == 'GET'): email = request.args.get('login_email') password = request.args.get('login_password') print('email=', email) print('password='******'search1.html', email=email, password=password) else: return render_template('search0.html')
def remove_house(): email = request.args.get('email') password = request.args.get('password') house_id = int(request.args.get('house_id')) Post = [] Deleted = [] Collect = [] if (control.verify(email, password)): user = control.getuser(email) user['property'].remove(str(house_id)) post = user['property'] # print(post) house.remove_house(house_id) try: for i in post: Post.append(house.readhouse(i)) except: pass try: user['deleted_post'].append(str(house_id)) except: user['deleted_post'] = [str(house_id)] try: for i in user['deleted_post']: Deleted.append(house.read_deleted_house(i)) except: pass try: visible_collect = set(user['collect']).difference( set(os.listdir('data/house_del'))) for i in visible_collect: Collect.append(house.readhouse(i)) except: pass control.putuser(email, user['user_name'], user['birthday'], password, user['phone number'], user['address'], user['property'], user['deleted_post']) else: return birthday = '-'.join(user['birthday'].split('/')[::-1]) return render_template('person_information_page.html', email=email, password=password, user_name=user['user_name'], birthday=birthday, address=user['address'], phone_number=user['phone number'], Post=Post, Deleted=Deleted, Collect=Collect)
def uncolloct(): email = request.values.get('email') password = request.values.get('password') house_id = request.values.get('house_id') if (control.verify(email, password)): user = control.getuser(email) try: post = [house.readhouse(i) for i in user['property']] post_id = [i for i in user['property']] except: post = [] post_id = [] try: deleted = [ house.read_deleted_house(i) for i in user['deleted_post'] ] deleted_id = [i for i in user['deleted_post']] except: deleted = [] deleted_id = [] collect_id = [] try: collect = [] visible_collect = set(user['collect']).difference( set(os.listdir('data/house_del'))) collect_id = [item for item in visible_collect] collect_id.remove(house_id) for i in collect_id: collect.append(house.readhouse(i)) except: pass control.putuser(email, user['user_name'], user['birthday'], password, user['phone number'], user['address'], post_id, deleted_id, collect_id) user = control.getuser(email) birthday = '-'.join(user['birthday'].split('/')[::-1]) return render_template('person_information_page.html', email=email, password=password, user_name=user['user_name'], birthday=birthday, address=user['address'], phone_number=user['phone number'], Post=post, Deleted=deleted, Collect=collect) else: return 'fail'
def change_person_info(): if (request.method == 'GET'): email = request.values.get('email') password = request.values.get('password') user = control.getuser(email) if (control.verify(email, password)): try: new_password = request.values.get('new_password') address = request.values.get('address') phone_number = request.values.get('phone_number') user_name = request.values.get('user_name') birthday = request.values.get('birthday') comfirm_password = request.values.get('comfirm_password') try: Post_id = user['property'] except: Post_id = [] try: deleted_id = user['deleted_post'] except: deleted_id = [] try: collect = [] visible_collect = set(user['collect']).difference( set(os.listdir('data/house_del'))) for i in visible_collect: collect.append(house.readhouse(i)) except: collect = [] control.putuser(email, user_name, birthday, new_password, phone_number, address, Post_id, deleted_id, collect) return render_template('person_information_page.html', email=email, password=new_password, user_name=user_name, birthday=birthday, address=address, phone_number=phone_number) except: return render_template('search1.html', email=email, password=password)
def search1(): if (request.method == 'GET'): try: search = request.args.get('search') email = request.args.get('email') password = request.args.get('password') collect = [] if (control.verify(email, password)): try: collect = control.getuser(email)['collect'] except: pass return render_template('result_list1.html', search_phrase=search, email=email, password=password, Collect=collect) except: return render_template('search1.html')
def change_person_info(): if (request.method == 'GET'): try: email = request.args.get('email') password = request.args.get('password') address = request.args.get('address') phone_number = request.args.get('phone_number') user_name = request.args.get('user_name') birthday = request.args.get('birthday') user = dict() if (control.verify(email, password)): control.putuser(email, user_name, birthday, password, phone_number, address) return render_template('person_information_page.html', email=email, password=password, user_name=user_name, birthday=birthday, address=address, phone_number=phone_number) except: return render_template('search1.html')
def edit_house(): email = request.values.get('email') password = request.values.get('password') house_id = int(request.values.get('house_id')) print(email, password, 'house_id12=', house_id) if request.method == 'POST': title = request.values.get('title') address = request.values.get('address') latitude = request.values.get('latitude') longitude = request.values.get('longitude') print('latitude=', latitude) print('longitude=', longitude) price = request.values.get('price') guest = request.values.get('guest') bedroom = request.values.get('bedroom') bed = request.values.get('bed') bath = request.values.get('bath') content = request.values.get('content') policy = request.values.get('policy') options1 = request.values.getlist("options1") options2 = request.values.getlist("options2") # picname = None # try: # picname = [request.files['pic']] # except: # pass # this part by fanxiaoyu # this is by fanxiaoyu picname = [] try: pic = request.files.getlist('pic') picname.append(pic) print('上传文件', picname) except: pass control.empty_folder(str(house_id)) policy = "\n".join(policy.split('\r\n')) control.edit_house_info(email, password, house_id, picname, title, guest, bedroom, bed, bath, price, options1, options2, policy, content, address, latitude, longitude) Post = [] Deleted = [] Collect = [] if (control.verify(email, password)): user = control.getuser(email) try: control.putuser(email, user['user_name'], user['birthday'], password, user['phone number'], user['address'], user['property'], user['deleted_post']) except: control.putuser(email, user['user_name'], user['birthday'], password, user['phone number'], user['address'], user['property']) for i in user['property']: Post.append(house.readhouse(i)) # print(Post) try: for i in user['deleted_post']: Deleted.append(house.read_deleted_house(i)) except: pass try: visible_collect = set(user['collect']).difference( set(os.listdir('data/house_del'))) for i in visible_collect: Collect.append(house.readhouse(i)) except: pass birthday = '-'.join(user['birthday'].split('/')[::-1]) return render_template('person_information_page.html', email=email, password=password, user_name=user['user_name'], birthday=birthday, address=user['address'], phone_number=user['phone number'], Post=Post, Deleted=Deleted, Collect=Collect) else: return render_template('person_information_page.html')