jgsogo avatar 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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.