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

Code to add the delivery_date column #128

Open
wants to merge 1 commit into
base: main
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
10 changes: 7 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Order(Base):
product_quantity = Column('Product Quantity', Integer)
order_date = Column('Order Date', DateTime)
shipping_date = Column('Shipping Date', DateTime)

delivery_date = Column('Delivery Date', DateTime)
# define routes
# route to display orders
@app.route('/')
Expand Down Expand Up @@ -85,7 +85,8 @@ def add_order():
product_quantity = request.form.get('product_quantity')
order_date = request.form.get('order_date')
shipping_date = request.form.get('shipping_date')

delivery_date = request.form['delivery_date']

# Create a session to interact with the database
session = Session()

Expand All @@ -99,14 +100,17 @@ def add_order():
product_quantity=product_quantity,
order_date=order_date,
shipping_date=shipping_date
delivery_date=delivery_date
)

# Add the new order to the session and commit to the database
session.add(new_order)
session.commit()
sdelivery_date = request.form['delivery_date']delivery_date = request.form['delivery_date']essiE37: No write since last change
E162: No write since last change for bufferon.commit()

return redirect(url_for('display_orders'))

# run the app
if __name__ == '__main__':
A
app.run(host='0.0.0.0', port=5000, debug=True)
4 changes: 4 additions & 0 deletions templates/orders.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ <h2 class="tab-title">Order List</h2>
<th>Product Quantity</th>
<th>Order Date</th>
<th>Shipping Date</th>
<th>Delivery Date</th>
</tr>
</thead>
<tbody>
Expand All @@ -40,6 +41,7 @@ <h2 class="tab-title">Order List</h2>
<td>{{ order.product_quantity }}</td>
<td>{{ order.order_date }}</td>
<td>{{ order.shipping_date }}</td>
<td>{{ order.delivery_date }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down Expand Up @@ -73,6 +75,8 @@ <h2 class="tab-title">Add New Order</h2>
<input type="text" id="order_date" name="order_date" required><br>
<label for="shipping_date">Shipping Date:</label>
<input type="text" id="shipping_date" name="shipping_date" required><br>
<label for="delivery_date">Delivery Date:</label>
<input type="date" id="delivery_date" name="delivery_date"><br><br>
<input type="submit" value="Add Order">
</form>
</div>
Expand Down