fixed usage of group_names in *_change_receiver (#306)

* fixed usage of group_names in *_change_receiver

group_names was missing second arg (action)

* fixed group_names to include action

* made group_names a classmethod
This commit is contained in:
AlexejStukov 2016-08-23 19:13:46 +02:00 committed by Andrew Godwin
parent 6649afce8e
commit fcb2875b53
2 changed files with 7 additions and 6 deletions

View File

@ -140,7 +140,7 @@ class Binding(object):
if action == CREATE:
group_names = set()
else:
group_names = set(cls.group_names(instance))
group_names = set(cls.group_names(instance, action))
if not hasattr(instance, '_binding_group_names'):
instance._binding_group_names = {}
@ -155,7 +155,7 @@ class Binding(object):
if action == DELETE:
new_group_names = set()
else:
new_group_names = set(cls.group_names(instance))
new_group_names = set(cls.group_names(instance, action))
# if post delete, new_group_names should be []
self = cls()
@ -182,7 +182,8 @@ class Binding(object):
group = Group(group_name)
group.send(message)
def group_names(self, instance, action):
@classmethod
def group_names(cls, instance, action):
"""
Returns the iterable of group names to send the object to based on the
instance and action performed on it.

View File

@ -18,7 +18,7 @@ class TestsBinding(ChannelTestCase):
fields = ['username', 'email', 'password', 'last_name']
@classmethod
def group_names(cls, instance):
def group_names(cls, instance, action):
return ["users"]
def has_permission(self, user, action, pk):
@ -60,7 +60,7 @@ class TestsBinding(ChannelTestCase):
fields = ['__all__']
@classmethod
def group_names(cls, instance):
def group_names(cls, instance, action):
return ["users2"]
def has_permission(self, user, action, pk):
@ -105,7 +105,7 @@ class TestsBinding(ChannelTestCase):
fields = ['username']
@classmethod
def group_names(cls, instance):
def group_names(cls, instance, action):
return ["users3"]
def has_permission(self, user, action, pk):