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
6 changes: 3 additions & 3 deletions bakerydemo/locations/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
from django.utils import timezone

from django.conf import settings
from django.core.validators import RegexValidator
Expand Down Expand Up @@ -182,9 +182,9 @@ def operating_hours(self):
hours = self.hours_of_operation.all()
return hours

# Determines if the location is currently open. It is timezone naive
# Determines if the location is currently open.
def is_open(self):
now = datetime.now()
now = timezone.localtime()
current_time = now.time()
current_day = now.strftime("%a").upper()
try:
Expand Down
6 changes: 5 additions & 1 deletion bakerydemo/search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from bakerydemo.blog.models import BlogPage
from bakerydemo.breads.models import BreadPage
from bakerydemo.locations.models import LocationPage
from bakerydemo.recipes.models import RecipePage


def search(request):
Expand All @@ -31,7 +32,10 @@ def search(request):
location_results = LocationPage.objects.live().search(search_query)
location_result_ids = [p.page_ptr.id for p in location_results]

page_ids = blog_page_ids + bread_page_ids + location_result_ids
recipe_results = RecipePage.objects.live().search(search_query)
recipe_page_ids = [p.page_ptr.id for p in recipe_results]

page_ids = blog_page_ids + bread_page_ids + location_result_ids + recipe_page_ids
search_results = Page.objects.live().filter(id__in=page_ids)

query = Query.get(search_query)
Expand Down
65 changes: 65 additions & 0 deletions bakerydemo/static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -2099,3 +2099,68 @@ input[type='radio'] {
max-height: 100vh;
margin-inline: auto;
}

/* ---- 404 Error Page ---- */
.error-page {
padding: 80px 0 120px;
}

.error-page__inner {
max-width: 600px;
}

.error-page__code {
font-family: var(--font--primary);
font-size: 8rem;
line-height: 1;
color: var(--orange);
margin: 0 0 10px;
}

.error-page__title {
font-size: 2.375rem;
line-height: 1.16;
margin: 0 0 20px;
}

.error-page__description {
color: var(--grey);
margin: 0 0 40px;
}

.error-page__actions {
display: flex;
align-items: center;
gap: 30px;
flex-wrap: wrap;
}

.error-page__search-link {
color: var(--dark);
text-decoration: underline;
}

.error-page__search-link:hover {
color: var(--dark-orange);
}

@media (min-width: 768px) {
.error-page {
padding: 140px 0 200px;
}

.error-page__code {
font-size: 12rem;
}

.error-page__title {
font-size: 3.75rem;
line-height: 1.07;
margin-bottom: 30px;
}

.error-page__description {
font-size: var(--font-md);
margin-bottom: 60px;
}
}
19 changes: 16 additions & 3 deletions bakerydemo/templates/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,20 @@
{% block body_class %}template-404{% endblock %}

{% block content %}
<h1>Page not found</h1>

<h2>Sorry, this page could not be found.</h2>
<div class="error-page">
<div class="container">
<div class="error-page__inner">
<p class="error-page__code">404</p>
<h1 class="error-page__title">Page not found</h1>
<p class="error-page__description">
Sorry, the page you were looking for could not be found.
It may have been moved, deleted, or never existed.
</p>
<div class="error-page__actions">
<a href="/" class="btn">Go to homepage</a>
<a href="/search" class="error-page__search-link">or try searching</a>
</div>
</div>
</div>
</div>
{% endblock content %}