Skip to content

Commit

Permalink
no more debug, real 404 and 500 pages
Browse files Browse the repository at this point in the history
  • Loading branch information
nwinans committed Apr 27, 2020
1 parent a01ca46 commit aa0dcdc
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ env
db.sqlite3
listing_images/
textbook_images/
staticfiles/
*.png

#image upload locations
Expand Down
63 changes: 63 additions & 0 deletions templates/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{% extends 'textbook_exchange/base.html' %}
{% load static %}

{% block content %}
<style>
body {
background-image: url("{% static 'textbook_exchange/images/Rotunda.jpg' %}");
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
background-size:cover;
}
.navbar, #footer {
background-color: rgba(32, 44, 80,.5);
}
a:not(#button) {
background-color: transparent !important;
}
#page-container {
background-color: rgba(0,0,0, 0.65) !important;
}
.col-md-8 {
color: white;
}
@media screen and (max-width: 991px) and (min-width: 768px) {
.welcome {
font-size: 37px;
}
.desc {
font-size: 21px;
width: 90% !important;
}
.col-md-8 {
padding-left: 0 !important;
}
}
@media only screen and (max-width: 991px){
.padding-top50 {
padding: 10px !important;
}
}
@media only screen and (max-width: 767px){
body {
background-position: top !important;
}
.padding-top30, .desc {
text-align: center !important;
margin: auto !important;
}
.desc {
width: 100% !important;
}

}
</style>

<div class="row padding-top30">
<div class="col-md-8">
<h1 class="mb-5 welcome">Whoops!</h1>
<h4 class="p-font desc" style="width: 80%">This resource does not exist! Try <a href="javascript:history.back()">navigating back</a> to the previous page or <a href="{% url 'exchange:landing' %}">go back home</a></h4>
</div>
</div>
{% endblock %}
63 changes: 63 additions & 0 deletions templates/500.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{% extends 'textbook_exchange/base.html' %}
{% load static %}

{% block content %}
<style>
body {
background-image: url("{% static 'textbook_exchange/images/Rotunda.jpg' %}");
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
background-size:cover;
}
.navbar, #footer {
background-color: rgba(32, 44, 80,.5);
}
a:not(#button) {
background-color: transparent !important;
}
#page-container {
background-color: rgba(0,0,0, 0.65) !important;
}
.col-md-8 {
color: white;
}
@media screen and (max-width: 991px) and (min-width: 768px) {
.welcome {
font-size: 37px;
}
.desc {
font-size: 21px;
width: 90% !important;
}
.col-md-8 {
padding-left: 0 !important;
}
}
@media only screen and (max-width: 991px){
.padding-top50 {
padding: 10px !important;
}
}
@media only screen and (max-width: 767px){
body {
background-position: top !important;
}
.padding-top30, .desc {
text-align: center !important;
margin: auto !important;
}
.desc {
width: 100% !important;
}

}
</style>

<div class="row padding-top30">
<div class="col-md-8">
<h1 class="mb-5 welcome">Whoops!</h1>
<h4 class="p-font desc" style="width: 80%">There was an internal server error... Please try again later.</h4>
</div>
</div>
{% endblock %}
10 changes: 0 additions & 10 deletions textbook_exchange/templates/textbook_exchange/404_error.html

This file was deleted.

1 change: 0 additions & 1 deletion textbook_exchange/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
urlpatterns = [
path('', views.landing, name='landing'),
path('faq', views.faq, name='faq'),
path('404_error', views.error_404, name='404_error'),
path('login/', views.login_redirect_before, name="login"),
path('login/redirect/', views.login_redirect_after, name="login_redirect"),
path('sell/', views.sell_books, name='sellbooks'),
Expand Down
5 changes: 0 additions & 5 deletions textbook_exchange/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ def faq(request):
context['title'] ='FAQ'
return render(request, 'textbook_exchange/faq.html', context=context)

def error_404(request):
context = {}
context['title'] ='404 Error: Not Found'
return render(request, 'textbook_exchange/404_error.html')

def login_redirect_before(request):
response = HttpResponseRedirect(reverse('google_login'))
response.set_cookie("redirect_address", request.GET.get('login_redirect_target'))
Expand Down
11 changes: 5 additions & 6 deletions textexc/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
SECRET_KEY = 'bzlj_!^o$51mc-3zb^xg87$0u=ygwuo*(+(57fk1^=0w4zs#j-'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = False

# OAUTH 2 ID and Secret: keep this private
CLIENT_ID = '926789688582-6hj6sj5kcquk9o6hc4proqh9p266v6mj.apps.googleusercontent.com'
CLIENT_SECRET = 'VKJy7twp3ZHgG8wUoGFxv3yx'

ALLOWED_HOSTS = []
ALLOWED_HOSTS = ["*"]

# Application definition

Expand Down Expand Up @@ -63,7 +63,7 @@
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
Expand Down Expand Up @@ -120,7 +120,6 @@
'allauth.account.auth_backends.AuthenticationBackend',
)


# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/

Expand Down Expand Up @@ -184,6 +183,6 @@
TWILIO_API_SID='SK9c7fe6717da5318751e61ca951dd784e'
TWILIO_API_SECRET='YP8YzQNQw8K1VM9bgiFlezje0MckJenx'

#STATIC_ROOT = os.path.join(BASE_DIR, 'static')
#STATICFILES_DIRS = (os.path.join(os.path.dirname(__file__),'static'),)
STATIC_ROOT = os.path.join(BASE_DIR, 'textbook_exchange/static/textbook_exchange/')
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'textbook_exchange/static/textbook_exchange/'),)
django_heroku.settings(locals())

0 comments on commit aa0dcdc

Please sign in to comment.