Commits

Matthew Schinckel committed 23d5677

Initial planning of inlines.
Currently not working: use your own routes instead.

  • Participants
  • Parent commits ae84a6f
  • Branches inlines

Comments (0)

Files changed (1)

File rest_api/options.py

     index_fields = ('name', 'href', 'id')
     # And which ones do we want to exclude?
     exclude = ('created', 'modified')
+    # We can include whole objects as inlines
+    inlines = []
+    
     
 class Api(BaseApi):
     def __init__(self, api_site):
             self.index_fields = self.fields
         model.href = property(lambda x: reverse('api:%s_%s_object' % (model._meta.app_label, model._meta.module_name), args=(x.pk,)))
         self.root_path = self.root_path or model._meta.module_name
+        self.inline_instances = []
+        for inline_class in self.inlines:
+            inline_instance = inline_class(self.model, self.api_site)
+            self.inline_instances.append(inline_instance)
         super(ModelApi, self).__init__()
         
     def get_urls(self):
             return qs
         raise http.Forbidden()
 
+class InlineApi(BaseModelApi):
+    """
+    Not yet implemented.
+    """
+    model = None
+    
+    def __init__(self, parent_model, api_site):
+        self.api_site = api_site
+        self.parent_model = parent_model
+        self.opts = self.model._meta
+        super(InlineApi, self).__init__()
+        
+    
+    
 # Monkey-patch to add in get_view_permissions().
 from django.db.models.options import Options