From d39702b0007ef30fb1021e7eaf7f470d66bc8eda Mon Sep 17 00:00:00 2001 From: Atul Varma Date: Fri, 6 Aug 2021 17:46:28 -0400 Subject: [PATCH 1/2] Allow users w/ execute_sql to export saved dashboards. --- .../django_sql_dashboard/widgets/default.html | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/django_sql_dashboard/templates/django_sql_dashboard/widgets/default.html b/django_sql_dashboard/templates/django_sql_dashboard/widgets/default.html index aaab5ac..1f2fe9f 100644 --- a/django_sql_dashboard/templates/django_sql_dashboard/widgets/default.html +++ b/django_sql_dashboard/templates/django_sql_dashboard/widgets/default.html @@ -13,7 +13,7 @@ {% if result.truncated %}

Results were truncated - {% if user_can_export_data and not saved_dashboard %} + {% if user_can_export_data %}

Copy and export data - {% if user_can_export_data and not saved_dashboard %} + {% if user_can_export_data %}

Duration: {{ result.duration_ms|floatformat:2 }}ms

+ + {% if saved_dashboard and user_can_export_data %} + {% comment %} + This is a bit of a hack to allow users with execute_sql permission to export + saved dashboards. We're essentially simulating a user who typed a SQL + query into the dashboard index page and decided to export it. + {% endcomment %} + + + {% endif %} +