فهرست منبع

resolved circular dependency

Marcos Dumay de Medeiros 9 سال پیش
والد
کامیت
83409c17fa
2فایلهای تغییر یافته به همراه6 افزوده شده و 3 حذف شده
  1. 4 0
      src/rapid/rapidfields.py
  2. 2 3
      src/rapid/wrappers.py

+ 4 - 0
src/rapid/rapidfields.py

@@ -18,6 +18,8 @@ class AlternativeData(GenericForeignKey):
     Create like a Django GenericForeignKey, but use an AlternativeDataTables instead of a
     ForeignKey to ContentTypes.
     """
+    is_alternatives = True
+
     def formfield(self, **kwargs):
         kwargs['form_class'] = RapidAlternativesField
         return super(GenericForeignKey, self).formfield(**kwargs)
@@ -28,6 +30,8 @@ class AlternativeDataTables(models.ForeignKey):
     Use an AlternativeDataTables model field on AlternativeData represetntations, instead of
     a ForeignKey with ContentTypes.
     """
+    is_alternatives = True
+
     def __init__(self, alternatives=[], **kwargs):
         """
         Receives the same named parameters of a ForeignKey, but instead of a target table,

+ 2 - 3
src/rapid/wrappers.py

@@ -6,7 +6,6 @@ __author__ = 'marcos.medeiros'
 
 from rapid.registry import registry, Action
 from rapid import filters
-import rapidfields
 
 import itertools
 from django.db import models
@@ -169,7 +168,7 @@ class ModelData:
             if f.bare_name() in ignore_fields:
                 ignore_fields.remove(f.bare_name())
                 continue
-            if isinstance(f.field, rapidfields.AlternativeDataTables):
+            if hasattr(f.field, 'is_rapid_alternatives') and f.field.is_rapid_alternatives:
                 for ff in self.rapid_alternative_data():
                     if ff[1].ct_field == f.bare_name():
                         f = FieldData(ff[1])
@@ -211,7 +210,7 @@ class ModelData:
         Those are not returned by fields()
         """
         for k, v in self.model.__dict__.iteritems():
-            if isinstance(v, rapidfields.AlternativeData):
+            if hasattr(v, 'is_rapid_alternatives') and v.is_rapid_alternatives:
                 yield (k, v)
 
     def related_fields(self):