Skip to content
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
2 changes: 2 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ async def unauthorized_redirect_handler(request: Request, exc: Exception):


if __name__ == "__main__":
print("Save")
print ("This is ")
uvicorn.run("app.main:app", host=get_settings().app_host, port=get_settings().app_port, reload=get_settings().env.lower()!="production")
16 changes: 16 additions & 0 deletions app/routers/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,20 @@ async def app(
context={
"user": user
}
)

@app_router.get("/todos", response_class=HTMLResponse)
async def get_todos(
request: Request,
user: AuthDep, #get currently logged in user
db:SessionDep
):
todos = db.exec(select(Todo).where(Todo).user_id == user.id).all()
return templates.TemplateResponse(
request=request,
name="todos.html",
context={
"user":user,
"todos":todos
}
)
6 changes: 5 additions & 1 deletion app/templates/authenticated-base.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,13 @@ <h4 class="text-white mb-4 text-center py-4">Project Template</h4>
</a>
</li>
<li class="nav-item">
<a class="nav-link d-flex align-items-center {{ 'active' if request.path == '/users' }}" href="/users">
<!-- <a class="nav-link d-flex align-items-center {{ 'active' if request.path == '/users' }}" href="/users">
<span class="material-icons me-2">people</span>
Users
</a> -->
<a class="nav-link d-flex align-items-center {{ 'active' if request.path == '/todos' }}" href="/todos">
<span class="material-icons me-2">checklist</span>
Todos
</a>
</li>

Expand Down
32 changes: 32 additions & 0 deletions app/templates/todos.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{% extends "authenticated-base.html" %}

{% block subpage_content %}

<h3 class=""mb-4">My Todos</h3>

{% if todos %}

<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>Todo task</th>
</tr>
</thead>
<tbody>

{% for todo in todos %}
<tr>
<td>{{todo.id}}</td>
<td>{{todo.title}}</td>
</tr>
{% end for %}
</tbody>
</table>

{% else %}
<p>No Todos found.</p>

{% endif %}

{% endblock %}