mirror of
https://github.com/jazzband/django-eav2.git
synced 2026-03-16 22:40:26 +00:00
Add instance parameter to config get_attributes
This commit is contained in:
parent
1f629506a8
commit
9a4c8f3ad3
3 changed files with 6 additions and 4 deletions
|
|
@ -503,7 +503,9 @@ class Entity(object):
|
|||
Return a query set of all :class:`Attribute` objects that can be set
|
||||
for this entity.
|
||||
"""
|
||||
return self.instance._eav_config_cls.get_attributes().order_by('display_order')
|
||||
return self.instance._eav_config_cls.get_attributes(
|
||||
instance=self.instance
|
||||
).order_by('display_order')
|
||||
|
||||
def _hasattr(self, attribute_slug):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class EavConfig(object):
|
|||
generic_relation_related_name = None
|
||||
|
||||
@classmethod
|
||||
def get_attributes(cls):
|
||||
def get_attributes(cls, instance=None):
|
||||
"""
|
||||
By default, all :class:`~eav.models.Attribute` object apply to an
|
||||
entity, unless you provide a custom EavConfig class overriding this.
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class Attributes(TestCase):
|
|||
generic_relation_related_name = 'encounters'
|
||||
|
||||
@classmethod
|
||||
def get_attributes(cls):
|
||||
def get_attributes(cls, instance=None):
|
||||
return Attribute.objects.filter(slug__contains='a')
|
||||
|
||||
eav.register(Encounter, EncounterEavConfig)
|
||||
|
|
@ -76,7 +76,7 @@ class Attributes(TestCase):
|
|||
def test_illegal_assignemnt(self):
|
||||
class EncounterEavConfig(EavConfig):
|
||||
@classmethod
|
||||
def get_attributes(cls):
|
||||
def get_attributes(cls, instance=None):
|
||||
return Attribute.objects.filter(datatype=Attribute.TYPE_INT)
|
||||
|
||||
eav.unregister(Encounter)
|
||||
|
|
|
|||
Loading…
Reference in a new issue