First pass on API generator. Not for serious use.
diff --git a/planetstack/apigen/api.template.py b/planetstack/apigen/api.template.py
index 15995af..81a1eca 100644
--- a/planetstack/apigen/api.template.py
+++ b/planetstack/apigen/api.template.py
@@ -14,6 +14,7 @@
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
"""
@@ -23,8 +24,7 @@
@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),
+ {% for object in generator.all %}'{{ object.plural }}': reverse('{{ object }}-list', request=request, format=format),
{% endfor %}
})
@@ -35,11 +35,11 @@
class {{ object.camel }}Serializer(serializers.HyperlinkedModelSerializer):
id = serializers.Field()
{% for ref in object.refs %}
- sites = serializers.HyperlinkedRelatedField(view_name='{{ ref }}-detail')
+ {{ ref.plural }} = serializers.HyperlinkedRelatedField(view_name='{{ ref }}-detail')
{% endfor %}
class Meta:
model = {{ object }}
- fields = ('id',{% for ref in object.refs %}'{{ ref }}',{% endfor %})
+ fields = ({% for prop in object.props %}'{{ prop }}',{% endfor %})
{% endfor %}
serializerLookUp = {
diff --git a/planetstack/dmdot b/planetstack/dmdot
index b40d1af..0075f59 100755
--- a/planetstack/dmdot
+++ b/planetstack/dmdot
@@ -46,5 +46,3 @@
except KeyError:
d[c.__name__]=[f.name.title()]
print json.dumps(d,indent=4)
-
-