CORD-879 add content_type_id to core api

Change-Id: Iae38dbe4511f8c3297a1a48c6b57780caf9c1d97
diff --git a/xos/coreapi/apihelper.py b/xos/coreapi/apihelper.py
index 89d1545..9d9134c 100644
--- a/xos/coreapi/apihelper.py
+++ b/xos/coreapi/apihelper.py
@@ -6,6 +6,7 @@
 from protos import xos_pb2
 from google.protobuf.empty_pb2 import Empty
 
+from django.contrib.contenttypes.models import ContentType
 from django.contrib.auth import authenticate as django_authenticate
 from django.db.models import F,Q
 from core.models import *
@@ -98,6 +99,8 @@
         bases = [x for x in bases if issubclass(x, PlCoreBase) or issubclass(x, User)]
         p_obj.class_names = ",".join( [x.__name__ for x in bases] )
 
+        p_obj.self_content_type_id = ContentType.objects.get_for_model(obj).id
+
         return p_obj
 
     def protoToArgs(self, djangoClass, message):
diff --git a/xos/tools/apigen/protobuf.template.txt b/xos/tools/apigen/protobuf.template.txt
index 3e5d82a..986d017 100644
--- a/xos/tools/apigen/protobuf.template.txt
+++ b/xos/tools/apigen/protobuf.template.txt
@@ -61,6 +61,7 @@
     repeated int32 {{ ref.related_name }}_ids  = {{ loop.index+100 }} [(reverseForeignKey).modelName = "{{ ref.camel() }}"];
   {%- endfor %}
   string class_names = 201;
+  int32 self_content_type_id = 202;
 }
 
 message {{ object.camel() }}s {