def postpatient(): if 'username' in session: name = request.form['name'].encode('utf-8') surname = request.form['surname'].encode('utf-8') secname = request.form['secname'].encode('utf-8') age = str(request.form['age']) diagnosis = request.form['diagnosis'].encode('utf-8') budget = str(request.form['budget']) current_budget = str(request.form['current_budget']) biography = request.form['biography'].encode('utf-8') fund_id = request.form['fund_id'] cover = request.files['cover'] filename = upload_file(cover, 'patients') if filename == -1: return jsonify({ 'info': 'error' }) u = Patient(fund_id, name, surname, secname, age, diagnosis, budget, current_budget, biography, filename) db_session.add(u) db_session.commit() response = { 'info': 'success' } return jsonify(response) else: return redirect("/signin")
def postevent(): if 'username' in session: title = request.form['title'].encode('utf-8') description = request.form['description'].encode('utf-8') date = str(request.form['date']) cover = request.files['cover'] longi = str(request.form['longi']) lati = str(request.form['lati']) city = request.form['city'].encode('utf-8') category = request.form['category'].encode('utf-8') address = request.form['address'].encode('utf-8') f = upload_file(cover, 'events') if f == -1: return jsonify({ 'info': 'error' }) u = Event(title, description, date, f, longi, lati, city, category, address) db_session.add(u) db_session.commit() return jsonify({ 'info': 'success' }) else: return redirect("/signin")
def postfund(): if 'username' in session: name = request.form['name'].encode('utf-8') description = request.form['description'].encode('utf-8') short_description = request.form['short_description'].encode('utf-8') cover = request.files['cover'] phone = str(request.form['phone']) email = str(request.form['email']) budget = str(request.form['budget']) bank_book = str(request.form['bank_book']) f = upload_file(cover, 'funds') if (f == -1): return jsonify({ 'info': 'error' }) u = Fund(name, description, budget, phone, email, bank_book, f, short_description) db_session.add(u) db_session.commit() return jsonify({ 'info': 'success' } ) else: return redirect("/signin")