Skip to content

Commit

Permalink
Fixed error with subscriptions and the action to subscribe to
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernesto Perez Amigo committed Oct 23, 2017
1 parent af5e79e commit cf439ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion graphene_django_extras/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .types import DjangoObjectType, DjangoInputObjectType, DjangoListObjectType
from .subscriptions import *

VERSION = (0, 1, 0, 'alpha', '1')
VERSION = (0, 1, 0, 'alpha', '2')

__version__ = get_version(VERSION)

Expand Down
20 changes: 11 additions & 9 deletions graphene_django_extras/subscriptions/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from graphene.utils.str_converters import to_snake_case
from six import string_types

from graphene_django_extras import DjangoSerializerMutation
from ..mutation import DjangoSerializerMutation
from .bindings import SubscriptionResourceBinding


Expand All @@ -34,12 +34,6 @@ class SubscriptionOptions(BaseOptions):
serializer_class = None
queryset = None
mutation_class = None
actions_map = {
'create': 'create',
'update': 'update',
'delete': 'delete',
'all_actions': ['create', 'update', 'delete']
}


class Subscription(ObjectType):
Expand Down Expand Up @@ -132,8 +126,16 @@ def subscription_resolver(cls, root, info, **kwargs):
channel = copy.copy(info.context.reply_channel)
channel.name = u'daphne.response.{}'.format(kwargs.get('channel_id'))

for act in cls._meta.actions_map[action]:
group_name = cls._group_name(act, id=obj_id)
if action == 'all_actions':
for act in ('create', 'update', 'delete'):
group_name = cls._group_name(act, id=obj_id)

if operation == 'subscribe':
Group(group_name).add(channel)
elif operation == 'unsubscribe':
Group(group_name).discard(channel)
else:
group_name = cls._group_name(action, id=obj_id)

if operation == 'subscribe':
Group(group_name).add(channel)
Expand Down

0 comments on commit cf439ef

Please sign in to comment.