def usercenter(): user_id = current_user.get_id() kv = sae.kvdb.Client() keys = kv.get(str(user_id))['pet'] if not keys: message = "你还没有发布过小动物信息哦,快去发布吧~" else: message = "您发布过的小动物:" pet_dict = kv.get_multi(keys).items() pet_dict = change_sequence(pet_dict) return render_template('user_page.html', message=message, pet_dict=pet_dict, username=user_id)
def show(pet_species): user_id = current_user.get_id() kv = sae.kvdb.Client() if pet_species == 'dog': prefix = 's:d' elif pet_species == 'cat': prefix = 's:c' elif pet_species == 'all': prefix = 's:' else: prefix = 's:e' keys = [key for key, value in kv.get_by_prefix(prefix)] pet_dict = kv.get_multi(keys).items() pet_dict = change_sequence(pet_dict) return render_template('show_dict.html', pet_dict=pet_dict, username=user_id)
def search_result(): query = request.form['query'] query = str(query) if not query: return render_template("nullpage.html") kv = sae.kvdb.Client() data = kv.get_by_prefix('s') results = [] for key, value in data: pet_item = [value['pet_title'], value['species'], value['location'],\ value['supplement'], value['date'], value['username']] for item in pet_item: if query in str(item): results.append(key) if results: print type(kv.get_multi(results).items()) pet_dict = kv.get_multi(results).items() pet_dict = change_sequence(pet_dict) return render_template('show_dict.html', pet_dict=pet_dict) else: return render_template("nullpage.html")
def usercenter(): user_id = current_user.get_id() message, pet_dict = get_message_petdict_from_userid(user_id) pet_dict = change_sequence(pet_dict) return render_template('user_page.html', message=message, pet_dict=pet_dict, username=user_id)
def show(pet_species): user_id = current_user.get_id() pet_dict = get_petdict_according_petspecies(pet_species) pet_dict = change_sequence(pet_dict) return render_template('show_dict.html', pet_dict=pet_dict, username=user_id)