Repository: learningequality/kolibri

Issue:
KDP Sync tasks do not display facility name and "retry" button does not work
<!--
Instructions:
 * Fill out the sections below, replace …'s with information about your issue
 * Use the 'preview' function above this text box to verify formatting before submitting
-->

### Observed behavior

Screenshots are from the https://kolibri-beta.learningequality.org/en/device/#/facilities from around this time

The name of the facility is not shown here:

<img width="979" alt="CleanShot 2020-06-22 at 10 17 28@2x" src="https://user-images.githubusercontent.com/10248067/85316953-7034c780-b472-11ea-811b-c721f5ff35da.png">


Because the `facility_name` field is missing from the Task object

<img width="483" alt="CleanShot 2020-06-22 at 10 17 44@2x" src="https://user-images.githubusercontent.com/10248067/85316956-72972180-b472-11ea-9764-4cf999d12870.png">

Also the "retry" button is not triggering a kdp sync task, so there might be something off about the sending the click even from "retry" to here
https://github.com/learningequality/kolibri/blob/fe997ef0bfa150c01f067602b5644bda484bbf27/kolibri/plugins/device/assets/src/views/FacilitiesPage/facilityTasksQueue.js#L60-L77

### Expected behavior

1. For KDP sync tasks, the "facility name" is added to the Task metadata, so it appears on the UI
1. The "retry" button works

### User-facing consequences
<!--
Implications and real-world consequences for learners, coaches, admins, and other users of the application
-->

…

### Errors and logs
<!--
Relevant logs from:
 * the command line
 * ~/.kolibri/logs/kolibri.txt
 * the browser console

Please wrap errors in triple backticks for clean formatting like this:
```
01:10 info: something happened
01:12 error: something bad happened
```
-->

…

### Steps to reproduce
<!--
Precise steps that someone else can follow in order to see this behavior
-->

…

### Context
0.14b3


Discussion:
Facility name might be missing from metadata because the KDP sync task type isn't included in this list here

https://github.com/learningequality/kolibri/blob/c0e59cc470921985a8fde87e7b0a2bcec02f2d6a/kolibri/core/tasks/api.py#L982-L991

Resolving patch:
diff --git a/kolibri/core/tasks/api.py b/kolibri/core/tasks/api.py
--- a/kolibri/core/tasks/api.py
+++ b/kolibri/core/tasks/api.py
@@ -865,11 +865,11 @@ def startdataportalbulksync(self, request):
         """
         responses = []
         facilities = Facility.objects.filter(dataset__registered=True).values_list(
-            "id", flat=True
+            "id", "name"
         )
 
-        for facility_id in facilities:
-            request.data.update(facility=facility_id)
+        for id, name in facilities:
+            request.data.update(facility=id, facility_name=name)
             responses.append(self.startdataportalsync(request).data)
 
         return Response(responses)
@@ -988,6 +988,10 @@ def prepare_sync_task(request, **kwargs):
             baseurl=request.data.get("baseurl", ""),
         )
         task_data.update(extra_task_data)
+    elif task_type == "SYNCDATAPORTAL":
+        # Extra metadata that can be passed from the client
+        extra_task_data = dict(facility_name=request.data.get("facility_name", ""))
+        task_data.update(extra_task_data)
 
     task_data.update(kwargs)
     return task_data


Test patch:
diff --git a/kolibri/core/tasks/test/test_api.py b/kolibri/core/tasks/test/test_api.py
--- a/kolibri/core/tasks/test/test_api.py
+++ b/kolibri/core/tasks/test/test_api.py
@@ -180,7 +180,7 @@ def test_startdataportalsync(self, facility_queue):
 
         response = self.client.post(
             reverse("kolibri:core:facilitytask-startdataportalsync"),
-            {"facility": self.facility.id},
+            {"facility": self.facility.id, "facility_name": "my facility name"},
             format="json",
         )
         self.assertEqual(response.status_code, 200)
@@ -194,6 +194,7 @@ def test_startdataportalsync(self, facility_queue):
             noninteractive=True,
             extra_metadata=dict(
                 facility=self.facility.id,
+                facility_name="my facility name",
                 started_by=user.pk,
                 started_by_username=user.username,
                 sync_state="PENDING",
@@ -238,6 +239,7 @@ def test_startdataportalbulksync(self, facility_queue):
                     noninteractive=True,
                     extra_metadata=dict(
                         facility=facility2.id,
+                        facility_name="facility 2",
                         started_by=user.pk,
                         started_by_username=user.username,
                         sync_state="PENDING",
@@ -256,6 +258,7 @@ def test_startdataportalbulksync(self, facility_queue):
                     noninteractive=True,
                     extra_metadata=dict(
                         facility=facility3.id,
+                        facility_name="facility 3",
                         started_by=user.pk,
                         started_by_username=user.username,
                         sync_state="PENDING",