Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Initialise Flask App
app = Flask(__name__)

# database connection
# database connection
server = 'devops-project-server.database.windows.net'
database = 'orders-db'
username = 'maya'
Expand Down Expand Up @@ -39,6 +39,7 @@
class Order(Base):
__tablename__ = 'orders'
date_uuid = Column('date_uuid', String, primary_key=True)
delivery_date = Column('Delivery Date', DateTime)
user_id = Column('User ID', String, primary_key=True)
card_number = Column('Card Number', String)
store_code = Column('Store Code', String)
Expand Down Expand Up @@ -78,14 +79,16 @@ def display_orders():
@app.route('/add_order', methods=['POST'])
def add_order():
date_uuid = request.form.get('date_uuid')
delivery_date = request.form['delivery_date']
user_id = request.form.get('user_id')
card_number = request.form.get('card_number')
store_code = request.form.get('store_code')
product_code = request.form.get('product_code')
product_quantity = request.form.get('product_quantity')
order_date = request.form.get('order_date')
shipping_date = request.form.get('shipping_date')



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

Expand All @@ -99,6 +102,7 @@ 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
Expand Down
6 changes: 5 additions & 1 deletion templates/orders.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h1>Fictional Company Name</h1>
<button id="btn-orders" class="tab-label">Order List</button>
<button id="btn-add-order" class="tab-label">Add New Order</button>
</div>

<div class="tab-container">
<div class="content" id="order-list-content">
<h2 class="tab-title">Order List</h2>
Expand All @@ -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