edit users button in tenant view
diff --git a/planetstack/core/xoslib/methods/sliceplus.py b/planetstack/core/xoslib/methods/sliceplus.py
index 0cfc67c..c48d036 100644
--- a/planetstack/core/xoslib/methods/sliceplus.py
+++ b/planetstack/core/xoslib/methods/sliceplus.py
@@ -22,7 +22,14 @@
def to_internal_value(self, data):
return data
-class SiteAllocationField(serializers.WritableField): # note: maybe just Field in rest_framework 3.x instead of WritableField
+class DictionaryField(serializers.WritableField): # note: maybe just Field in rest_framework 3.x instead of WritableField
+ def to_representation(self, obj):
+ return json.dumps(obj)
+
+ def to_internal_value(self, data):
+ return json.loads(data)
+
+class ListField(serializers.WritableField): # note: maybe just Field in rest_framework 3.x instead of WritableField
def to_representation(self, obj):
return json.dumps(obj)
@@ -35,7 +42,8 @@
sliceInfo = serializers.SerializerMethodField("getSliceInfo")
humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
network_ports = NetworkPortsField(required=False)
- site_allocation = SiteAllocationField(required=False)
+ site_allocation = DictionaryField(required=False)
+ users = ListField(required=False)
def getSliceInfo(self, slice):
return slice.getSliceInfo(user=self.context['request'].user)
@@ -44,13 +52,12 @@
return str(obj)
networks = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
-# availableNetworks = serializers.PrimaryKeyRelatedField(many=True, read_only=True, view_name='network-detail')
class Meta:
model = SlicePlus
fields = ('humanReadableName', 'id','created','updated','enacted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','service','network','mount_data_sets',
'default_image', 'default_flavor',
- 'serviceClass','creator','networks','sliceInfo','network_ports','backendIcon','backendHtml','site_allocation')
+ 'serviceClass','creator','networks','sliceInfo','network_ports','backendIcon','backendHtml','site_allocation','users')
class SlicePlusList(PlusListCreateAPIView): #generics.ListCreateAPIView):
queryset = SlicePlus.objects.select_related().all()
diff --git a/planetstack/core/xoslib/methods/tenantview.py b/planetstack/core/xoslib/methods/tenantview.py
index 596c082..b2e0e0e 100644
--- a/planetstack/core/xoslib/methods/tenantview.py
+++ b/planetstack/core/xoslib/methods/tenantview.py
@@ -46,6 +46,10 @@
if not volume.private:
volumes.append(volume)
+ site_users=[]
+ for auser in user.site.users.all():
+ site_users.append(auser)
+
blessed_service_classes = [ServiceClass.objects.get(name="Best Effort")]
return {"id": 0,
@@ -62,6 +66,8 @@
"public_volumes": [volume.id for volume in volumes],
"current_user_site_id": user.site.id,
"current_user_login_base": user.site.login_base,
+ "current_user_site_users": [auser.id for auser in site_users],
+ "current_user_site_user_names": [auser.email for auser in site_users],
}
class TenantList(APIView):