Skip to content

Commit cf0fe58

Browse files
committed
Fixes a bug
- rendering `code_view.html` instead of `homepage.html`
2 parents 2c75bf7 + 4c88fb3 commit cf0fe58

File tree

14 files changed

+297
-11
lines changed

14 files changed

+297
-11
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ Contribution are welcome as always. Checkout the existing issues or create issue
2121
- Push your changes to your upstream fork.
2222

2323
- Create a pull request to the `development` branch of the repository.
24+

code_share/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ venv1/*
44
db.sqlite3
55
debug.log
66
static_media/*
7+
.cache/*
8+
../.vscode/

code_share/app_code_share/templates/app_code_share/code_view.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{% if code_share.file_name %}
2121
<h4>File Name: {{code_share.file_name}}</h4>
2222
{%endif%}
23-
23+
2424
<textarea id="code_snippet" name="code_snippet">{{code_share.code}}</textarea><br>
2525
<input id="language" name="language" value="{{code_share.language}}" hidden>
2626
<input id="submit_edit" type="submit" value="edit"><br>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{% load staticfiles %}
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<!-- Simple HttpErrorPages | MIT X11 License | https://github.com/AndiDittrich/HttpErrorPages -->
6+
7+
<meta charset="utf-8" />
8+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
9+
<meta name="viewport" content="width=device-width, initial-scale=1" />
10+
11+
<link rel="stylesheet" href="{% static 'css/error.css' %}">
12+
13+
<title>We've got some trouble | 400 - Bad Request</title>
14+
15+
</head>
16+
17+
<body>
18+
<div class="cover">
19+
<h1>Bad Request <small>Error 400</small></h1>
20+
<p class="lead">The server cannot process the request due to something that is perceived to be a client error.</p>
21+
</div>
22+
23+
</body>
24+
</html>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{% load staticfiles %}
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<!-- Simple HttpErrorPages | MIT X11 License | https://github.com/AndiDittrich/HttpErrorPages -->
6+
7+
<meta charset="utf-8" />
8+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
9+
<meta name="viewport" content="width=device-width, initial-scale=1" />
10+
<link rel="stylesheet" href="{% static 'css/error.css' %}">
11+
12+
<title>We've got some trouble | 403 - Access Denied</title>
13+
14+
</head>
15+
16+
<body>
17+
<div class="cover">
18+
<h1>Access Denied <small>Error 403</small></h1>
19+
<p class="lead">The requested resource requires an authentication.</p>
20+
</div>
21+
22+
</body>
23+
</html>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{% load staticfiles %}
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<!-- Simple HttpErrorPages | MIT X11 License | https://github.com/AndiDittrich/HttpErrorPages -->
6+
7+
<meta charset="utf-8" />
8+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
9+
<meta name="viewport" content="width=device-width, initial-scale=1" />
10+
11+
<title>We've got some trouble | 404 - Resource not found</title>
12+
13+
<link rel="stylesheet" href="{% static 'css/error.css' %}">
14+
15+
</head>
16+
17+
<body>
18+
<div class="cover">
19+
<h1>Resource not found <small>Error 404</small></h1>
20+
<p class="lead">The requested resource could not be found but may be available again in the future.</p>
21+
</div>
22+
23+
</body>
24+
</html>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{% load staticfiles %}
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<!-- Simple HttpErrorPages | MIT X11 License | https://github.com/AndiDittrich/HttpErrorPages -->
6+
7+
<meta charset="utf-8" />
8+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
9+
<meta name="viewport" content="width=device-width, initial-scale=1" />
10+
11+
<title>We've got some trouble | 500 - Webservice currently unavailable</title>
12+
<link rel="stylesheet" href="{% static 'css/error.css' %}">
13+
14+
</head>
15+
16+
<body>
17+
<div class="cover">
18+
<h1>Webservice currently unavailable <small>Error 500</small></h1>
19+
<p class="lead">An unexpected condition was encountered.<br />
20+
Our service team has been dispatched to bring it back online.</p>
21+
</div>
22+
23+
</body>
24+
</html>

code_share/app_code_share/tests/test_models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from django.utils.crypto import get_random_string
44

55

6-
76
class TestCodeShare(TestCase):
87

98
def setUp(self):

code_share/app_code_share/tests/test_urls.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22
from test_plus.test import TestCase
33
from app_code_share.models import CodeShare
44
from django.utils.crypto import get_random_string
5+
from django.test.client import RequestFactory
56

7+
from code_share.views import (
8+
page_not_found_view,
9+
my_custom_error_view,
10+
permission_denied_view,
11+
bad_request_view,
12+
)
613

714

815
class TestCodeShare(TestCase):
@@ -35,3 +42,30 @@ def test_detail_resolve(self):
3542
resolve('/app/' + self.hash_value + '/').view_name,
3643
'code_share:view_by_hash'
3744
)
45+
46+
47+
class TestMyErrorPages(TestCase):
48+
49+
def test_400_error(self):
50+
factory = RequestFactory()
51+
request = factory.get('/400')
52+
response = bad_request_view(request)
53+
self.assertEqual(response.status_code, 400)
54+
55+
def test_403_error(self):
56+
factory = RequestFactory()
57+
request = factory.get('/403')
58+
response = permission_denied_view(request)
59+
self.assertEqual(response.status_code, 403)
60+
61+
def test_404_error(self):
62+
factory = RequestFactory()
63+
request = factory.get('/404')
64+
response = page_not_found_view(request)
65+
self.assertEqual(response.status_code, 404)
66+
67+
def test_500_error(self):
68+
factory = RequestFactory()
69+
request = factory.get('/500')
70+
response = my_custom_error_view(request)
71+
self.assertEqual(response.status_code, 500)

code_share/app_code_share/tests/test_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ def setUp(self):
2222

2323
def test_post_list(self):
2424
response = self.client.get('/app/' + self.hash_value + '/')
25-
self.assertEqual(response.status_code, 200)
25+
self.assertEqual(response.status_code, 200)

0 commit comments

Comments
 (0)