Skip to content

Commit 87319a1

Browse files
authored
Merge pull request #3 from metalogico/develop
Develop
2 parents d00074d + 82e3175 commit 87319a1

File tree

18 files changed

+173
-99
lines changed

18 files changed

+173
-99
lines changed

django_sonar/mixins.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from django.contrib.auth.mixins import AccessMixin
2+
from django.http import HttpResponseForbidden
3+
from django.shortcuts import redirect
4+
5+
6+
class SuperuserRequiredMixin(AccessMixin):
7+
"""
8+
Ensure that the user is logged in and is a superuser.
9+
"""
10+
11+
def dispatch(self, request, *args, **kwargs):
12+
if not request.user.is_authenticated:
13+
return redirect('sonar_login')
14+
15+
if not request.user.is_superuser:
16+
return redirect('sonar_denied')
17+
18+
return super().dispatch(request, *args, **kwargs)

django_sonar/static/django_sonar/css/django-sonar.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ a:hover {
7474
font-size: 10px !important;
7575
}
7676

77+
.text-light-grey {
78+
color: #bec6cc !important;
79+
}
80+
7781
.card-header {
7882
padding-top: 20px !important;
7983
padding-bottom: 20px !important;

django_sonar/static/django_sonar/css/solid.min.css

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{% extends "django_sonar/layouts/auth.html" %}
2+
3+
{% block content %}
4+
<div class="container">
5+
<div class="row justify-content-center">
6+
<div class="col-md-6">
7+
<h1 class="text-center mt-5">
8+
<i class="bi bi-broadcast me-1"></i>Django Sonar
9+
</h1>
10+
<div class="card shadow-sm mt-5">
11+
<div class="card-body text-center">
12+
<h5 class="card-title text-danger">Access denied</h5>
13+
<div class="mt-3">
14+
The current user doesn't have permission to access this page.
15+
</div>
16+
</div>
17+
</div>
18+
</div>
19+
</div>
20+
</div>
21+
{% endblock %}

django_sonar/templates/django_sonar/auth/login.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% block content %}
44
<div class="container">
55
<div class="row justify-content-center">
6-
<div class="col-md-6">
6+
<div class="col-md-4">
77
<h1 class="text-center mt-5">
88
<i class="bi bi-broadcast me-1"></i>Django Sonar
99
</h1>

django_sonar/templates/django_sonar/dumps/index.html

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,32 @@ <h5 class="card-title">Dumps</h5>
44
</div>
55
<div class="card-body">
66

7-
<table class="table table-dashed table-hover">
8-
<thead>
9-
<tr>
10-
<th scope="col">Dump</th>
11-
<th scope="col" class="text-end">Happened</th>
12-
<th class="w-50px text-end">&nbsp;</th>
13-
</tr>
14-
</thead>
15-
<tbody>
16-
{% for dump in dumps %}
17-
<tr class="align-middle">
18-
<td><code>{{ dump.data|safe }}</code></td>
19-
<td class="text-end">{{ dump.created_at|timesince }}</td>
20-
<td class="w-50px text-end">
21-
<a class="btn btn-sm btn-icon btn-primary">
22-
<i class="bi bi-arrow-right"></i>
23-
</a>
24-
</td>
25-
</tr>
26-
{% endfor %}
27-
</tbody>
28-
</table>
7+
{% if not dumps %}
8+
<div class="text-light-grey">No dumps found</div>
9+
{% else %}
10+
<table class="table table-dashed table-hover">
11+
<thead>
12+
<tr>
13+
<th scope="col">Dump</th>
14+
<th scope="col" class="text-end">Happened</th>
15+
<th class="w-50px text-end">&nbsp;</th>
16+
</tr>
17+
</thead>
18+
<tbody>
19+
{% for dump in dumps %}
20+
<tr class="align-middle">
21+
<td><code>{{ dump.data|safe }}</code></td>
22+
<td class="text-end">{{ dump.created_at|timesince }}</td>
23+
<td class="w-50px text-end">
24+
<a class="btn btn-sm btn-icon btn-primary">
25+
<i class="bi bi-arrow-right"></i>
26+
</a>
27+
</td>
28+
</tr>
29+
{% endfor %}
30+
</tbody>
31+
</table>
32+
{% endif %}
2933

3034
</div>
3135
</div>

django_sonar/templates/django_sonar/exceptions/index.html

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,36 @@ <h5 class="card-title">Queries</h5>
44
</div>
55
<div class="card-body">
66

7-
<table class="table table-dashed table-hover">
8-
<thead>
9-
<tr>
10-
<th scope="col">Type</th>
11-
<th scope="col">File/Line</th>
12-
<th scope="col">Function</th>
13-
<th scope="col">Happened</th>
14-
<th class="w-50px">&nbsp;</th>
15-
</tr>
16-
</thead>
17-
<tbody>
18-
{% for exception in exceptions %}
19-
<tr>
20-
<td>{{ exception.data.exception_message }}</td>
21-
<td><code>{{ exception.data.file_name }}:{{ exception.data.line_number }}</code></td>
22-
<td>{{ exception.created_at|timesince }}</td>
23-
<td>
24-
<a class="btn btn-sm btn-icon btn-primary">
25-
<i class="bi bi-arrow-right"></i>
26-
</a>
27-
</td>
28-
</tr>
29-
{% endfor %}
30-
</tbody>
31-
</table>
7+
8+
{% if not exceptions %}
9+
<div class="text-light-grey">No exceptions found</div>
10+
{% else %}
11+
<table class="table table-dashed table-hover">
12+
<thead>
13+
<tr>
14+
<th scope="col">Type</th>
15+
<th scope="col">File/Line</th>
16+
<th scope="col">Function</th>
17+
<th scope="col">Happened</th>
18+
<th class="w-50px">&nbsp;</th>
19+
</tr>
20+
</thead>
21+
<tbody>
22+
{% for exception in exceptions %}
23+
<tr>
24+
<td>{{ exception.data.exception_message }}</td>
25+
<td><code>{{ exception.data.file_name }}:{{ exception.data.line_number }}</code></td>
26+
<td>{{ exception.created_at|timesince }}</td>
27+
<td>
28+
<a class="btn btn-sm btn-icon btn-primary">
29+
<i class="bi bi-arrow-right"></i>
30+
</a>
31+
</td>
32+
</tr>
33+
{% endfor %}
34+
</tbody>
35+
</table>
36+
{% endif %}
3237

3338
</div>
3439
</div>

django_sonar/templates/django_sonar/layouts/auth.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<title>Django Sonar</title>
1010
<link rel="shortcut icon" href="{% static 'django_sonar/media/logos/favicon.png' %}">
1111
<link rel="stylesheet" href="{% static 'django_sonar/css/bootstrap.min.css' %}">
12+
<link rel="stylesheet" href="{% static 'django_sonar/css/django-sonar.css' %}">
1213
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
1314
</head>
1415
<body class="">

django_sonar/templates/django_sonar/queries/index.html

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,35 @@ <h5 class="card-title">Queries</h5>
44
</div>
55
<div class="card-body">
66

7-
<table class="table table-dashed table-hover">
8-
<thead>
9-
<tr>
10-
<th scope="col">Query</th>
11-
<th scope="col">Duration</th>
12-
<th scope="col">Happened</th>
13-
<th class="w-50px">&nbsp;</th>
14-
</tr>
15-
</thead>
16-
<tbody>
17-
{% for query in queries %}
18-
<tr>
19-
<td><code>{{ query.sql|truncatechars:90 }}</code></td>
20-
<td>{{ query.time }}ms</td>
21-
<td>{{ query.created_at|timesince }}</td>
22-
<td>
23-
<a class="btn btn-sm btn-icon btn-primary">
24-
<i class="bi bi-arrow-right"></i>
25-
</a>
26-
</td>
27-
</tr>
28-
{% endfor %}
29-
</tbody>
30-
</table>
7+
8+
{% if not queries %}
9+
<div class="text-light-grey">No queries found</div>
10+
{% else %}
11+
<table class="table table-dashed table-hover">
12+
<thead>
13+
<tr>
14+
<th scope="col">Query</th>
15+
<th scope="col">Duration</th>
16+
<th scope="col">Happened</th>
17+
<th class="w-50px">&nbsp;</th>
18+
</tr>
19+
</thead>
20+
<tbody>
21+
{% for query in queries %}
22+
<tr>
23+
<td><code>{{ query.sql|truncatechars:90 }}</code></td>
24+
<td>{{ query.time }}ms</td>
25+
<td>{{ query.created_at|timesince }}</td>
26+
<td>
27+
<a class="btn btn-sm btn-icon btn-primary">
28+
<i class="bi bi-arrow-right"></i>
29+
</a>
30+
</td>
31+
</tr>
32+
{% endfor %}
33+
</tbody>
34+
</table>
35+
{% endif %}
3136

3237
</div>
3338
</div>

django_sonar/templates/django_sonar/requests/detail_dumps.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<div class="card shadow-sm border-light mt-3">
22

33
<div class="card-body">
4+
5+
{% if not dumps %}
6+
<div class="text-light-grey">No dumps found</div>
7+
{% endif %}
8+
49
{% for dump in dumps %}
510
<div class="row">
611
<div class="col border-bottom border-1 border-light pb-3">

0 commit comments

Comments
 (0)