Repository: learningequality/kolibri

Issue:
NotImplementedError msg received when saving learner device statuses on full-facility devices
<!--
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
<!--
Description of the behavior that was observed, including screenshots or other references when applicable
-->
A `NotImplementedError` is raised within the class method `save_statuses` for full-facility devices within `LearnerDeviceStatus` modal. Saving a specified status for all learners on the device is only supported for devices provisioned as a `subset_of_users_device`. Therefore, on full facilities, this [piece of code](https://github.com/learningequality/kolibri/blob/4cf6a66db0714f76735d2b695d4291276b7b2d4b/kolibri/core/device/models.py#L467) should not be called at all or the `LearnerDeviceStatus` should be passive and only saved when it is a learner-only device.

## 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
```
-->
```
[python-devserver] Traceback (most recent call last):
[python-devserver]   File "/home/richard/github/kolibri/kolibri/core/tasks/job.py", line 299, in execute
[python-devserver]     result = func(*args, **kwargs)
[python-devserver]   File "/home/richard/github/kolibri/kolibri/core/tasks/registry.py", line 238, in __call__
[python-devserver]     return self.func(*args, **kwargs)
[python-devserver]   File "/home/richard/github/kolibri/kolibri/core/content/tasks.py", line 347, in automatic_resource_import
[python-devserver]     process_content_requests()
[python-devserver]   File "/home/richard/github/kolibri/kolibri/core/content/utils/content_request.py", line 271, in process_content_requests
[python-devserver]     LearnerDeviceStatus.save_statuses(DeviceStatus.InsufficientStorage)
[python-devserver]   File "/home/richard/github/kolibri/kolibri/core/device/models.py", line 470, in save_statuses
[python-devserver]     raise NotImplementedError(
[python-devserver] NotImplementedError: Saving all learner statuses is not supported on full-facility devices
```
## Expected behavior
<!--
Description of what behavior was expected but did not occur
-->
If on a full-facility device, it does not try to save learner statuses and does not raise the `NotImplementedError`. If on a learn-only device, all of the specified learner device statuses are saved on the device.

## User-facing consequences
<!--
Implications and real-world consequences for learners, coaches, admins, and other users of the application
-->
Unnecessary error message raised instead of skipping code. 




Discussion:

Resolving patch:
diff --git a/kolibri/core/device/models.py b/kolibri/core/device/models.py
--- a/kolibri/core/device/models.py
+++ b/kolibri/core/device/models.py
@@ -464,15 +464,11 @@ def save_statuses(cls, status):
         :param status: A status tuple of which to save, see `DeviceStatus`
         :type status: tuple(string, int)
         """
-        if not get_device_setting(
+        if get_device_setting(
             "subset_of_users_device", default=not device_provisioned()
         ):
-            raise NotImplementedError(
-                "Saving all learner statuses is not supported on full-facility devices"
-            )
-
-        for user_id in FacilityUser.objects.all().values_list("id", flat=True):
-            cls.save_learner_status(user_id, status)
+            for user_id in FacilityUser.objects.all().values_list("id", flat=True):
+                cls.save_learner_status(user_id, status)
 
     @classmethod
     def save_learner_status(cls, learner_user_id, status):
@@ -507,15 +503,11 @@ def clear_statuses(cls):
         provisioned as a `subset_of_users_device`
         :return:
         """
-        if not get_device_setting(
+        if get_device_setting(
             "subset_of_users_device", default=not device_provisioned()
         ):
-            raise NotImplementedError(
-                "Saving all learner statuses is not supported on full-facility devices"
-            )
-
-        for user_id in FacilityUser.objects.all().values_list("id", flat=True):
-            cls.clear_learner_status(user_id)
+            for user_id in FacilityUser.objects.all().values_list("id", flat=True):
+                cls.clear_learner_status(user_id)
 
     @classmethod
     def clear_learner_status(cls, learner_user_id):


Test patch:
diff --git a/kolibri/core/device/test/test_models.py b/kolibri/core/device/test/test_models.py
--- a/kolibri/core/device/test/test_models.py
+++ b/kolibri/core/device/test/test_models.py
@@ -139,8 +139,8 @@ def test_clear_learner_status(self):
 
     @mock.patch("kolibri.core.device.models.device_provisioned", return_value=True)
     def test_save_statuses__not_subset_of_users_device(self, _):
-        with self.assertRaises(NotImplementedError):
-            LearnerDeviceStatus.save_statuses(DeviceStatus.InsufficientStorage)
+        LearnerDeviceStatus.save_statuses(DeviceStatus.InsufficientStorage)
+        self.assertEqual(LearnerDeviceStatus.objects.count(), 0)
 
     @mock.patch("kolibri.core.device.models.get_device_setting", return_value=True)
     def test_save_statuses(self, mock_device_setting):