Repository: learningequality/kolibri
Issue: On Windows, importing or exporting a large number of items (~1000) can fail

<!--
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
When trying to download content i get a transfer failed error.  First channel downloaded in bulk ok but cannot download further channelsin bulk. If i go in and download sub categories i can eventually pull down the whole channel

### Expected behavior
<!--
Description of what behavior was expected but did not occur
-->

channel downloads as a whole not 1 by 1 resource sub sets


### Errors and logs
<!--
Relevant logs from:
 * the command line
 * ~/.kolibri/kolibri.log
 * 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
```
-->

```
[33mWARNING  Job d416c174faeb4648b22bd1420a75f2a0 raised an exception: Traceback (most recent call last):
  File "c:\\python27\\lib\\site-packages\\kolibri\\dist\\iceqube\\worker\\backends\\inmem.py", line 75, in handle_finished_future
    result = future.result()
  File "c:\\python27\\lib\\site-packages\\kolibri\\dist\\concurrent\\futures\\_base.py", line 455, in result
    return self.__get_result()
  File "c:\\python27\\lib\\site-packages\\kolibri\\dist\\concurrent\\futures\\thread.py", line 63, in run
    result = self.fn(*self.args, **self.kwargs)
  File "c:\\python27\\lib\\site-packages\\kolibri\\dist\\iceqube\\worker\\backends\\inmem.py", line 149, in wrap
    raise e
OperationalError: too many SQL variables
[0m
WARNING:iceqube.worker.backends.base:Job d416c174faeb4648b22bd1420a75f2a0 raised an exception: Traceback (most recent call last):
  File "c:\\python27\\lib\\site-packages\\kolibri\\dist\\iceqube\\worker\\backends\\inmem.py", line 75, in handle_finished_future
    result = future.result()
  File "c:\\python27\\lib\\site-packages\\kolibri\\dist\\concurrent\\futures\\_base.py", line 455, in result
    return self.__get_result()
  File "c:\\python27\\lib\\site-packages\\kolibri\\dist\\concurrent\\futures\\thread.py", line 63, in run
    result = self.fn(*self.args, **self.kwargs)
  File "c:\\python27\\lib\\site-packages\\kolibri\\dist\\iceqube\\worker\\backends\\inmem.py", line 149, in wrap
    raise e
OperationalError: too many SQL variables
```


### Context
<!--
Tell us about your environment, including:
 * Kolibri version
 * Operating system
 * Browser
-->

win 10 running kolibri 0.7.0.  all browsers.



Changed files:
kolibri/content/utils/import_export_content.py

diff --git a/kolibri/content/utils/import_export_content.py b/kolibri/content/utils/import_export_content.py
index 1190d1d3e6..4e17a043c6 100644
--- a/kolibri/content/utils/import_export_content.py
+++ b/kolibri/content/utils/import_export_content.py
@@ -1,16 +1,16 @@
 from django.db.models import Sum
-from kolibri.content.models import LocalFile, ContentNode
+from kolibri.content.models import ContentNode, LocalFile
 
 
 def get_files_to_transfer(channel_id, node_ids, exclude_node_ids, available):
     files_to_transfer = LocalFile.objects.filter(files__contentnode__channel_id=channel_id, available=available)
 
     if node_ids:
-        leaf_node_ids = _get_leaves_ids(node_ids)
+        leaf_node_ids = _get_leaf_node_ids(node_ids)
         files_to_transfer = files_to_transfer.filter(files__contentnode__in=leaf_node_ids)
 
     if exclude_node_ids:
-        exclude_leaf_node_ids = _get_leaves_ids(exclude_node_ids)
+        exclude_leaf_node_ids = _get_leaf_node_ids(exclude_node_ids)
         files_to_transfer = files_to_transfer.exclude(files__contentnode__in=exclude_leaf_node_ids)
 
     # Make sure the files are unique, to avoid duplicating downloads
@@ -21,12 +21,10 @@ def get_files_to_transfer(channel_id, node_ids, exclude_node_ids, available):
     return files_to_transfer, total_bytes_to_transfer
 
 
-def _get_leaves_ids(node_ids):
-    leaf_node_ids = []
-    for node_id in node_ids:
-        node_leaves = ContentNode.objects.get(pk=node_id) \\
-            .get_descendants(include_self=True) \\
-            .filter(children__isnull=True) \\
-            .values_list('id', flat=True)
-        leaf_node_ids += node_leaves
-    return leaf_node_ids
+def _get_leaf_node_ids(node_ids):
+
+    return ContentNode.objects \\
+        .filter(pk__in=node_ids) \\
+        .get_descendants(include_self=True) \\
+        .filter(children__isnull=True) \\
+        .values_list('id', flat=True)