From 142295671ba277e310af8a9328b426e5e9120a30 Mon Sep 17 00:00:00 2001 From: Arik Fraimovich Date: Sat, 1 Aug 2015 16:30:03 +0300 Subject: [PATCH 1/2] Feature flag to control if everyone can edit queries --- rd_ui/app/scripts/controllers/query_source.js | 2 +- redash/controllers.py | 3 ++- redash/settings.py | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/rd_ui/app/scripts/controllers/query_source.js b/rd_ui/app/scripts/controllers/query_source.js index 2e067b4958..dea2021587 100644 --- a/rd_ui/app/scripts/controllers/query_source.js +++ b/rd_ui/app/scripts/controllers/query_source.js @@ -17,7 +17,7 @@ saveQuery = $scope.saveQuery; $scope.sourceMode = true; - $scope.canEdit = true; + $scope.canEdit = currentUser.canEdit($scope.query) || featureFlags.allowAllToEditQueries; $scope.isDirty = false; $scope.newVisualization = undefined; diff --git a/redash/controllers.py b/redash/controllers.py index a72fba1e38..717729a450 100644 --- a/redash/controllers.py +++ b/redash/controllers.py @@ -59,7 +59,8 @@ def index(**kwargs): } features = { - 'clientSideMetrics': settings.CLIENT_SIDE_METRICS + 'clientSideMetrics': settings.CLIENT_SIDE_METRICS, + 'allowAllToEditQueries': settings.FEATURE_ALLOW_ALL_TO_EDIT_QUERIES } return render_template("index.html", user=json.dumps(user), name=settings.NAME, diff --git a/redash/settings.py b/redash/settings.py index 0cd825305c..6ab7230f9a 100644 --- a/redash/settings.py +++ b/redash/settings.py @@ -131,4 +131,5 @@ def all_settings(): ]))) # Features: +FEATURE_ALLOW_ALL_TO_EDIT_QUERIES = parse_boolean(os.environ.get("REDASH_FEATURE_ALLOW_ALL_TO_EDIT", "true")) FEATURE_TABLES_PERMISSIONS = parse_boolean(os.environ.get("REDASH_FEATURE_TABLES_PERMISSIONS", "false")) From 3a56b9ded7f11a211656d150656ffba269a8f6f8 Mon Sep 17 00:00:00 2001 From: Arik Fraimovich Date: Sat, 1 Aug 2015 16:36:56 +0300 Subject: [PATCH 2/2] Don't set last_modified_by if only changing ref to last result --- redash/controllers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/redash/controllers.py b/redash/controllers.py index 717729a450..2070d5b050 100644 --- a/redash/controllers.py +++ b/redash/controllers.py @@ -392,7 +392,9 @@ def post(self, query_id): if 'data_source_id' in query_def: query_def['data_source'] = query_def.pop('data_source_id') - query_def['last_modified_by'] = self.current_user + # Don't set "last_modified_by" if the user only refreshing this query + if not ('latest_query_data' in query_def and len(query_def.keys()) == 1): + query_def['last_modified_by'] = self.current_user # TODO: use #save() with #dirty_fields. models.Query.update_instance(query_id, **query_def)