mirror of
https://github.com/jazzband/django-eav2.git
synced 2026-05-02 04:34:50 +00:00
Added sites framework
This commit is contained in:
parent
9cf3b5b9f1
commit
5ccc3f012a
3 changed files with 11 additions and 2 deletions
|
|
@ -16,7 +16,7 @@
|
|||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with EAV-Django. If not, see <http://gnu.org/licenses/>.
|
||||
VERSION = (0, 9, 1)
|
||||
VERSION = (0, 9, 2)
|
||||
|
||||
def get_version():
|
||||
version = "%s.%s" % (VERSION[0], VERSION[1])
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ from django.core.exceptions import ValidationError
|
|||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.contrib.contenttypes import generic
|
||||
from django.contrib.sites.models import Site
|
||||
from django.contrib.sites.managers import CurrentSiteManager
|
||||
from django.conf import settings
|
||||
|
||||
from .validators import *
|
||||
|
|
@ -150,6 +152,7 @@ class Attribute(models.Model):
|
|||
|
||||
class Meta:
|
||||
ordering = ['name']
|
||||
unique_together = ('site', 'slug')
|
||||
|
||||
TYPE_TEXT = 'text'
|
||||
TYPE_FLOAT = 'float'
|
||||
|
|
@ -172,6 +175,9 @@ class Attribute(models.Model):
|
|||
name = models.CharField(_(u"name"), max_length=100,
|
||||
help_text=_(u"User-friendly attribute name"))
|
||||
|
||||
site = models.ForeignKey(Site, verbose_name=_(u"site"),
|
||||
default=Site.objects.get_current)
|
||||
|
||||
slug = EavSlugField(_(u"slug"), max_length=50, db_index=True,
|
||||
help_text=_(u"Short unique attribute label"),
|
||||
primary_key=True)
|
||||
|
|
@ -199,6 +205,9 @@ class Attribute(models.Model):
|
|||
|
||||
required = models.BooleanField(_(u"required"), default=False)
|
||||
|
||||
on_site = CurrentSiteManager()
|
||||
objects = models.Manager()
|
||||
|
||||
def get_validators(self):
|
||||
'''
|
||||
Returns the appropriate validator function from :mod:`~eav.validators`
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class EavConfig(object):
|
|||
By default, all :class:`~eav.models.Attribute` object apply to an
|
||||
entity, unless you provide a custom EavConfig class overriding this.
|
||||
'''
|
||||
return Attribute.objects.all()
|
||||
return Attribute.on_site.all()
|
||||
|
||||
|
||||
class Registry(object):
|
||||
|
|
|
|||
Loading…
Reference in a new issue