Skip to content

Commit a784e0e

Browse files
ashfaq1934albertyw
authored andcommitted
added button to delete specific requests on summary and requests pages
1 parent 615ab31 commit a784e0e

File tree

6 files changed

+33
-1
lines changed

6 files changed

+33
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ fabric.properties
119119

120120
# Virtual env
121121
.venv*
122+
venv
122123

123124
package-lock.json
124125
*.db

silk/static/silk/css/button.css

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.silk-button{
2+
border: 1px solid transparent;
3+
border-radius: 0.25rem;
4+
padding: 6px 10px;
5+
background: rgb(51, 51, 68);
6+
color: whitesmoke;
7+
margin-top: 5%;
8+
}
9+
10+
.cell:hover .silk-button{
11+
background-color: #e2e6ea;
12+
color: #000;
13+
}

silk/templates/silk/base/root_base.html

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<link rel="stylesheet" href="{% static 'silk/css/cell.css' %}"/>
1212
<link rel="stylesheet" href="{% static 'silk/css/row.css' %}"/>
1313
<link rel="stylesheet" href="{% static 'silk/css/numeric.css' %}"/>
14+
<link rel="stylesheet" href="{% static 'silk/css/button.css' %}">
1415
<link rel="stylesheet" href="{% static "silk/lib/jquery.datetimepicker.css" %}"/>
1516
<link rel="icon" type="image/png" href="{% static 'silk/favicon-32x32.png' %}" sizes="32x32">
1617
<link rel="icon" type="image/png" href="{% static 'silk/favicon-16x16.png' %}" sizes="16x16">

silk/templates/silk/inclusion/request_summary.html

+6
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@
1414
<span class="numeric">{{ silk_request.num_sql_queries }}</span>
1515
<span class="appendage">queries<span class="meta">{% if silk_request.meta_num_queries %} +{{ silk_request.meta_num_queries }}{% endif %}</span>
1616
</div>
17+
<div>
18+
<form action="{% url 'silk:request_detail' silk_request.id %}" method="POST">
19+
{% csrf_token %}
20+
<button class="silk-button" type="submit" value="Delete">Delete</button>
21+
</form>
22+
</div>
1723
</div>

silk/templates/silk/request.html

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
{% block style %}
66
<link rel="stylesheet" href="{% static 'silk/css/cell.css' %}"/>
77
<link rel="stylesheet" href="{% static 'silk/css/numeric.css' %}"/>
8+
<link rel="stylesheet" href="{% static 'silk/css/button.css' %}">
89
<link rel="stylesheet" href="{% static 'silk/css/heading.css' %}"/>
910
<link rel="stylesheet" href="{% static 'silk/lib/highlight/foundation.css' %}"/>
1011
<style>

silk/views/request_detail.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22

3-
from django.shortcuts import render
3+
from django.shortcuts import render, redirect, HttpResponseRedirect
44
from django.utils.decorators import method_decorator
55
from django.views.generic import View
66

@@ -40,3 +40,13 @@ def get(self, request, request_id):
4040
'request': request
4141
}
4242
return render(request, 'silk/request.html', context)
43+
44+
@method_decorator(login_possibly_required)
45+
@method_decorator(permissions_possibly_required)
46+
def post(self, request, request_id):
47+
silk_request = Request.objects.get(pk=request_id)
48+
try:
49+
silk_request.delete()
50+
except Request.DoesNotExist:
51+
return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/silk'))
52+
return redirect('/silk')

0 commit comments

Comments
 (0)