Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit 10be54e

Browse files
committed
fix Dockerfile in 0.2-migration
1 parent a51d635 commit 10be54e

File tree

6 files changed

+47
-7
lines changed

6 files changed

+47
-7
lines changed

app/app.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ def view_registration_form():
3636
def register_guest():
3737
name = request.form.get('name')
3838
email = request.form.get('email')
39+
partysize = request.form.get('partysize')
40+
if not partysize or partysize=='':
41+
partysize = 1
3942

40-
guest = Guest(name, email)
43+
guest = Guest(name, email, partysize)
4144
DB.session.add(guest)
4245
DB.session.commit()
4346

4447
return render_template('guest_confirmation.html',
45-
name=name, email=email)
46-
47-
48+
name=name, email=email, partysize=partysize)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""empty message
2+
3+
Revision ID: 32b48058cd02
4+
Revises: 791cd7d80402
5+
Create Date: 2017-05-02 17:00:45.486682
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
12+
# revision identifiers, used by Alembic.
13+
revision = '32b48058cd02'
14+
down_revision = '791cd7d80402'
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
op.add_column('guests', sa.Column('partysize', sa.Integer(), nullable=True))
22+
# ### end Alembic commands ###
23+
24+
25+
def downgrade():
26+
# ### commands auto generated by Alembic - please adjust! ###
27+
op.drop_column('guests', 'partysize')
28+
# ### end Alembic commands ###

app/models.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ class Guest(DB.Model):
77
id = DB.Column(DB.Integer, primary_key=True)
88
name = DB.Column(DB.String(80))
99
email = DB.Column(DB.String(120))
10+
partysize = DB.Column(DB.Integer, default=1)
1011

11-
def __init__(self, name=None, email=None):
12+
def __init__(self, name=None, email=None, partysize=1):
1213
self.name = name
13-
self.email = email
14+
self.email = email
15+
self.partysize = partysize
16+

app/templates/guest_confirmation.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
<h1>You are confirmed!</h1>
88
<p>
99
Name: {{ name }}<br/>
10-
Email: {{ email }}
10+
Email: {{ email }}<br/>
11+
Number of attendees: {{ partysize }}
1112
</p>
1213
<a href="/">View all attendees</a>
1314
{% endblock %}

app/templates/guest_list.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ <h1>Registered Guests</h1>
1010
<tr>
1111
<th>Name</th>
1212
<th>Email</th>
13+
<th>Attendees</th>
1314
</tr>
1415
</thead>
1516
<tbody>
1617
{% for guest in guests %}
1718
<tr>
1819
<td>{{ guest.name }}</td>
1920
<td>{{ guest.email }}</td>
21+
<td>{% if guest.partysize %}{{ guest.partysize }}{% else %}1{% endif %}</td>
2022
</tr>
2123
{% endfor %}
2224
</table>

app/templates/guest_registration.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ <h1>Guest Registration</h1>
1515
<label for="emailfield">Email address</label>
1616
<input type="email" class="form-control" id="emailfield" name="email" aria-describedby="emailHelp" placeholder="Email">
1717
<small id="emailHelp" class="form-text text-muted">Your email address in case we need to contact you.</small>
18+
</div>
19+
<div class="form-group">
20+
<label for="partyfield">Number of attendees</label>
21+
<input type="number" min="0" step="1" class="form-control" id="partyfield" name="partysize" aria-describedby="partyHelp" value="1">
22+
<small id="partyHelp" class="form-text text-muted"> Tell us how many people will be attending.</small>
1823
</div>
1924
<button type="submit" class="btn btn-default">Register</button>
2025
</form>

0 commit comments

Comments
 (0)