Commits

jgsogo committed c2e8e17 Draft

added policy_nopolicy, todo más claro

Comments (0)

Files changed (3)

taxonomy/models/taxon.py

 from mptt.models import MPTTModel, TreeForeignKey
 
 from taxonomy.settings import BASETAXON_MIXIN, TAXONRANK_SEPARATOR, TAXONOMY_SITES_POLICY, TAXONOMY_RANKED
-from taxonomy.utils import load_class, get_basemodel_mixin
+from taxonomy.utils import load_class, get_basemodel_mixin, get_site_policy_model_mixin
 from taxonomy.models.taxonrank import TaxonRank
 
-SITE_POLICY_MODEL_MIXIN = models.Model
-if TAXONOMY_SITES_POLICY:
-    from django.conf import settings
-    from django.contrib.sites.models import Site
-    from taxonomy.utils import get_site_policy_model_mixin
-    SITE_POLICY_MODEL_MIXIN = get_site_policy_model_mixin(TAXONOMY_SITES_POLICY)
+SITE_POLICY_MODEL_MIXIN = get_site_policy_model_mixin(TAXONOMY_SITES_POLICY)
+
 
 class BaseTaxon(MPTTModel, SITE_POLICY_MODEL_MIXIN):
     #name = models.CharField(max_length=255)

taxonomy/models/taxonrank.py

 from django.utils.translation import ugettext_lazy as _
 
 from taxonomy.settings import BASETAXONRANK_MIXIN, TAXONOMY_SITES_POLICY
-from taxonomy.utils import load_class, get_basemodel_mixin
+from taxonomy.utils import load_class, get_basemodel_mixin, get_site_policy_model_mixin
 from taxonomy.managers import TaxonRankManager
 from taxonomy.exceptions import TaxonRankUpperMost, TaxonRankLowerMost
 
-SITE_POLICY_MODEL_MIXIN = models.Model
-if TAXONOMY_SITES_POLICY:
-    from django.conf import settings
-    from django.contrib.sites.models import Site
-    from taxonomy.utils import get_site_policy_model_mixin
-    SITE_POLICY_MODEL_MIXIN = get_site_policy_model_mixin(TAXONOMY_SITES_POLICY)
-
+SITE_POLICY_MODEL_MIXIN = get_site_policy_model_mixin(TAXONOMY_SITES_POLICY)
 
 class BaseTaxonRank(SITE_POLICY_MODEL_MIXIN):
     rank = models.PositiveIntegerField()

taxonomy/utils/site_policy.py

             self.sites.add(current_site)
 
 
+class NoSitePolicy(models.Model):
+    class Meta:
+        abstract = True
+
+    def save(self, ref_obj=None, *args, **kwargs):
+        super(NoSitePolicy, self).save(*args, **kwargs)
 
 
 def get_site_policy_model_mixin(site_policy):
     if site_policy == SITE_POLICY.M2M:
         return M2MSitePolicy
+    elif site_policy == SITE_POLICY.FK:
+        return FKSitePolicy
     else:
-        return FKSitePolicy
+        return NoSitePolicy