Esempio n. 1
0
 def create(self, person):
     create_person = Person()
     create_person.name = person['name']
     create_person.state_short = person['state_short']
     create_person.city = person['city']
     self.database.create(create_person)
     self.rewrite_list()
Esempio n. 2
0
def submit_person():
	session = Session()

	person = None

	if 'id' in request.form:
		person = session.query(Person).filter(Person.id == request.form['id']).first()
	else:
		person = Person()

	person.name = request.form['name']
	if 'location' in request.form:
		person.location = request.form['location']

	if 'image_id' in request.form and request.form['image_id']:
		person.image_id = request.form['image_id']
	elif('cover' in request.files) and request.files['cover'] and request.files['cover'].filename:
		upload = request.files['cover']
		file = File()

		file.name = secure_filename(upload.filename)
		file.type = 'image'
		file.mime = guess_type(file.name)[0]
		file.data = upload.read()

		person.image = file

	session.add(person)

	session.commit()

	return redirect(url_for('index'))
Esempio n. 3
0
    def create_test_data(self):

        create_person = Person()
        create_person.name = "testovací jméno"
        create_person.state_short = "testovací stát"
        create_person.city = "testovací město"
        self.database.create(create_person)
        self.rewrite_list()