Skip to content

Commit

Permalink
CM-403: adjust backend to handle individual and group tasks (#39)
Browse files Browse the repository at this point in the history
* CM-404: update handle change head

* CM-403: add task logic to GroupIndividual update

* CM-405: block more than one tasks

---------

Co-authored-by: Jan <[email protected]>
  • Loading branch information
jdolkowski and Jan authored Jan 8, 2024
1 parent f6000aa commit b1700a8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
25 changes: 16 additions & 9 deletions individual/gql_mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def _mutate(cls, user, **data):
data.pop('client_mutation_label')

service = IndividualService(user)
service.create(data)
result = service.create(data)
return result if not result['success'] else None

class Input(CreateIndividualInputType):
pass
Expand Down Expand Up @@ -93,9 +94,10 @@ def _mutate(cls, user, **data):

service = IndividualService(user)
if IndividualConfig.gql_check_individual_update:
service.create_update_task(data)
result = service.create_update_task(data)
else:
service.update(data)
result = service.update(data)
return result if not result['success'] else None

class Input(UpdateIndividualInputType):
pass
Expand Down Expand Up @@ -150,7 +152,8 @@ def _mutate(cls, user, **data):
data.pop('client_mutation_label')

service = GroupService(user)
service.create(data)
result = service.create(data)
return result if not result['success'] else None

class Input(CreateGroupInputType):
pass
Expand Down Expand Up @@ -178,7 +181,8 @@ def _mutate(cls, user, **data):
data.pop('client_mutation_label')

service = GroupService(user)
service.update(data)
result = service.update(data)
return result if not result['success'] else None

class Input(UpdateGroupInputType):
pass
Expand Down Expand Up @@ -233,7 +237,8 @@ def _mutate(cls, user, **data):
data.pop('client_mutation_label')

service = GroupIndividualService(user)
service.create(data)
result = service.create(data)
return result if not result['success'] else None

class Input(CreateGroupIndividualInputType):
pass
Expand Down Expand Up @@ -262,9 +267,10 @@ def _mutate(cls, user, **data):

service = GroupIndividualService(user)
if IndividualConfig.gql_check_group_individual_update:
service.create_update_task(data)
result = service.create_update_task(data)
else:
service.update(data)
result = service.update(data)
return result if not result['success'] else None

class Input(UpdateGroupIndividualInputType):
pass
Expand Down Expand Up @@ -319,7 +325,8 @@ def _mutate(cls, user, **data):
data.pop('client_mutation_label')

service = GroupService(user)
service.create_group_individuals(data)
result = service.create_group_individuals(data)
return result if not result['success'] else None

class Input(CreateGroupInputType):
individual_ids = graphene.List(graphene.UUID)
22 changes: 22 additions & 0 deletions individual/signals/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import logging

from core.service_signals import ServiceSignalBindType
from core.signals import bind_service_signal
from individual.services import GroupIndividualService, IndividualService

from tasks_management.services import on_task_complete_service_handler

logger = logging.getLogger(__name__)


def bind_service_signals():
bind_service_signal(
'task_service.complete_task',
on_task_complete_service_handler(GroupIndividualService),
bind_type=ServiceSignalBindType.AFTER
)
bind_service_signal(
'task_service.complete_task',
on_task_complete_service_handler(IndividualService),
bind_type=ServiceSignalBindType.AFTER
)

0 comments on commit b1700a8

Please sign in to comment.