From 90ed437438382a32fb29314ec2f3200dd9bee0fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Antonio=20Perdiguero?= Date: Thu, 16 Mar 2017 17:55:19 +0100 Subject: [PATCH] Adds download link of profile file to view, fixes #170 (#171) Change also adds the content of the profile file to the view. --- silk/templates/silk/profile_detail.html | 29 +++++++++++++++++++++++++ silk/templates/silk/profiling.html | 11 ---------- silk/views/profile_detail.py | 8 +++---- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/silk/templates/silk/profile_detail.html b/silk/templates/silk/profile_detail.html index 32f043cf..7f1007e0 100644 --- a/silk/templates/silk/profile_detail.html +++ b/silk/templates/silk/profile_detail.html @@ -20,6 +20,22 @@ font-size: 13px; } + + a { + color: #45ADA8; + } + + a:visited { + color: #45ADA8; + } + + a:hover { + color: #547980; + } + + a:active { + color: #594F4F; + } {% endblock %} @@ -54,6 +70,19 @@ {% endif %} + {% if silk_request.pyprofile %} +
+
Python Profiler
+
+
+ The below is a dump from the cPython profiler. +
+ {% if silk_request.prof_file %} + Click here to download profile. + {% endif %} +
{{ silk_request.pyprofile }}
+ {% endif %} + diff --git a/silk/templates/silk/profiling.html b/silk/templates/silk/profiling.html index 609ca620..b12fe73b 100644 --- a/silk/templates/silk/profiling.html +++ b/silk/templates/silk/profiling.html @@ -252,15 +252,4 @@

Silk Profiler

{% endif %} - - {% if silk_request.pyprofile %} -
-

Python Profiler

- {% if silk_request.prof_file %} - - {% endif %} -
The below is a dump from the cPython profiler.
-
{{ silk_request.pyprofile }}
-
- {% endif %} {% endblock %} diff --git a/silk/views/profile_detail.py b/silk/views/profile_detail.py index bce46394..66513118 100644 --- a/silk/views/profile_detail.py +++ b/silk/views/profile_detail.py @@ -2,7 +2,7 @@ from django.utils.decorators import method_decorator from django.views.generic import View from silk.auth import login_possibly_required, permissions_possibly_required -from silk.models import Profile, Request +from silk.models import Profile from silk.views.sql_detail import _code @@ -12,7 +12,6 @@ class ProfilingDetailView(View): @method_decorator(permissions_possibly_required) def get(self, request, *_, **kwargs): profile_id = kwargs['profile_id'] - silk_request_id = kwargs.get('request_id', None) context = { 'request': request } @@ -22,9 +21,8 @@ def get(self, request, *_, **kwargs): context['profile'] = profile context['line_num'] = file_path context['file_path'] = line_num - if silk_request_id: - silk_request = Request.objects.get(pk=silk_request_id) - context['silk_request'] = silk_request + if profile.request: + context['silk_request'] = profile.request if file_path and line_num: try: actual_line, code = _code(file_path, line_num, profile.end_line_num)