Repository: learningequality/kolibri

Issue:
Select all not working in groups
### Observed behavior
In the coach tab, while enrolling learners in the group first select single user and then select select all option and then enroll. It will enroll only one user in the group.

### Expected behavior
When we select select all, it must enroll all users in the group.

### Steps to reproduce
1. Create the group.
2. Select one user while enrolling.
3. Then select select all in groups.
4. Click on enroll.
5. It will enroll only one user in the group.

### Context
 * Kolibri version : Kolibri 0.12.2
 * Operating system : Ubuntu 14.04
 * Browser : Chrome

### Screenshots
![1](https://user-images.githubusercontent.com/12776071/55711874-4200ce80-5a0b-11e9-942d-2cd54cbc4db4.png)
![2](https://user-images.githubusercontent.com/12776071/55711898-51801780-5a0b-11e9-8f78-c63ceb2b808d.png)
![3](https://user-images.githubusercontent.com/12776071/55711909-56dd6200-5a0b-11e9-8f7c-98a9485c59bb.png)
![4](https://user-images.githubusercontent.com/12776071/55711911-56dd6200-5a0b-11e9-83f8-b9214743fa2a.png)
![5](https://user-images.githubusercontent.com/12776071/55711912-56dd6200-5a0b-11e9-94f1-4b727225dbda.png)




Discussion:
This looks like the same problem in #5321, which was fixed using the technique in #5322, but only for the Facility > Learner/Coach Enrollment page.

To fix this for Groups, you must also make sure a Set of IDs is sent to the Membership API. Checking one checkbox, then select-all will result in having the first checkbox duplicated in the POST request.

Resolving patch:
diff --git a/kolibri/core/logger/api.py b/kolibri/core/logger/api.py
--- a/kolibri/core/logger/api.py
+++ b/kolibri/core/logger/api.py
@@ -1,12 +1,17 @@
+import logging
+
 from django.core.exceptions import ObjectDoesNotExist
 from django.db.models.query import F
+from django.db.utils import IntegrityError
 from django.http import Http404
 from django_filters import ModelChoiceFilter
 from django_filters.rest_framework import CharFilter
 from django_filters.rest_framework import DjangoFilterBackend
 from django_filters.rest_framework import FilterSet
 from rest_framework import filters
+from rest_framework import status
 from rest_framework import viewsets
+from rest_framework.exceptions import ValidationError
 from rest_framework.response import Response
 
 from .models import AttemptLog
@@ -36,6 +41,8 @@
 from kolibri.core.content.api import OptionalPageNumberPagination
 from kolibri.core.exams.models import Exam
 
+logger = logging.getLogger(__name__)
+
 
 class BaseLogFilter(FilterSet):
     facility = ModelChoiceFilter(
@@ -98,6 +105,21 @@ def update(self, request, *args, **kwargs):
                 default_response[field] = method(instance)
         return Response(default_response)
 
+    def create(self, request, *args, **kwargs):
+        try:
+            return super(LoggerViewSet, self).create(request, *args, **kwargs)
+        except IntegrityError:
+            # The object has been created previously: let's calculate its id and return it
+            serializer = self.get_serializer(data=request.data)
+            serializer.is_valid(raise_exception=True)
+            obj = serializer.Meta.model(**serializer.validated_data)
+            obj.id = obj.calculate_uuid()
+            final_obj = self.get_serializer(obj)
+            return Response(final_obj.data)
+        except ValidationError as e:
+            logger.error("Failed to validate data: {}".format(e))
+            return Response(request.data, status.HTTP_400_BAD_REQUEST)
+
 
 class ContentSessionLogFilter(BaseLogFilter):
     class Meta:


Test patch: