Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django 1.9 #34

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions eav/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def get_version():
__version__ = get_version()

def register(model_cls, config_cls=None):
from registry import Registry
from .registry import Registry
Registry.register(model_cls, config_cls)

def unregister(model_cls):
from registry import Registry
from .registry import Registry
Registry.unregister(model_cls)
4 changes: 2 additions & 2 deletions eav/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ def create(self, **kwargs):

new_kwargs = {}
eav_kwargs = {}
for key, value in kwargs.iteritems():
for key, value in kwargs.items():
if key.startswith(prefix):
eav_kwargs.update({key[len(prefix):]: value})
else:
new_kwargs.update({key: value})

obj = self.model(**new_kwargs)
obj_eav = getattr(obj, config_cls.eav_attr)
for key, value in eav_kwargs.iteritems():
for key, value in eav_kwargs.items():
setattr(obj_eav, key, value)
obj.save()
return obj
Expand Down
8 changes: 4 additions & 4 deletions eav/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
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.contenttypes.fields import GenericForeignKey
from django.contrib.sites.models import Site
from django.contrib.sites.managers import CurrentSiteManager
from django.conf import settings
Expand Down Expand Up @@ -177,7 +177,7 @@ class Meta:
help_text=_(u"User-friendly attribute name"))

site = models.ForeignKey(Site, verbose_name=_(u"site"),
default=Site.objects.get_current)
default=settings.SITE_ID)

slug = EavSlugField(_(u"slug"), max_length=50, db_index=True,
help_text=_(u"Short unique attribute label"))
Expand Down Expand Up @@ -337,7 +337,7 @@ class Value(models.Model):

entity_ct = models.ForeignKey(ContentType, related_name='value_entities')
entity_id = models.IntegerField()
entity = generic.GenericForeignKey(ct_field='entity_ct',
entity = GenericForeignKey(ct_field='entity_ct',
fk_field='entity_id')

value_text = models.TextField(blank=True, null=True)
Expand All @@ -351,7 +351,7 @@ class Value(models.Model):
generic_value_id = models.IntegerField(blank=True, null=True)
generic_value_ct = models.ForeignKey(ContentType, blank=True, null=True,
related_name='value_values')
value_object = generic.GenericForeignKey(ct_field='generic_value_ct',
value_object = GenericForeignKey(ct_field='generic_value_ct',
fk_field='generic_value_id')

created = models.DateTimeField(_(u"created"), default=datetime.now)
Expand Down
4 changes: 2 additions & 2 deletions eav/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

from django.db.utils import DatabaseError
from django.db.models.signals import pre_init, post_init, pre_save, post_save
from django.contrib.contenttypes import generic
from django.contrib.contenttypes.fields import GenericRelation

from .managers import EntityManager
from .models import Entity, Attribute, Value
Expand Down Expand Up @@ -163,7 +163,7 @@ def _attach_generic_relation(self):

gr_name = self.config_cls.generic_relation_attr.lower()
generic_relation = \
generic.GenericRelation(Value,
GenericRelation(Value,
object_id_field='entity_id',
content_type_field='entity_ct',
related_query_name=rel_name)
Expand Down