Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update requirements.txt #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from flask import Flask, render_template, request, redirect, url_for, session

from model import Donation
from model import Donation, Donor

app = Flask(__name__)

Expand All @@ -15,7 +15,17 @@ def home():
def all():
donations = Donation.select()
return render_template('donations.jinja2', donations=donations)


@app.route('/new_donation', methods=['POST', 'GET'])
def create():
if request.method == 'POST':
donor = request.form['donor']
amount = int(request.form['amount'])
saved_donor = Donor.select().where(Donor.name == donor).get()
Donation(donor=saved_donor, value=amount).save()
return redirect(url_for('home'))
return render_template('new_donation.jinja2')


if __name__ == "__main__":
port = int(os.environ.get("PORT", 6738))
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ itsdangerous==0.24
Jinja2==2.10
MarkupSafe==1.0
peewee==3.2.2
psycopg2-binary==2.7.4
psycopg2-binary==2.8.1
Werkzeug==0.14.1
4 changes: 4 additions & 0 deletions templates/base.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
<title>Mailroom</title>
</head>
<body>
<nav>
<a id="all" href="{{ url_for('all') }}">Past Donations</a>
<a id="new_donation" href="{{ url_for('create') }}">New Donation</a>
</nav>
<h1>Donations</h1>
<h2>{% block subtitle %} {% endblock subtitle %}</h2>
{% block content %} {% endblock content %}
Expand Down
12 changes: 12 additions & 0 deletions templates/new_donation.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% extends 'base.jinja2' %}

{% block subtitle %}Add a Donation{% endblock subtitle %}

{% block content %}
<form method="POST">
<label for="donor">Donor: </label><input type="text" id="donor" name="donor"><br>
<label for="amount">Amount: </label><input type="number" id="amount" name="amount"><br>
<input type="submit" value="Add donation!">

</form>
{% endblock content %}