Beispiel #1
0
def checkin_pet():
    user_id = current_user.get_id()
    pet_title = request.form['pet-title']
    species = request.form['species']
    location = request.form['location']
    tel = request.form['tel']
    supplement = request.form['supplement']
    pet_photo = request.files['petphoto']
    if pet_photo and allowed_file(pet_photo.filename):
        filename = secure_filename(pet_photo.filename)
        renew_filename = process_filename(user_id, filename)
        photo_url = save_image_return_url(renew_filename, pet_photo)
    petkey = save_data(pet_title,species,location,tel,supplement, photo_url, user_id)

    kv = sae.kvdb.Client()
    user_dic = kv.get(str(user_id))
    user_dic['pet'].append(str(petkey))
    kv.set(str(user_id),user_dic)
    kv.disconnect_all()
    return redirect(url_for("show_post", pet_id=petkey, username=user_id))
Beispiel #2
0
def checkin_pet():
    user_id = current_user.get_id()  #user_id is email
    pet_title = request.form['pet-title']
    age = request.form['age']
    gender = request.form['gender']
    sterilization = request.form['sterilization'] 
    immunization = request.form['immunization'] 
    health = request.form['health']
    species = request.form['species']
    location = request.form['location']
    tel = request.form['tel']
    supplement = request.form['supplement']
    pet_photo = request.files.getlist('petphoto') # upload multiple files

    photo_urls = get_photourls(user_id, pet_photo)

    petkey = save_data(pet_title, age, gender, sterilization, immunization, \
        health, species,location,tel,supplement, photo_urls, user_id)

    add_petkey_to_userId( user_id, petkey)
    return redirect(url_for("show_post", pet_id=petkey, username=user_id))