'Returns a mapping of group IDs to a two-tuple of (subscribed: bool,
subscription: GroupSubscription or None) for the provided user and
groups.'

def _get_subscriptions(self, item_list, user):

    results = {group.id: None for group in item_list}
    subscriptions = GroupSubscription.objects.filter(group__in=results.keys(), user=user)
    for subscription in subscriptions:
        results[subscription.group_id] = (subscription.is_active, subscription)
    projects = defaultdict(set)
    for group in item_list:
        if (results[group.id] is None):
            projects[group.project].add(group.id)
    if projects:
        options = {option.project_id: option.value for option in UserOption.objects.filter((Q(project__in=projects.keys()) | Q(project__isnull=True)), user=user, key='workflow:notifications')}
        default = options.get(None, UserOptionValue.all_conversations)
        for (project, group_ids) in projects.items():
            is_subscribed = (options.get(project.id, default) == UserOptionValue.all_conversations)
            for group_id in group_ids:
                results[group_id] = (is_subscribed, None)
    return results
