def create_user_task(sender=None, body=None, **kwargs):  # pylint: disable=unused-argument
    """
    Create a :py:class:`UserTaskStatus` record for each :py:class:`UserTaskMixin`.

    Also creates a :py:class:`UserTaskStatus` for each chain, chord, or group containing
    the new :py:class:`UserTaskMixin`.
    """
    try:
        task_class = import_string(sender)
    except ImportError:
        return
    if issubclass(task_class.__class__, UserTaskMixin):
        arguments_dict = task_class.arguments_as_dict(*body['args'], **body['kwargs'])
        user_id = _get_user_id(arguments_dict)
        task_id = body['id']
        if body.get('callbacks', []):
            return _create_chain_entry(user_id, task_id, task_class, body['args'], body['kwargs'], body['callbacks'])
        if body.get('chord', None):
            return _create_chord_entry(task_id, task_class, body, user_id)
        parent = _get_or_create_group_parent(body, user_id)
        name = task_class.generate_name(arguments_dict)
        total_steps = task_class.calculate_total_steps(arguments_dict)
        UserTaskStatus.objects.get_or_create(
            task_id=task_id, defaults={'user_id': user_id, 'parent': parent, 'name': name, 'task_class': sender,
                                       'total_steps': total_steps})
        if parent:
            parent.increment_total_steps(total_steps)
def create_user_task ( sender = None , body = None , ** kwargs ) : try : task_class = import_string ( sender ) except ImportError : return if issubclass ( task_class . __class__ , UserTaskMixin ) : arguments_dict = task_class . arguments_as_dict ( * body [ 'args' ] , ** body [ 'kwargs' ] ) user_id = _get_user_id ( arguments_dict ) task_id = body [ 'id' ] if body . get ( 'callbacks' , [ ] ) : return _create_chain_entry ( user_id , task_id , task_class , body [ 'args' ] , body [ 'kwargs' ] , body [ 'callbacks' ] ) if body . get ( 'chord' , None ) : return _create_chord_entry ( task_id , task_class , body , user_id ) parent = _get_or_create_group_parent ( body , user_id ) name = task_class . generate_name ( arguments_dict ) total_steps = task_class . calculate_total_steps ( arguments_dict ) UserTaskStatus . objects . get_or_create ( task_id = task_id , defaults = { 'user_id' : user_id , 'parent' : parent , 'name' : name , 'task_class' : sender , 'total_steps' : total_steps } ) if parent : parent . increment_total_steps ( total_steps )
Create a :py:class:`UserTaskStatus` record for each :py:class:`UserTaskMixin`.

    Also creates a :py:class:`UserTaskStatus` for each chain, chord, or group containing
    the new :py:class:`UserTaskMixin`.