Skip to content

Commit

Permalink
feat: list venues
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes1803 committed Dec 4, 2023
1 parent ddce064 commit 1f24c08
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
9 changes: 9 additions & 0 deletions in_concert/app/app_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,15 @@ def delete_venue(
raise HTTPException(status_code=HTTP_404_NOT_FOUND, detail=str(e))
return {"id": venue_id}

@app.get("/list_venues")
def list_venues(
db_session: Annotated[Any, Depends(db_session_dep)],
request: Request,
):
venues = db_session.query(Venue).all()
html = templates.TemplateResponse("venues.html", {"venues": venues, "request": request})
return html

if override_security_dependencies:

async def dummy_is_authorized_current_user():
Expand Down
2 changes: 1 addition & 1 deletion in_concert/app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ class VenueForm(StarletteForm):
state = StringField("state", validators=[DataRequired(), Length(max=30)])
phone = IntegerField("phone", validators=[DataRequired()])
website = StringField("website", validators=[Length(max=30)])
image_link = StringField("image_link", validators=[Length(max=30)])
image_link = StringField("image_link", validators=[Length(max=300)])
genres = StringField("genres", validators=[Length(max=30)])
2 changes: 1 addition & 1 deletion in_concert/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Venue(Base):
state: Mapped[str] = mapped_column(String(30))
phone: Mapped[int] = mapped_column(Integer())
website: Mapped[str] = mapped_column(String(30), nullable=True)
image_link: Mapped[str] = mapped_column(String(30), nullable=True)
image_link: Mapped[str] = mapped_column(String(), nullable=True)
genres: Mapped[str] = mapped_column(String(30), nullable=True)
manager_id: Mapped[int] = mapped_column(ForeignKey("venue_managers.id"))
manager: Mapped["VenueManager"] = relationship(back_populates="venues")
Expand Down
22 changes: 22 additions & 0 deletions in_concert/app/templates/venues.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% extends "base.html" %} {% block content %}

<div class="container my-5">
<h1>Discover Venues nearby!</h1>
{% for venue in venues %}
<div class="row">
<div class="col">
<p>
<img src="{{ venue.image_link }}" class="img-fluid" alt="venue" />
</p>
</div>
<div class="col-8">
<h2>{{ venue.name }}</h2>
<p>
Location: {{ venue.street }}, {{ venue.zip_code }} {{ venue.city }}, {{
venue.state }}
</p>
</div>
</div>
{% endfor %}
</div>
{% endblock %}

0 comments on commit 1f24c08

Please sign in to comment.