def property(): print('propTest') myform = PropertyForm() print('propTest1') if request.method == 'POST': print("method is post") if myform.validate_on_submit(): #Add data from form print('This is the true test') propTitle = myform.propTitle.data description = myform.description.data roomNum = myform.roomNum.data bathroomNum = myform.bathroomNum.data price = myform.price.data propType = myform.propType.data location = myform.location.data image = myform.file.data filename = secure_filename(image.filename) image.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) newProp = Property(propTitle, description, roomNum, bathroomNum, price, propType, location, filename) db.session.add(newProp) db.session.commit() flash('The property was added successfully!') return redirect(url_for('home')) else: flash_errors(myform) return render_template('property.html', form=myform)
def add_property(): form = PropertyForm() if request.method == 'POST': if form.validate_on_submit(): try: title = form.title.data bedroom_count = int(form.bathroom_count.data) bathroom_count = int(form.bathroom_count.data) location = form.location.data price = float(form.price.data) type = form.type.data description = form.description.data photo = form.photo.data photo_path = secure_filename(photo.filename) photo.save( os.path.join(app.config['UPLOAD_FOLDER'], photo_path)) prop = Property(title, bedroom_count, bathroom_count, location, price, type, description, photo_path) db.session.add(prop) db.session.commit() flash('Property saved successfully', 'success') return redirect(url_for('show_properties')) except Exception as e: print(e) flash('Something went wrong', 'danger') else: flash_errors(form) return render_template('add_property.html', form=form)
def new_property(): form = PropertyForm() if form.validate_on_submit(): description = form.content.data rent = form.rent.data if rent < 20001: rent_category = '_0_to_20' elif rent < 40001: rent_category = '_20_to_40' elif rent < 60001: rent_category = '_40_to_60' else: rent_category = 'above_60' location = form.location.data owner_id = current_user._get_current_object().id new_property = Property(description=description, rent=rent, rent_category=rent_category, location=location, owner_id=owner_id) new_property.save() return redirect(url_for('new_property')) return render_template('create_property.html', form=form)
def prop(): form = PropertyForm() if request.method == "POST" and form.validate_on_submit(): title = form.title.data description = form.description.data rooms = form.rooms.data bathrooms = form.bathrooms.data price = form.price.data ptype = form.ptype.data location = form.location.data photo = request.files['photo'] if photo and allowed_file(photo.filename): filename = secure_filename(photo.filename) prop = Property(title, description, rooms, bathrooms, price, ptype, location, filename) db.session.add(prop) db.session.commit() photo.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) flash('Property added successfully', 'success') return redirect('/properties') else: flash("Photo must be either png or jpg.") else: flash_errors(form) return render_template("add_property.html", form=form)
def property(): myform = PropertyForm() if request.method == 'POST' and myform.validate_on_submit(): property_title = myform.property_title.data description = myform.description.data rooms = myform.rooms.data bathrooms = myform.bathrooms.data price = myform.price.data property_type = myform.property_type.data location = myform.location.data #photo=myform.photo.data photo = request.files['photo'] filename = secure_filename(photo.filename) photo.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) propt = NewProperty(request.form['property_title'], request.form['description'], request.form['rooms'], request.form['bathrooms'], request.form['price'], request.form['property_type'], request.form['location'], filename) db.session.add(propt) db.session.commit() flash('Property successfully added', 'success') return redirect(url_for('properties')) return render_template('property.html', form=myform)
def property(): """Render the website's property page.""" form = PropertyForm() if request.method == 'POST' and form.validate_on_submit(): title = form.title.data desc = form.description.data nobed = form.nobed.data nobath = form.nobed.data location = form.location.data price = form.price.data property_type = form.property_type.data photo = form.photo.data filename = secure_filename(photo.filename) photo.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) prop = PropertyProfile(title, desc, nobed, nobath, location, price, property_type, filename) db.session.add(prop) db.session.commit() flash('Property successfully added.', 'success') return redirect(url_for('properties')) else: flash_errors(form) return render_template('property.html', form=form)
def newproperty(): form = PropertyForm() if request.method == 'POST' and form.validate_on_submit(): title = form.title.data bedroom = form.bedroom.data bathroom = form.bathroom.data location = form.location.data price = form.price.data type = form.type.data description = form.description.data img = form.photo.data img_filename = secure_filename(img.filename) img.save(os.path.join(app.config['UPLOAD_FOLDER'], img_filename)) add_property = Property(title, bedroom, bathroom, location, price, type, description, img_filename) db.session.add(add_property) db.session.commit() flash('New property added!', 'success') return redirect(url_for('properties')) return render_template('property.html', form=form)
def property(): form=PropertyForm() if request.method=='POST' and form.validate_on_submit(): title=form.title.data bedroom_num=form.bedroom_num.data bathroom_num=form.bathroom_num.data location=form.location.data price=form.price.data types=form.types.data description=form.description.data photo=request.files['photo'] filename=secure_filename(photo.filename) photo.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) propert= UserProp(title, bedroom_num, bathroom_num, location,price,types,description,filename) db.session.add(propert) db.session.commit() flash('Property Added Successfully', 'success') return redirect(url_for('properties')) return render_template('property.html', form=form)
def property(): form = PropertyForm() upload_folder = app.config['UPLOAD_FOLDER'] if request.method == "POST" and form.validate_on_submit(): title = form.title.data description = form.description.data number_of_rooms = form.number_of_bedrooms.data number_of_bathrooms = form.number_of_bathrooms.data price = form.price.data property_type = form.property_type.data location = form.location.data photo = form.photo.data filename = secure_filename(photo.filename) # Create new property new_property = Property(title, description, number_of_rooms, number_of_bathrooms, price, property_type, location, filename) # Add to db db.session.add(new_property) db.session.commit() photo.save(os.path.join(upload_folder, filename)) flash("Property was added successfully", 'success') return redirect(url_for('properties')) flash_errors(form) return render_template('new_property.html', form=form)
def add_property(): form = PropertyForm() if request.method == 'POST' and form.validate_on_submit(): # Get form data title = form.property_title.data description = form.description.data no_bedrooms = form.no_bedrooms.data no_bathrooms = form.no_bathrooms.data price = form.price.data location = form.location.data property_type = form.property_type.data photo = form.property_photo.data # Save the photo photo_path = secure_filename(photo.filename) photo.save(os.path.join(app.config['UPLOAD_FOLDER'], photo_path)) # Store the property to the database property_model = PropertyModel(title, no_bedrooms, no_bathrooms, description, price, location, property_type, photo_path) db.session.add(property_model) db.session.commit() # Redirect to properties page flash('Saved Property', 'success') return redirect(url_for('get_properties')) else: flash_errors(form) return render_template('property.html', form=form)
def add_property(): form = PropertyForm() if (request.method == 'POST'): if form.validate_on_submit() == True: title = request.form["title"] propertyDescription = request.form["propertyDescription"] Bedrooms = request.form["bedrooms"] Bathrooms = request.form["bathrooms"] price = request.form["price"] propertytype = request.form["propertytype"] location = request.form["location"] filename = uploadPhoto(form.photo.data) prop = Properties(title, propertyDescription, Bedrooms, Bathrooms, price, propertytype, location, filename) db.session.add(prop) db.session.commit() flash('Property added') else: flash('Property not Added') return redirect(url_for("properties")) return render_template("add_property.html", form=form)
def property(): form = PropertyForm() if form.validate_on_submit(): photo = form.photo.data filename = secure_filename(photo.filename) photo.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) property = Property(form.name.data, form.nobed.data, form.nobath.data, form.location.data, form.price.data, form.type.data, form.description.data, filename) db.session.add(property) db.session.commit() flash('Property Successfully Added', 'success') return redirect(url_for("properties")) return render_template('property.html', form=form)
def property(): form = PropertyForm() if request.method == 'POST' and form.validate_on_submit(): title = request.form['title'] desc = request.form['desc'] rooms = int(request.form['rooms']) bath = int(request.form['bath']) price = float(request.form['price']) type = request.form['type'] location = request.form['location'] photo = request.files['photo'] filename = secure_filename(photo.filename) photo.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) property = Property(title, rooms, bath, location, price, type, desc, filename) db.session.add(property) db.session.commit() flash('Property information successfully added', 'success') return redirect(url_for('properties')) return render_template('property.html', form=form)
def property(): form = PropertyForm() if request.method == "POST" and form.validate_on_submit(): title = form.title.data desc = form.desc.data numOfBed = form.numOfBed.data numOfBath = form.numOfBath.data pric = form.pric.data proptype = form.proptype.data location = form.location.data pic = form.pic.data filename = secure_filename(pic.filename) pic.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) userproperty = UserProperty(title, desc, numOfBed, numOfBath, pric, proptype, location, filename) db.session.add(userproperty) db.session.commit() flash("Property successfully created", category="success") return redirect(url_for('properties')) return render_template("property.html", form=form)
def property(): form = PropertyForm() if request.method == "POST" and form.validate_on_submit(): photo = form.photo.data filename = secure_filename(photo.filename) photo.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) user = UserProperties(title=request.form['title'], description=request.form['description'], bedrooms=request.form['bedrooms'], bathrooms=request.form['bathrooms'], price=request.form['price'], types=request.form['types'], location=request.form['location'], photo=filename) db.session.add(user) db.session.commit() flash('Property Saved', 'success') return redirect(url_for('properties')) return render_template('property.html', form=form)
def property(): form = PropertyForm() # Validate profile info on submit if request.method == 'POST': if form.validate_on_submit(): # Save image to upload folder photo = request.files['photo'] filename = secure_filename(photo.filename) photo.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) # Extract data for the profile data property_title = form.property_title.data description = form.description.data bedrooms = form.bedrooms.data bathrooms = form.bathrooms.data price = form.price.data location = form.location.data property_type = form.property_type.data # Save data to database property_model = PropertyModel(title=property_title, description=description, bedrooms=bedrooms, bathrooms=bathrooms, price=price, location=location, property_type=property_type, photo=photo) db.session.add(property_model) db.session.commit() # Redirect to properties page flash('Property successfully saved') return redirect(url_for('get_properties', properties=properties)) flash_errors(form) return render_template('property.html', form=form)
def add_property(): """Form for adding properties""" # Initialize the property form form = PropertyForm() if request.method == 'POST': if form.validate_on_submit(): property_title = form.property_title.data description = form.description.data no_bedrooms = form.no_bedrooms.data no_bathrooms = form.no_bathrooms.data price = form.price.data location = form.location.data property_type = form.property_type.data photo = form.photo.data property_photo = secure_filename(photo.filename) path_joined = os.path.join( app.config['UPLOAD_FOLDER'], property_photo) photo.save(path_joined) property_model = PropertyModel( title=property_title, description=description, price=price, location=location, no_bedrooms=no_bedrooms, no_bathrooms=no_bathrooms, property_type=property_type, property_photo=property_photo) db.session.add(property_model) db.session.commit() flash('Saved property', 'success') return redirect(url_for('property_catalogue')) flash_errors(form) return render_template('add_property.html', form=form)
def add_property(): """Form for adding properties""" # Initialize the property form form = PropertyForm() if request.method == 'POST': if form.validate_on_submit(): title = form.title.data description = form.description.data num_of_beds = form.num_of_beds.data num_of_baths = form.num_of_baths.data price = form.price.data location = form.location.data propertyType = form.propertyType.data photo = form.photo.data photo_path = secure_filename(photo.filename) path_joined = os.path.join(app.config['UPLOAD_FOLDER'], photo_path) print(path_joined) photo.save(path_joined) property_model = PropertyModel(title=title, description=description, num_of_beds=num_of_beds, num_of_baths=num_of_baths, price=price, location=location, propertyType=propertyType, path_joined=path_joined) db.session.add(property_model) db.session.commit() # Redirect to properties page flash('Property successfully saved', 'success') return redirect(url_for('get_properties')) flash_errors(form) return render_template('property.html', form=form)
def property(): """Form for new property.""" form = PropertyForm() if request.method == 'POST' and form.validate_on_submit(): title = form.title.data bedroomnum = form.bedrooms.data bathroomnum = form.bathrooms.data location = form.location.data price = form.price.data type = form.type.data description = form.description.data photo = form.photo.data filename = secure_filename(photo.filename) photo.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) property = PropertyB(title, bedrooms, bathrooms, location, price, type, desc, filename) db.session.add(property) db.session.commit() flash('Property added successfully', 'success') return redirect(url_for('properties')) return render_template('property.html', form=form)
def property(): form= PropertyForm() if request.method == 'POST': if form.validate_on_submit(): title=form.title.data num_bedrooms=form.num_bedrooms.data num_bathrooms=form.num_bathrooms.data location=form.location.data price=form.price.data propertytype=form.propertytype.data description=form.description.data photo=form.photo.data filename=secure_filename(photo.filename) photo.save(os.path.join(app.config['UPLOAD_FOLDER'],filename)) property_list=PropertyList(title,num_bedrooms,num_bathrooms,location, price,propertytype,description,filename) db.session.add(property_list) db.session.commit() flash("Property was successfully added", "success") return redirect(url_for('properties')) flash_errors(form) return render_template('property.html',form=form)
def property(): pf = PropertyForm() if request.method == 'POST': if pf.validate_on_submit(): title = pf.title.data num_bedrooms = pf.num_bedrooms.data num_bathrooms = pf.num_bathrooms.data location = pf.location.data price = pf.price.data property_type = pf.property_type.data description = pf.description.data photo = photo_save(pf.photo.data) property_info = Property(title, num_bedrooms, num_bathrooms, location, price, property_type, description, photo) db.session.add(property_info) db.session.commit() flash('Property Added', 'success') return redirect(url_for('properties')) else: flash_errors(pf) return render_template('propertyADD.html', form=pf)
def property(): form = PropertyForm() if request.method == "POST" and form.validate_on_submit(): title = form.title.data description = form.description.data rooms = form.rooms.data bathrooms = form.bathrooms.data price = form.price.data proptype = form.proptype.data location = form.location.data photo = form.photo.data filename = secure_filename(photo.filename) photo.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) propertydisplay = Property(title, description, rooms, bathrooms, price, proptype, location, filename) db.session.add(propertydisplay) db.session.commit() flash("Property successfully created", category="success") return redirect(url_for('properties')) return render_template("propertyform.html", form=form)
def property(): myform = PropertyForm() if request.method == 'POST': if myform.validate_on_submit(): title = myform.title.data bedrooms = myform.bedrooms.data bathrooms = myform.bathrooms.data location = myform.location.data price = myform.price.data prop_type = myform.prop_type.data description = myform.description.data image = myform.imageFile.data filename = secure_filename(image.filename) image.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) property = UserProperty(title, bedrooms, bathrooms, location, price, prop_type, description, filename) db.session.add(property) db.session.commit() flash('You have successfully uploaded a property') return redirect(url_for('properties')) return render_template('property.html', form=myform)
def property(): form = PropertyForm(request.form) if request.method == 'POST' and form.validate_on_submit(): return 'We confirm your registration!' return render_template('property.html', form=form)