Skip to content

Commit

Permalink
fixes and custom 404/500 pages (#544)
Browse files Browse the repository at this point in the history
  • Loading branch information
sid22 authored and souravbadami committed Sep 5, 2017
1 parent 0dbe6eb commit 41567b7
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
11 changes: 11 additions & 0 deletions website/templates/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends "base.html" %}
{% block content %}
<div style="font-family: 'Arial';">
<center>
<h1>The Page you are looking for can't be found.</h1>
{% if exception %}
Error message: {{exception}}
{% endif %}
</center>
</div>
{% endblock %}
23 changes: 23 additions & 0 deletions website/templates/500.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% extends "base.html" %}
{% load staticfiles %}
{% block content %}
<div style="font-family: 'Arial';">
<center>
<h1>The Page you are looking is down or doesn't exist.</h1>
{% if exception %}
Error message: {{exception}}
{% endif %}
<br>Refresh the page or report it <a><span class="errors">here</span></a>.
</center>
</div>
<script type="text/javascript">
$(document).ready(function () {
$(document).on('click', '.errors', function () {
var url = window.location.href;
var bugheist = 'https://www.bugheist.com/report/?url=' + url;
var redirectWindow = window.open(bugheist, '_blank');
redirectWindow.location;
});
});
</script>
{% endblock %}
12 changes: 10 additions & 2 deletions website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,11 @@ def get_context_data(self, *args, **kwargs):
status="closed")

context['name'] = parsed_url.netloc.split(".")[-2:][0].title()
context['domain'] = Domain.objects.get(name=self.kwargs['slug'])

try:
context['domain'] = Domain.objects.get(name=self.kwargs['slug'])
except Domain.DoesNoTExist:
raise Http404("domain not found")

paginator = Paginator(open_issue, 10)
page = self.request.GET.get('open')
Expand Down Expand Up @@ -771,7 +775,11 @@ def post(self, request, *args, **kwargs):


def UpdateIssue(request):
issue = Issue.objects.get(id=request.POST.get('issue_pk'))
try:
issue = Issue.objects.get(id=request.POST.get('issue_pk'))
except Issue.DoesNoTExist:
raise Http404("issue not found")

if request.method == "POST" and request.user.is_superuser or (issue is not None and request.user == issue.user):
if request.POST.get('action') == "close":
issue.status = "closed"
Expand Down

0 comments on commit 41567b7

Please sign in to comment.