8000 fix: fixed issues according to comments · PythonFreeCourse/calendar@5fd6929 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5fd6929

Browse files
committed
fix: fixed issues according to comments
1 parent cac2432 commit 5fd6929

File tree

5 files changed

+4
-14
lines changed

5 files changed

+4
-14
lines changed

app/internal/daily_quotes.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
from datetime import date
2-
from os.path import join, relpath
32
from typing import Dict, List, Optional
43

54
from sqlalchemy.orm import Session
65
from sqlalchemy.sql.expression import func
76

87
from app.database.models import Quote, UserQuotes
9-
from app.dependencies import MEDIA_PATH
108

11-
EMPTY_HEART_PATH = relpath(join(MEDIA_PATH, "empty_heart.png"), "app")
12-
FULL_HEART_PATH = relpath(join(MEDIA_PATH, "full_heart.png"), "app")
13-
FAVORITES_PATH = join("../..", FULL_HEART_PATH)
149
TOTAL_DAYS = 366
1510

1611

@@ -72,6 +67,6 @@ def is_quote_favorite(
7267
exists = (
7368
session.query(UserQuotes)
7469
.filter(user_id == user_id, UserQuotes.quote_id == quote_of_day.id)
75-
.all()
70+
.scalar()
7671
)
7772
return bool(exists)

app/main.py

-4
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@ async def startup_event():
159159
session.close()
160160

161161

162-
# TODO: I add the quote day to the home page
163-
# until the relevant calendar view will be developed.
164162
@app.get("/", include_in_schema=False)
165163
@logger.catch()
166164
async def home(
@@ -184,8 +182,6 @@ async def home(
184182
"request": request,
185183
"is_connected": is_connected,
186184
"quote": quote_of_day,
187-
"empty_heart": daily_quotes.EMPTY_HEART_PATH,
188-
"full_heart": daily_quotes.FULL_HEART_PATH,
189185
},
190186
)
191187

app/routers/favorite_quotes.py

-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,5 @@ async def favorite_quotes(
5151
{
5252
"request": request,
5353
"quotes": quotes,
54-
"full_heart": daily_quotes.FAVORITES_PATH,
5554
},
5655
)

app/templates/favorite_quotes.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ <h2 id="favorite-quotes">Favorite Quotes</h2>
1111
{% else %}
1212
<span>&nbsp;
1313
{% endif %}
14-
<img src="{{full_heart}}" data-heart="on" data-qid="{{quote.id}}" class="heart favorites">
14+
<img src="{{ url_for('media', path='/full_heart.png') }}" data-heart="on" data-qid="{{quote.id}}" class="heart favorites">
1515
</span>
1616
</p>
1717
{% endfor %}

app/templates/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ <h2 class="fs-1 fw-bold">
2222
<span >&nbsp;
2323
{% endif %}
2424
{% if quote.is_favorite %}
25-
<img src="{{full_heart}}" data-heart="on" data-qid="{{quote.id}}" class="heart full-heart">
25+
<img src="{{ url_for('media', path='/full_heart.png') }}" data-heart="on" data-qid="{{quote.id}}" class="heart full-heart">
2626
{% else %}
27-
<img src="{{empty_heart}}" data-heart="off" data-qid="{{quote.id}}" class="heart empty-heart">
27+
<img src="{{ url_for('media', path='/empty_heart.png') }}" data-heart="off" data-qid="{{quote.id}}" class="heart empty-heart">
2828
{% endif %}
2929
</span>
3030
</p>

0 commit comments

Comments
 (0)
0