From: Scott Baker Date: Sat, 17 Jan 2015 03:26:54 +0000 (-0800) Subject: fix users list not subtracted properly when displaying picker X-Git-Url: http://git.onelab.eu/?p=plstackapi.git;a=commitdiff_plain;h=85743c1a683903301d2d69b4a552b56ab6effcba fix users list not subtracted properly when displaying picker --- diff --git a/planetstack/core/xoslib/dashboards/xosTenant.html b/planetstack/core/xoslib/dashboards/xosTenant.html index ca74d5c..1287e15 100644 --- a/planetstack/core/xoslib/dashboards/xosTenant.html +++ b/planetstack/core/xoslib/dashboards/xosTenant.html @@ -42,11 +42,13 @@ diff --git a/planetstack/core/xoslib/objects/sliceplus.py b/planetstack/core/xoslib/objects/sliceplus.py index 4fdc824..9a70e25 100644 --- a/planetstack/core/xoslib/objects/sliceplus.py +++ b/planetstack/core/xoslib/objects/sliceplus.py @@ -57,6 +57,10 @@ class SlicePlus(Slice, PlusObjectMixin): def user_names(self): return [user["name"] for user in self.getSliceInfo()["users"].values()] + @user_names.setter + def user_names(self, value): + pass # it's read-only + @property def users(self): return [user["id"] for user in self.getSliceInfo()["users"].values()] diff --git a/planetstack/core/xoslib/static/js/xosTenant.js b/planetstack/core/xoslib/static/js/xosTenant.js index 929552c..96465d3 100644 --- a/planetstack/core/xoslib/static/js/xosTenant.js +++ b/planetstack/core/xoslib/static/js/xosTenant.js @@ -264,6 +264,8 @@ XOSTenantApp.viewSlice = function(model) { tenantSites = new XOSTenantSiteCollection(); tenantSites.getFromSlice(model); model.usersBuffer = model.attributes.users; /* save a copy of 'users' that we can edit. This prevents another view (developer) from overwriting our copy with a fetch from the server */ + model.usersOrig = model.attributes.users; /* save an immutable copy that we'll use for username lookups */ + model.user_namesOrig = model.attributes.user_names; model.tenantSiteCollection = tenantSites; XOSTenantApp.tenantSites = tenantSites; diff --git a/planetstack/core/xoslib/static/js/xoslib/xos-util.js b/planetstack/core/xoslib/static/js/xoslib/xos-util.js index 7a57d8a..59fb06e 100644 --- a/planetstack/core/xoslib/static/js/xoslib/xos-util.js +++ b/planetstack/core/xoslib/static/js/xoslib/xos-util.js @@ -93,6 +93,18 @@ function array_diff(a1, a2) return diff; } +function array_subtract(a1, a2) +{ + result=[] + for (index in a1) { + value = a1[index]; + if (!$.inArray(value, a2) >= 0) { + result.push(value); + } + } + return result; +} + function array_pair_lookup(x, names, values) { for (index in values) {