-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dnikolay-ebc
committed
Jul 14, 2022
1 parent
a556bdd
commit a84053a
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,29 @@ | ||
import requests | ||
|
||
from django.shortcuts import render | ||
|
||
|
||
def home(request): | ||
context = {} | ||
return render(request, "home.html", context) | ||
|
||
|
||
def __generic_error_handler(request, status_code: int): | ||
context = {"error_code": status_code} | ||
return render(request, "error.html", context) | ||
|
||
|
||
def custom_page_not_found_view(request, *args, **kwargs): | ||
return __generic_error_handler(request, status_code=404) | ||
|
||
|
||
def custom_error_view(request, *args, **kwargs): | ||
return __generic_error_handler(request, status_code=500) | ||
|
||
|
||
def custom_permission_denied_view(request, *args, **kwargs): | ||
return __generic_error_handler(request, status_code=403) | ||
|
||
|
||
def custom_bad_request_view(request, *args, **kwargs): | ||
return __generic_error_handler(request, status_code=400) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% extends '_base.html' %} | ||
|
||
{% block title %}Error {{ error_code }}{% endblock %} | ||
|
||
{% block content %} | ||
<div class="d-flex"> | ||
{# TODO: use custom error layout, but hey cats :D #} | ||
<img src="https://http.cat/{{ error_code }}.jpg" class="rounded mx-auto d-block" alt="..."> | ||
</div> | ||
{% endblock %} |