tenant view only shows sites the user should be able to see
diff --git a/planetstack/core/xoslib/static/js/xosDeveloper_datatables.js b/planetstack/core/xoslib/static/js/xosDeveloper_datatables.js
index 4be4e0f..7d6ee3c 100644
--- a/planetstack/core/xoslib/static/js/xosDeveloper_datatables.js
+++ b/planetstack/core/xoslib/static/js/xosDeveloper_datatables.js
@@ -12,12 +12,16 @@
row = data.models[rowkey];
slicename = row.get("name");
sliceid = row.get("id");
- role = row.get("sliceInfo").roles[0];
+ role = row.get("sliceInfo").roles[0] || "";
slivercount = row.get("sliceInfo").sliverCount;
sitecount = row.get("sliceInfo").siteCount;
backendHtml = row.get("backendHtml")
- if (! role) {
+ //if (! role) {
+ // continue;
+ //}
+
+ if (! row.get("current_user_can_see") ) {
continue;
}
diff --git a/planetstack/core/xoslib/static/js/xosTenant.js b/planetstack/core/xoslib/static/js/xosTenant.js
index ae6f955..0182f9f 100644
--- a/planetstack/core/xoslib/static/js/xosTenant.js
+++ b/planetstack/core/xoslib/static/js/xosTenant.js
@@ -178,6 +178,9 @@
sliceChanged: function(id) {
XOSTenantApp.navToSlice(id);
},
+ filter: function(slice) {
+ return slice.attributes.current_user_can_see;
+ },
});
xos.sites.fetch();
diff --git a/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js b/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js
index d359f36..1ca1307 100644
--- a/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js
+++ b/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js
@@ -319,18 +319,12 @@
var url = this.urlRoot || ( models && models.length && models[0].urlRoot );
url && ( url += ( url.length > 0 && url.charAt( url.length - 1 ) === '/' ) ? '' : '/' );
- // Build a url to retrieve a set of models. This assume the last part of each model's idAttribute
- // (set to 'resource_uri') contains the model's id.
- if ( models && models.length ) {
- var ids = _.map( models, function( model ) {
- var parts = _.compact( model.id.split('/') );
- return parts[ parts.length - 1 ];
- });
- url += 'set/' + ids.join(';') + '/';
- }
-
url && ( url += "?no_hyperlinks=1" );
+ if (this.currentUserCanSee) {
+ url && ( url += "¤t_user_can_see=1" );
+ }
+
return url;
},
@@ -364,6 +358,7 @@
function define_model(lib, attrs) {
modelName = attrs.modelName;
modelClassName = modelName;
+ collectionClass = attrs.collectionClass || XOSCollection;
collectionClassName = modelName + "Collection";
if (!attrs.addFields) {
@@ -411,7 +406,7 @@
collectionAttrs["model"] = lib[modelName];
- lib[collectionClassName] = XOSCollection.extend(collectionAttrs);
+ lib[collectionClassName] = collectionClass.extend(collectionAttrs);
lib[collectionName] = new lib[collectionClassName]();
lib.allCollectionNames.push(collectionName);
@@ -692,7 +687,10 @@
detailFields: [],
});
- this.tenant = function() { return this.tenantview.models[0].attributes; }
+ /* by default, have slicePlus only fetch the slices the user can see */
+ this.slicesPlus.currentUserCanSee = true;
+
+ this.tenant = function() { return this.tenantview.models[0].attributes; };
this.listObjects = function() { return this.allCollectionNames; };
diff --git a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
index 76254f6..7392843 100644
--- a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
+++ b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
@@ -4,6 +4,21 @@
},
});
+FilteredCompositeView = Marionette.CompositeView.extend( {
+ showCollection: function() {
+ var ChildView;
+ this.collection.each(function(child, index) {
+ filterFunc = this.options.filter || this.filter;
+ if (filterFunc && !filterFunc(child)) {
+ return;
+ }
+ ChildView = this.getChildView(child);
+ this.addChild(child, ChildView, index);
+ }, this);
+
+ },
+});
+
SliceSelectorOption = Marionette.ItemView.extend({
template: "#xos-sliceselector-option",
tagName: "option",
@@ -16,7 +31,7 @@
},
});
-SliceSelectorView = Marionette.CompositeView.extend({
+SliceSelectorView = FilteredCompositeView.extend({
template: "#xos-sliceselector-select",
childViewContainer: "select",
childView: SliceSelectorOption,
@@ -39,20 +54,6 @@
templateHelpers: function() { return {caption: this.options.caption || this.caption }; },
});
-FilteredCompositeView = Marionette.CompositeView.extend( {
- showCollection: function() {
- var ChildView;
- this.collection.each(function(child, index) {
- if (this.filter && !this.filter(child)) {
- return;
- }
- ChildView = this.getChildView(child);
- this.addChild(child, ChildView, index);
- }, this);
-
- },
-});
-
XOSRouter = Marionette.AppRouter.extend({
initialize: function() {
this.routeStack=[];