Skip to content

Commit

Permalink
Merge pull request #1 from JimacoMS4/mess-with-modal-windows
Browse files Browse the repository at this point in the history
Some cleanup, make form fields required in templates
  • Loading branch information
JimacoMS4 authored Jul 15, 2024
2 parents 85d7a82 + 5f34cac commit 35cbc52
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/fastapi_app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import typing

from datetime import datetime
from sqlmodel import Field, Relationship, SQLModel, create_engine
from sqlmodel import Field, SQLModel, create_engine

POSTGRES_USERNAME = os.environ.get("POSTGRES_USERNAME")
POSTGRES_PASSWORD = os.environ.get("POSTGRES_PASSWORD")
Expand Down
6 changes: 1 addition & 5 deletions src/fastapi_app/seed_data.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import json
import logging
import pathlib

from sqlmodel import Session, SQLModel, select
from sqlmodel import SQLModel

from fastapi_app import models

Expand Down
15 changes: 11 additions & 4 deletions src/templates/create_restaurant.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,25 @@ <h1>Add New Restaurant</h1>
<form method="POST" action="{{ url_for('add_restaurant') }}">
<div class="mb-3">
<label for="restaurant_name" class="form-label">Name</label>
<input type="text" class="form-control" id="restaurant_name" name="restaurant_name">
<input type="text" class="form-control" id="restaurant_name" name="restaurant_name", required>
</div>
<div class="mb-3">
<label for="street_address" class="form-label">Street Address</label>
<input type="text" class="form-control" id="street_address" name="street_address">
<input type="text" class="form-control" id="street_address" name="street_address", required>
</div>
<div class="mb-3">
<label for="description" class="form-label">Description</label>
<input type="text" class="form-control" id="description" name="description">
<input type="text" class="form-control" id="description" name="description", required>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
<button type="cancel" class="btn btn-primary">Cancel</button>
<button type="button" id="cancelButton" class="btn btn-primary">Cancel</button>
</form>

<script>
document.getElementById('cancelButton').addEventListener('click', function() {
window.location.href = "{{ url_for('index') }}";
});
</script>

{% endblock %}

16 changes: 8 additions & 8 deletions src/templates/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h1>{{ restaurant.name }}</h1>
</div>
<div class="row">
<div class="col-md-2 fw-bold">Rating:</div>
<div class="col">{{ restaurant.avg_rating|float }} ({{ restaurant.review_count }} {% if restaurant.review_count == 1 %} review{% else %} reviews{% endif %})</div>
<div class="col">{% if restaurant.review_count %} {{ restaurant.avg_rating|round(3) }} ({{ restaurant.review_count }} {% if restaurant.review_count == 1 %} review{% else %} reviews{% endif %}) {% else %} No ratings yet {% endif %}</div>
</div>

<h4 class="mt-5">Reviews</h4>
Expand Down Expand Up @@ -72,35 +72,35 @@ <h5 class="modal-title" id="addReviewModalLabel">Add Review</h5>

<div class="mb-3">
<label for="user_name" class="form-label fw-bold">Your name</label>
<input type="text" class="form-control" id="user_name" name="user_name">
<input type="text" class="form-control" id="user_name" name="user_name" required>
</div>
<div class="mb-3">
<label class="form-label fw-bold">Rating</label>

<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating1" value="1">
<input class="form-check-input" type="radio" name="rating" id="rating1" value="1" required>
<label class="form-check-label" for="rating1">1</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating2" value="2">
<input class="form-check-input" type="radio" name="rating" id="rating2" value="2" required>
<label class="form-check-label" for="rating2">2</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating3" value="3">
<input class="form-check-input" type="radio" name="rating" id="rating3" value="3" required>
<label class="form-check-label" for="rating3">3</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating4" value="4">
<input class="form-check-input" type="radio" name="rating" id="rating4" value="4" required>
<label class="form-check-label" for="rating3">4</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating5" value="5">
<input class="form-check-input" type="radio" name="rating" id="rating5" value="5" required>
<label class="form-check-label" for="rating3">5</label>
</div>
</div>
<div class="mb-3">
<label for="review_text" class="form-label fw-bold">Comments</label>
<input type="text" class="form-control" id="review_text" name="review_text">
<input type="text" class="form-control" id="review_text" name="review_text" required>
</div>
</div>
<div class="modal-footer">
Expand Down
25 changes: 0 additions & 25 deletions src/templates/star_rating.originalhtml

This file was deleted.

0 comments on commit 35cbc52

Please sign in to comment.