Continuing bug fixes
diff --git a/planetstack/apigen/modelgen b/planetstack/apigen/modelgen
index c36048e..ef2730b 100755
--- a/planetstack/apigen/modelgen
+++ b/planetstack/apigen/modelgen
@@ -74,21 +74,31 @@
def compute_links(self):
for obj in self.values():
- #if (str(obj)=='siteprivilege'):
+ #if (str(obj)=='network'):
# pdb.set_trace()
fields = obj.model._meta.fields
for f in fields:
- if type(f)==ForeignKey and f.name in self.keys():
- refobj = self[f.name]
- obj.refs.append(refobj)
+ if (f and f.rel):
+ to_name = str(f.rel.to)
+ else:
+ to_name = None
+
+ if type(f)==ForeignKey and to_name and to_name in self.keys():
+ refobj = self[f.to_name]
+
+ if (str(obj)=='slice' and f.to_name=='networks'):
+ obj.refs.append(refobj)
related_name = f.related_query_name()
- if (related_name.lower()!=str(obj).lower()):
+ if (related_name!='+' and related_name.lower()!=str(obj).lower()):
cobj = copy.deepcopy(obj)
cobj.multi = True
cobj.plural_name = related_name
+ #if (str(refobj)=='slice' and related_name=='networks'):
+ # pdb.set_trace()
refobj.refs.append(cobj)
else:
obj.props.append(f.name)
+
m2m = obj.model._meta.many_to_many
for f in m2m:
try:
@@ -96,6 +106,7 @@
except:
related_model_name = f.m2m_db_table().rsplit('_',1)[-1]
+ related_name = f.related_query_name()
if related_model_name in self.keys():
# pdb.set_trace()
refobj = self[related_model_name]
@@ -103,12 +114,19 @@
cobj.multi=True
refobj.refs.append(cobj)
- if (related_name.lower()!=str(obj).lower()):
+ if (related_name!='+' and related_name.lower()!=str(obj).lower()):
cobj = copy.deepcopy(obj)
cobj.multi = True
cobj.plural_name = related_name
+
+ #if (str(refobj)=='slice' and related_name=='networks'):
+ # pdb.set_trace()
refobj.refs.append(cobj)
+ #if (related_name=='networks'):
+ #pdb.set_trace()
+ #print str(refobj)
+