diff --git a/channels/binding/base.py b/channels/binding/base.py index 902b56e..a1f1977 100644 --- a/channels/binding/base.py +++ b/channels/binding/base.py @@ -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. diff --git a/channels/tests/test_binding.py b/channels/tests/test_binding.py index dca1092..aaf88aa 100644 --- a/channels/tests/test_binding.py +++ b/channels/tests/test_binding.py @@ -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):