def donate(scholarship_id=None): scholarship = Scholarship.get_scholarship(scholarship_id) if not scholarship: flash( 'Error finding donation page. Please make sure the scholarship ID is correct.' ) return redirect(url_for('donor.browse')) form = DonationForm(request.form, obj=donor) if form.validate_on_submit(): amount = form.amount.data or form.other_amount.data donation = Donation( donor_id=Donor.get_donor(user_id=current_user.id).donor_id, scholarship_id=scholarship_id, message=form.message.data, amount=amount, cleared=False) db.session.add(donation) db.session.commit() form.populate_obj(donor) return render_template( 'donor/donate.html', scholarship=scholarship, donation=donation, key=current_app.config['STRIPE_CREDENTIALS']['publishable_key'], form=form) return render_template('donor/donate.html', form=form, scholarship=scholarship)
def profile(user_id=None, donor_id=None): if donor_id: donor = Donor.get_donor(donor_id=donor_id) if donor: return render_template('donor/profile.html', donor=donor) flash("The donor profile you selected is unavailable. \ We've redirected you to your own profile.".format(donor_id)) donor = Donor.query.filter_by(user_id=current_user.id).first() or None return render_template('donor/profile.html', donor=donor)
def create(): form = CreateScholarshipForm(request.form) if form.validate_on_submit(): new_scholarship = Scholarship( name=form.name.data, category=form.category.data, affiliation=form.affiliation.data, slug=form.slug.data, grade_9=form.grade_9.data, grade_10=form.grade_9.data, grade_11=form.grade_9.data, grade_12=form.grade_9.data, amount_target=form.amount_target.data, description=form.description.data, creator_id=Donor.get_donor(user_id=current_user.id).donor_id) db.session.add(new_scholarship) db.session.commit() flash('Your scholarship was successfully created!') return redirect(url_for('home.index')) return render_template('donor/create.html', form=form)