mirror of
https://github.com/getredash/redash.git
synced 2025-12-19 17:37:19 -05:00
Merge pull request #1394 from getredash/012patches
Fix: conflict handling in dashboard widget editing was wrong
This commit is contained in:
@@ -242,6 +242,7 @@
|
|||||||
$scope.dashboard.widgets = _.filter($scope.dashboard.widgets, function(row) { return row.length > 0 });
|
$scope.dashboard.widgets = _.filter($scope.dashboard.widgets, function(row) { return row.length > 0 });
|
||||||
|
|
||||||
$scope.dashboard.layout = response.layout;
|
$scope.dashboard.layout = response.layout;
|
||||||
|
$scope.dashboard.version = response.version;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -208,6 +208,7 @@
|
|||||||
widget.$save().then(function(response) {
|
widget.$save().then(function(response) {
|
||||||
// update dashboard layout
|
// update dashboard layout
|
||||||
$scope.dashboard.layout = response['layout'];
|
$scope.dashboard.layout = response['layout'];
|
||||||
|
$scope.dashboard.version = response['version'];
|
||||||
var newWidget = new Widget(response['widget']);
|
var newWidget = new Widget(response['widget']);
|
||||||
if (response['new_row']) {
|
if (response['new_row']) {
|
||||||
$scope.dashboard.widgets.push([newWidget]);
|
$scope.dashboard.widgets.push([newWidget]);
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from flask import request
|
from flask import request
|
||||||
|
|
||||||
from redash import models
|
from redash import models
|
||||||
from redash.permissions import require_permission, require_admin_or_owner, require_access, view_only
|
|
||||||
from redash.handlers.base import BaseResource
|
from redash.handlers.base import BaseResource
|
||||||
|
from redash.permissions import (require_access,
|
||||||
|
require_object_modify_permission,
|
||||||
|
require_permission, view_only)
|
||||||
|
|
||||||
|
|
||||||
class WidgetListResource(BaseResource):
|
class WidgetListResource(BaseResource):
|
||||||
@@ -12,7 +13,7 @@ class WidgetListResource(BaseResource):
|
|||||||
def post(self):
|
def post(self):
|
||||||
widget_properties = request.get_json(force=True)
|
widget_properties = request.get_json(force=True)
|
||||||
dashboard = models.Dashboard.get_by_id_and_org(widget_properties.pop('dashboard_id'), self.current_org)
|
dashboard = models.Dashboard.get_by_id_and_org(widget_properties.pop('dashboard_id'), self.current_org)
|
||||||
require_admin_or_owner(dashboard.user_id)
|
require_object_modify_permission(dashboard, self.current_user)
|
||||||
|
|
||||||
widget_properties['options'] = json.dumps(widget_properties['options'])
|
widget_properties['options'] = json.dumps(widget_properties['options'])
|
||||||
widget_properties.pop('id', None)
|
widget_properties.pop('id', None)
|
||||||
@@ -47,7 +48,7 @@ class WidgetListResource(BaseResource):
|
|||||||
widget.dashboard.layout = json.dumps(layout)
|
widget.dashboard.layout = json.dumps(layout)
|
||||||
widget.dashboard.save()
|
widget.dashboard.save()
|
||||||
|
|
||||||
return {'widget': widget.to_dict(), 'layout': layout, 'new_row': new_row}
|
return {'widget': widget.to_dict(), 'layout': layout, 'new_row': new_row, 'version': dashboard.version}
|
||||||
|
|
||||||
|
|
||||||
class WidgetResource(BaseResource):
|
class WidgetResource(BaseResource):
|
||||||
@@ -55,7 +56,7 @@ class WidgetResource(BaseResource):
|
|||||||
def post(self, widget_id):
|
def post(self, widget_id):
|
||||||
# This method currently handles Text Box widgets only.
|
# This method currently handles Text Box widgets only.
|
||||||
widget = models.Widget.get_by_id_and_org(widget_id, self.current_org)
|
widget = models.Widget.get_by_id_and_org(widget_id, self.current_org)
|
||||||
require_admin_or_owner(widget.dashboard.user_id)
|
require_object_modify_permission(widget.dashboard, self.current_user)
|
||||||
widget_properties = request.get_json(force=True)
|
widget_properties = request.get_json(force=True)
|
||||||
widget.text = widget_properties['text']
|
widget.text = widget_properties['text']
|
||||||
widget.save()
|
widget.save()
|
||||||
@@ -65,7 +66,7 @@ class WidgetResource(BaseResource):
|
|||||||
@require_permission('edit_dashboard')
|
@require_permission('edit_dashboard')
|
||||||
def delete(self, widget_id):
|
def delete(self, widget_id):
|
||||||
widget = models.Widget.get_by_id_and_org(widget_id, self.current_org)
|
widget = models.Widget.get_by_id_and_org(widget_id, self.current_org)
|
||||||
require_admin_or_owner(widget.dashboard.user_id)
|
require_object_modify_permission(widget.dashboard, self.current_user)
|
||||||
widget.delete_instance()
|
widget.delete_instance()
|
||||||
|
|
||||||
return {'layout': widget.dashboard.layout}
|
return {'layout': widget.dashboard.layout, 'version': widget.dashboard.version}
|
||||||
|
|||||||
Reference in New Issue
Block a user