added openstack dependencies for the observer
Merge branch 'master' of ssh://git.planet-lab.org/git/plstackapi
diff --git a/planetstack/apigen/api.template.py b/planetstack/apigen/api.template.py
index f595d2b..a98acb8 100644
--- a/planetstack/apigen/api.template.py
+++ b/planetstack/apigen/api.template.py
@@ -9,17 +9,17 @@
 from rest_framework import filters
 
 """
-	Schema of the generator object:
-		all: Set of all Model objects
-		all_if(regex): Set of Model objects that match regex
-	
-	Model object:
-		plural: English plural of object name
-		camel: CamelCase version of object name
-		refs: list of references to other Model objects
-		props: list of properties minus refs
+    Schema of the generator object:
+        all: Set of all Model objects
+        all_if(regex): Set of Model objects that match regex
+    
+    Model object:
+        plural: English plural of object name
+        camel: CamelCase version of object name
+        refs: list of references to other Model objects
+        props: list of properties minus refs
 
-	TODO: Deal with subnets
+    TODO: Deal with subnets
 """
 
 # Based on api_root.py
@@ -27,8 +27,8 @@
 @api_view(['GET'])
 def api_root(request, format=None):
     return Response({
-		{% for object in generator.all %}'{{ object.plural }}': reverse('{{ object }}-list', request=request, format=format),
-		{% endfor %}
+        {% for object in generator.all %}'{{ object.plural }}': reverse('{{ object }}-list', request=request, format=format),
+        {% endfor %}
     })
 
 # Based on serializers.py
@@ -36,30 +36,30 @@
 {% for object in generator.all %}
 
 class {{ object.camel }}Serializer(serializers.HyperlinkedModelSerializer):
-	id = serializers.Field()
-	{% for ref in object.refs %}
-	{% if ref.multi %}
-	{{ ref.plural }} = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='{{ ref }}-detail')
-	{% else %}
-	{{ ref }} = serializers.HyperlinkedRelatedField(read_only=True, view_name='{{ ref }}-detail')
-	{% endif %}
-	{% endfor %}
-	class Meta:
-		model = {{ object.camel }}
-		fields = ({% for prop in object.props %}'{{ prop }}',{% endfor %}{% for ref in object.refs %}{%if ref.multi %}'{{ ref.plural }}'{% else %}'{{ ref }}'{% endif %},{% endfor %})
+    id = serializers.Field()
+    {% for ref in object.refs %}
+    {% if ref.multi %}
+    {{ ref.plural }} = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='{{ ref }}-detail')
+    {% else %}
+    {{ ref }} = serializers.HyperlinkedRelatedField(read_only=True, view_name='{{ ref }}-detail')
+    {% endif %}
+    {% endfor %}
+    class Meta:
+        model = {{ object.camel }}
+        fields = ({% for prop in object.props %}'{{ prop }}',{% endfor %}{% for ref in object.refs %}{%if ref.multi %}'{{ ref.plural }}'{% else %}'{{ ref }}'{% endif %},{% endfor %})
 
 class {{ object.camel }}IdSerializer(serializers.ModelSerializer):
-	id = serializers.Field()
-	{% for ref in object.refs %}
-	{% if ref.multi %}
-	{{ ref.plural }} = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='{{ ref }}-detail')
-	{% else %}
-	{{ ref }} = serializers.HyperlinkedRelatedField(read_only=True, view_name='{{ ref }}-detail')
-	{% endif %}
-	{% endfor %}
-	class Meta:
-		model = {{ object.camel }}
-		fields = ({% for prop in object.props %}'{{ prop }}',{% endfor %}{% for ref in object.refs %}{%if ref.multi %}'{{ ref.plural }}'{% else %}'{{ ref }}'{% endif %},{% endfor %})
+    id = serializers.Field()
+    {% for ref in object.refs %}
+    {% if ref.multi %}
+    {{ ref.plural }} = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='{{ ref }}-detail')
+    {% else %}
+    {{ ref }} = serializers.HyperlinkedRelatedField(read_only=True, view_name='{{ ref }}-detail')
+    {% endif %}
+    {% endfor %}
+    class Meta:
+        model = {{ object.camel }}
+        fields = ({% for prop in object.props %}'{{ prop }}',{% endfor %}{% for ref in object.refs %}{%if ref.multi %}'{{ ref.plural }}'{% else %}'{{ ref }}'{% endif %},{% endfor %})
 
 
 {% endfor %}
@@ -138,12 +138,15 @@
 
     def create(self, request, *args, **kwargs):
         #obj = {{ object.camel }}().update(request.DATA)
-        obj = self.get_object()
-        obj.caller = request.user
-        if obj.can_update(request.user):
-            return super({{ object.camel }}List, self).create(request, *args, **kwargs)
-        else:
-            return Response(status=status.HTTP_400_BAD_REQUEST)
+        #obj = self.get_object()
+        #obj.caller = request.user
+        ret = super({{ object.camel }}List, self).create(request, *args, **kwargs)
+        if (ret.status_code%100 != 200):
+            raise Exception(ret.data)
+        #if obj.can_update(request.user):
+        #    return super({{ object.camel }}List, self).create(request, *args, **kwargs)
+        #else:
+        #    return Response(status=status.HTTP_400_BAD_REQUEST)
 
 class {{ object.camel }}Detail(PlanetStackRetrieveUpdateDestroyAPIView):
     queryset = {{ object.camel }}.objects.select_related().all()
diff --git a/planetstack/core/models/site.py b/planetstack/core/models/site.py
index 9f183b5..0ade5df 100644
--- a/planetstack/core/models/site.py
+++ b/planetstack/core/models/site.py
@@ -20,7 +20,7 @@
 
         parent_queryset = parent.get_queryset() if hasattr(parent, "get_queryset") else parent.get_query_set()
         if (backend_type):
-            return parent_queryset.filter(Q(deployment__backend_type=backend_type)|Q(backend_type=None))
+            return parent_queryset.filter(Q(deployment__backend_type=backend_type))
         else:
             return parent_queryset
 
@@ -41,7 +41,7 @@
         parent_queryset = parent.get_queryset() if hasattr(parent, "get_queryset") else parent.get_query_set()
 
         if backend_type:
-            return parent_queryset.filter(Q(backend_type=backend_type)|Q(backend_type=None))
+            return parent_queryset.filter(Q(backend_type=backend_type))
         else:
             return parent_queryset
 
@@ -61,7 +61,7 @@
         parent_queryset = parent.get_queryset() if hasattr(parent, "get_queryset") else parent.get_query_set()
 
         if backend_type:
-            return parent_queryset.filter(Q(deployment__backend_type=backend_type)|Q(backend_type=None))
+            return parent_queryset.filter(Q(deployment__backend_type=backend_type))
         else:
             return parent_queryset
 
@@ -82,7 +82,7 @@
         parent_queryset = parent.get_queryset() if hasattr(parent, "get_queryset") else parent.get_query_set()
 
         if backend_type:
-            return parent_queryset.filter(Q(backend_type=backend_type)|Q(backend_type=None))
+            return parent_queryset.filter(Q(backend_type=backend_type))
         else:
             return parent_queryset