Эх сурвалжийг харах

[core] Set document natural keys as composite

Romain Rigaux 11 жил өмнө
parent
commit
22416bc598

+ 3 - 2
apps/impala/static/js/impala-dashboard.ko.js

@@ -127,7 +127,8 @@ var Query = function (vm, query) {
 
 var Dashboard = function (vm, dashboard) { 
   var self = this;
-  
+
+  self.id = ko.mapping.fromJS(dashboard.id);
   self.facets = ko.mapping.fromJS(dashboard.facets);
   self.properties = ko.mapping.fromJS(dashboard.properties);
 
@@ -351,7 +352,7 @@ var ImpalaDashboardViewModel = function (query_json, dashboard_json, initial_jso
           "layout": ko.mapping.toJSON(self.columns)
       }, function (data) {
         if (data.status == 0) {
-          self.collection.id = data.id;
+          self.dashboard.id(data.id);
           $(document).trigger("info", data.message);
           if (window.location.search.indexOf("dashboard") == -1) {
             window.location.hash = '#dashboard=' + data.id;

+ 3 - 3
desktop/core/src/desktop/models.py

@@ -589,8 +589,8 @@ class DocumentPermission(models.Model):
 
 
 class Document2Manager(models.Manager):
-  def get_by_natural_key(self, uuid):
-    return self.get(uuid=uuid)
+  def get_by_natural_key(self, uuid, version, is_history):
+    return self.get(uuid=uuid, version=version, is_history=is_history)
 
 
 def uuid_default():
@@ -618,7 +618,7 @@ class Document2(models.Model):
   unique_together = ('uuid', 'version', 'is_history')
   
   def natural_key(self):
-    return (self.uuid,)
+    return (self.uuid, self.version, self.is_history)
   
   @property
   def data_dict(self):