Repository: learningequality/kolibri

Issue:
icon alignment issue in mac app

### Observed behavior

super admin icon not aligned: 

![image](https://user-images.githubusercontent.com/2367265/71264379-d5a7d000-22f8-11ea-80c6-b43a33f0300f.png)


### Expected behavior

properly aligned icon

### Steps to reproduce

edit super admin permissions on mac app

### Context

0.13.0 beta 7



Discussion:

Resolving patch:
diff --git a/kolibri/core/auth/models.py b/kolibri/core/auth/models.py
--- a/kolibri/core/auth/models.py
+++ b/kolibri/core/auth/models.py
@@ -34,6 +34,7 @@
 from django.core.exceptions import ValidationError
 from django.db import models
 from django.db.models.query import F
+from django.db.models.query import Q
 from django.db.utils import IntegrityError
 from django.utils.encoding import python_2_unicode_compatible
 from morango.models import Certificate
@@ -664,6 +665,26 @@ def validate_birth_year(value):
         raise ValidationError(error)
 
 
+class FacilityUserRoleBasedPermissionsForCoach(RoleBasedPermissions):
+    def readable_by_user_filter(self, user, queryset):
+        if user.is_anonymous():
+            return queryset.none()
+        roles = user.roles.filter(kind__in=self.can_be_read_by)
+
+        if not roles:
+            return queryset.none()
+
+        filter = Q()
+
+        for role in roles:
+            filter |= Q(
+                Q(memberships__collection_id=role.collection_id)
+                | Q(facility_id=role.collection_id)
+            )
+
+        return queryset.filter(filter)
+
+
 @python_2_unicode_compatible
 class FacilityUser(KolibriAbstractBaseUser, AbstractFacilityDataModel):
     """
@@ -679,7 +700,7 @@ class FacilityUser(KolibriAbstractBaseUser, AbstractFacilityDataModel):
     # FacilityUser can be read and written by a facility admin
     admin = IsAdminForOwnFacility()
     # FacilityUser can be read by admin or coach, and updated by admin, but not created/deleted by non-facility admin
-    role = RoleBasedPermissions(
+    role = FacilityUserRoleBasedPermissionsForCoach(
         target_field=".",
         can_be_created_by=(),  # we can't check creation permissions by role, as user doesn't exist yet
         can_be_read_by=(role_kinds.ADMIN, role_kinds.COACH),
diff --git a/packages/kolibri-tools/lib/i18n/fonts.py b/packages/kolibri-tools/lib/i18n/fonts.py
--- a/packages/kolibri-tools/lib/i18n/fonts.py
+++ b/packages/kolibri-tools/lib/i18n/fonts.py
@@ -44,6 +44,11 @@
 )
 
 
+# Sets the source date epoch to 1/1/21 to prevent temporary files from
+# getting different headers on each run, leading to non-glyph-related changes to
+# their base64 encoding
+# ref: https://github.com/fonttools/fonttools/issues/1135
+os.environ["SOURCE_DATE_EPOCH"] = "1609459200000"
 FONT_TOOLS_OPTIONS = subset.Options()
 FONT_TOOLS_OPTIONS.flavor = "woff"  # most widely supported format
 FONT_TOOLS_OPTIONS.ignore_missing_unicodes = True  # important for subsetting


Test patch:
diff --git a/integration_testing/features/app-context/ORDER.txt b/integration_testing/features/app-context/ORDER.txt
--- a/integration_testing/features/app-context/ORDER.txt
+++ b/integration_testing/features/app-context/ORDER.txt
@@ -3,3 +3,4 @@ app-context-manage-sign-in-options.feature
 app-context-create-account.feature
 app-context-remote-network-access.feature
 app-context-disable-device-network-access.feature
+app-context-content-download.feature
diff --git a/integration_testing/features/app-context/app-context-content-download.feature b/integration_testing/features/app-context/app-context-content-download.feature
new file mode 100644
--- /dev/null
+++ b/integration_testing/features/app-context/app-context-content-download.feature
@@ -0,0 +1,15 @@
+Feature: Learner does not see the 'download' resource button
+
+  Background:
+    Given that Kolibri is running in app context
+      And the *Show 'download' button with resources* option at *Facility > Settings* page is disabled
+
+  Scenario: Lesson content download
+     When I go to *Learn > Classes > Lesson* page
+      And I open a lesson
+    Then I don't see the *Download resource* button
+
+  Scenario: Channel content download
+    When I go to *Learn > Channels* page
+      And I browse any channel's topics until I open an single resource
+    Then I don't see the *Download resource* button
diff --git a/integration_testing/features/coach/coach-class-home.feature b/integration_testing/features/coach/coach-class-home.feature
--- a/integration_testing/features/coach/coach-class-home.feature
+++ b/integration_testing/features/coach/coach-class-home.feature
@@ -16,25 +16,16 @@ Feature: General navigation on *Class home* tab
     Given there are no created quizzes
     When I look at the *Quizzes* block
     Then I see no quizzes
-    #  When I click *View all*
-    #  Then I am on *Coach '<class>' > Reports > Quizzes* subtab
-    #    And I see no quizzes
 
   Scenario: There are no lessons
     Given there are no created lessons
     When I look at the *Lessons* block
     Then I see no lessons
-    #  When I click *View all*
-    #  Then I am on *Coach '<class>' > Reports > Lessons* subtab
-    #    And I see no lessons
 
   Scenario: There has been no activity in the class
     Given that there has not been any learner engagement in the class
     When I look at the *Class activity* block
     Then I see *No activity in your class* notification
-    #  When I click *View all*
-    #  Then I am on an empty *Class activity* page
-    #    And I see *No activity in your class* notification
 
   Scenario: No coaches assigned to class
     Given I am facility coach
diff --git a/integration_testing/features/coach/coach-create-lesson.feature b/integration_testing/features/coach/coach-create-lesson.feature
--- a/integration_testing/features/coach/coach-create-lesson.feature
+++ b/integration_testing/features/coach/coach-create-lesson.feature
@@ -103,7 +103,7 @@ Feature: Coach creates lessons
     Given that there are results from the previous search
     When I press the *X* button in the search field
       Or I delete the previous search term and press *Enter*
-    Then I see the list of all *Channels* under *Select topics or exercises* again
+    Then I still see the previous search results (no change)
 
   Scenario: Add resources from the search results page
     Given I am on the search results page
diff --git a/integration_testing/features/coach/coach-create-quiz.feature b/integration_testing/features/coach/coach-create-quiz.feature
--- a/integration_testing/features/coach/coach-create-quiz.feature
+++ b/integration_testing/features/coach/coach-create-quiz.feature
@@ -12,13 +12,13 @@ Feature: Coach creates quizzes
       And I see a list of channels that contain exercises
         But I don't see any checkboxes
 
-  # Given there are no channels that have exercises
-  # Then there should not be any channels available to select
+    # Given there are no channels that have exercises
+    # Then there should not be any channels available to select
   Scenario: Try and fail to create new quiz when no channel on device contains exercises
     When I click the *New quiz* button
     Then I see a new *Create new quiz* page
       And I see empty *Title* and *Number of questions* fields
-      But I don't see any channels
+        But I don't see any channels
 
   Scenario: Check validation for the number of questions field
     When I input a number outside the range of 1-50
@@ -104,7 +104,7 @@ Feature: Coach creates quizzes
     Given that there are results from the previous search
     When I press the *X* button in the search field
       Or I delete the previous search term and press *Enter*
-    Then I see the list of all *Channels* with exercises under *Select topics or exercises* again
+    Then I still see the previous search results (no change)
 
   Scenario: Add a topic or exercise from the search results page
     Given I am on the search results page
@@ -221,8 +221,8 @@ Feature: Coach creates quizzes
       But I did not save the quiz
     When I click the *back arrow* button
     Then I am redirected to the *Coach - '<class>' > Plan > Quizzes* page
-      And I loose all quiz creation progress
+    And I loose all quiz creation progress
 
 Examples:
-  | quiz          | number_of_question | exercises_questions | channel                | topic               |
-  | First Quarter | 5                  | Mathématiques       | Khan Academy (English) | Recognize fractions |
+    | quiz          | number_of_question | exercises_questions | channel                | topic               |
+    | First Quarter | 5                  | Mathématiques       | Khan Academy (English) | Recognize fractions |
diff --git a/integration_testing/features/guest/guest-find-content-item.feature b/integration_testing/features/guest/guest-find-content-item.feature
--- a/integration_testing/features/guest/guest-find-content-item.feature
+++ b/integration_testing/features/guest/guest-find-content-item.feature
@@ -1,54 +1,55 @@
 Feature: Guest finds content item
-  Guest needs to be able to search and find content items using the search bar
+	Guest needs to be able to search and find content items using the search bar
 
-  Background:
-    Given I am on Kolibri sign in page
-      And I click *Continue as guest* button
-      And there is a channel <channel> imported on the device
-      And I am on *Learn > Channels* or *Learn > Recommended* page
+	Background:
+		Given I am on Kolibri sign in page
+			And I click *Continue as guest* button
+			And there is a channel <channel> imported on the device
+			And I am on *Learn > Channels* or *Learn > Recommended* page
 
-  Scenario: Find a specific content item using the search bar
-    When I enter the <search_term> in the search field
-     And I press the Enter key or click the search icon button
-    Then I see the *Search > N results for '<search_term>'* page
+	Scenario: Find a specific content item using the search bar
+		When I enter the <search_term> in the search field
+			And I press the Enter key or click the search icon button
+		Then I see the *Search > N results for '<search_term>'* page
+			And I see the search results for <search_term>
 
-  Scenario: Clear the previous search
-    Given that I've written something in the search field
-      When I use the TAB key to focus the *Clear* button
-        And I press ENTER
-          Or I click/tap the *Clear* button directly
-      Then I see the search field is empty
-        But I can still see the results of the previous search
+	Scenario: Clear the previous search
+		Given that I've written something in the search field
+			When I use the TAB key to focus the *Clear* button
+				And I press ENTER
+					Or I click/tap the *Clear* button directly
+			Then I see the search field is empty
+				But I can still see the results of the previous search
 
-  Scenario: Filter search results
-    When I open the *Type* filter and select a type
-    Then I see the results are filtered
-      And I see the *M results for '<search_term>'*
-    When I open the *Channels* filter and select a channel
-    Then I see the results are filtered even more
-      And I see the *Q results for '<search_term>'*
-    When I click the *X* (clear) button
-    Then the search field is empty
-      And I can write the new search term
-        But I can still see the results of the previous search
+	Scenario: Filter search results
+		When I open the *Type* filter and select a type
+		Then I see the results are filtered
+			And I see the *M results for '<search_term>'*
+		When I open the *Channels* filter and select a channel
+		Then I see the results are filtered even more
+			And I see the *Q results for '<search_term>'*
+		When I click the *X* (clear) button
+		Then the search field is empty
+			And I can write the new search term
+				But I can still see the results of the previous search
 
-  Scenario: Browse locations for the multiple search results
-    Given there is a search result item that is present in various channels and/or locations
-      When I click the *N locations* link on one of the items
-      Then I see the *Locations* modal
-        And I see the list of links to N locations where the search result item is present
-      When I click one of the links
-      Then I see the *Search > '<content item>'> page
-      When I click *back* arrow button in the left upper corner
-      Then I see the results of the previous search
-      When I click the *N locations* link on one of the items
-      Then I see the *Locations* modal again
-      When I click *Close*
-      Then the modal closes
-        And I see the results of the previous search
-    Then the modal closes
+	Scenario: Browse locations for the multiple search results
+		Given there is a search result item that is present in various channels and/or locations
+			When I click the *N locations* link on one of the items
+			Then I see the *Locations* modal
+				And I see the list of links to N locations where the search result item is present
+			When I click one of the links
+			Then I see the *Search > '<content item>'> page
+			When I click *back* arrow button in the left upper corner
+			Then I see the results of the previous search
+			When I click the *N locations* link on one of the items
+			Then I see the *Locations* modal again
+			When I click *Close*
+			Then the modal closes
+				And I see the results of the previous search
+			Then the modal closes
 
 
 Examples:
-  | search_term |
-  | cosine      |
+	| search_term |
+	| cosine      |
diff --git a/integration_testing/features/learner/learner-engage-content-channels.feature b/integration_testing/features/learner/learner-engage-content-channels.feature
--- a/integration_testing/features/learner/learner-engage-content-channels.feature
+++ b/integration_testing/features/learner/learner-engage-content-channels.feature
@@ -33,6 +33,18 @@ Feature: Learner engages content channels
     When I click on the *Channels* part of the breadcrumb above the player
     Then I can see and browse the rest of the channels on *Learn > Channels* page
 
+    Scenario: Lesson content download
+      Given a super admin has enabled the *Show 'download' button with resources* option at *Facility > Settings* page
+      When I go to *Learn > Classes > Lesson* page
+        And I open a lesson
+      Then I see the *Download resource* button
+
+    Scenario: Channel content download
+      Given a super admin has enabled the *Show 'download' button with resources* option at *Facility > Settings* page
+      When I go to *Learn > Channels* page
+        And I browse any channel's topics until I open an single resource
+      Then I see the *Download resource* button
+
 Examples:
   | channel        | topic    | subtopic | content_item                     |
   | Kolibri Demo 1 | Science  | Physics  | Intro to springs and Hooke's law |
diff --git a/integration_testing/features/learner/learner-find-content-item.feature b/integration_testing/features/learner/learner-find-content-item.feature
--- a/integration_testing/features/learner/learner-find-content-item.feature
+++ b/integration_testing/features/learner/learner-find-content-item.feature
@@ -1,51 +1,52 @@
 Feature: Learner finds content item
-  Learner needs to be able to search and find content items using the search bar
+	Learner needs to be able to search and find content items using the search bar
 
-  Background:
-    Given I am signed in to Kolibri as a Learner user
-      And there is a channel <channel> imported on the device
-      And I am on any of the tabs inside *Learn*
+	Background:
+		Given I am signed in to Kolibri as a Learner user
+			And there is a channel <channel> imported on the device
+			And I am on any of the tabs inside *Learn*
 
-  Scenario: Find a specific content item using the search bar
-    When I enter the <search_term> in the search field
-     And I press the ENTER key or click the search icon button
-    Then I see the *Search > N results for '<search_term>'* page
+	Scenario: Find a specific content item using the search bar
+		When I enter the <search_term> in the search field
+			And I press the ENTER key or click the search icon button
+		Then I see the *Search > N results for '<search_term>'* page
+			And I see the search results for <search_term>
 
-  Scenario: Clear the previous search
-    Given that I've written something in the search field
-      When I use the TAB key to focus the *Clear* button
-        And I press ENTER
-          Or I click/tap the *Clear* button directly
-      Then I see the search field is empty
-        But I can still see the results of the previous search
+	Scenario: Clear the previous search
+		Given that I've written something in the search field
+		When I use the TAB key to focus the *Clear* button
+			And I press ENTER
+				Or I click/tap the *Clear* button directly
+		Then I see the search field is empty
+			But I can still see the results of the previous search
 
-  Scenario: Filter search results
-    When I open the *Type* filter and select a type
-    Then I see the results are filtered
-      And I see the *M results for '<search_term>'*
-    When I open the *Channels* filter and select a channel
-    Then I see the results are filtered even more
-      And I see the *Q results for '<search_term>'*
-    When I click the *X* (clear) button
-    Then the search field is empty
-      And I can write the new search term
-        But I can still see the results of the previous search
+	Scenario: Filter search results
+		When I open the *Type* filter and select a type
+		Then I see the results are filtered
+			And I see the *M results for '<search_term>'*
+		When I open the *Channels* filter and select a channel
+		Then I see the results are filtered even more
+			And I see the *Q results for '<search_term>'*
+		When I click the *X* (clear) button
+		Then the search field is empty
+			And I can write the new search term
+				But I can still see the results of the previous search
 
-  Scenario: Browse locations for the multiple search results
-    Given there is a search result item that is present in various channels and/or locations
-      When I click the *N locations* link on one of the items
-      Then I see the *Locations* modal
-        And I see the list of links to N locations where the search result item is present
-      When I click one of the links
-      Then I see the *Search > '<content item>'> page
-      When I click the *X* icon in the left upper corner
-      Then I see the results of the previous search
-      When I click the *N locations* link on one of the items
-      Then I see the *Locations* modal again
-      When I click *Close*
-      Then the modal closes
-        And I see the results of the previous search
+	Scenario: Browse locations for the multiple search results
+		Given there is a search result item that is present in various channels and/or locations
+			When I click the *N locations* link on one of the items
+			Then I see the *Locations* modal
+				And I see the list of links to N locations where the search result item is present
+			When I click one of the links
+			Then I see the *Search > '<content item>'> page
+			When I click the *X* icon in the left upper corner
+			Then I see the results of the previous search
+			When I click the *N locations* link on one of the items
+			Then I see the *Locations* modal again
+			When I click *Close*
+			Then the modal closes
+				And I see the results of the previous search
 
 Examples:
-  | search_term |
-  | cosine      |
+	| search_term |
+	| cosine      |
diff --git a/integration_testing/features/super-admin/facility/super-admin-change-facility-settings.feature b/integration_testing/features/super-admin/facility/super-admin-change-facility-settings.feature
--- a/integration_testing/features/super-admin/facility/super-admin-change-facility-settings.feature
+++ b/integration_testing/features/super-admin/facility/super-admin-change-facility-settings.feature
@@ -58,7 +58,8 @@ Feature: Admin changes facility settings
     Then I (as learner <learner>) can see the *Change password* link
 
   Scenario: Allow content download
-    Given the *Show 'download' button with content* checkbox is unchecked
+    Given the *Show 'download' button with resources* checkbox is unchecked
+      And Kolibri is not running in the app context
     When I check the *Show 'download' button with resources* checkbox
       And I click the *Save changes* button
     When I go to *Learn > Channels* page
diff --git a/integration_testing/features/super-admin/super-admin-goes-through-setup-wizard-offline-mode.feature b/integration_testing/features/super-admin/super-admin-goes-through-setup-wizard-offline-mode.feature
new file mode 100644
--- /dev/null
+++ b/integration_testing/features/super-admin/super-admin-goes-through-setup-wizard-offline-mode.feature
@@ -0,0 +1,69 @@
+Feature: Super admin goes through the setup wizard in offline mode
+  Super admin can go through the Setup Wizard in offline mode
+
+  # In case of testing on virtual machine:
+  # Make sure that your testing environment has no Internet connection (before you start the VM, go to Properties > Network > Adapter 1, and uncheck the Enable Network Adapter checkbox; try to do a Google search to confirm that the VM has no Internet access).
+  # Download it on your host and unzip anywhere on your Windows 10 VM guest (Desktop should work fine). VM's Shared Folders setting should work even without the network adapter.
+  # Keep both folders (Kolibri and KOLIBRI_DATA) together in the same location.
+  # Open the Kolibri folder and double-click the Kolibri.exe file.
+
+  Background:
+    Given The testing environment has no active Internet connection
+      And The Kolibri installation was successful
+      And the server is running for the first time
+      And the App is opened in the virtual machine
+
+  Scenario: Select language
+    Given that I am at the beginning of the setup wizard
+      And I see *Please select the default language for Kolibri*
+    When I click the link *Español*
+    Then the wizard language changes to Spanish
+    When I click *More languages*
+    Then I see the *Change language* modal
+    When I select *Français*
+      And click *Confirmar*
+    Then the modal closes
+      And I see the wizard language changes to French
+    When I click the link *English*
+    Then the wizard language changes to English
+    When I click *Continue* button
+    Then I see *Getting started*
+
+  Scenario: Select 'Quick start'
+    Given I see *How are you using Kolibri?*
+    When I select *Quick start*
+      And I click *Continue*
+    Then I see *Create super admin account*
+
+  Scenario: Select 'Advanced setup' wizard
+    Given I am on the Language selection page
+    When I click the Continue button on that page
+    Then I see *Quick Start* and *Advanced setup* options
+    When I select *Advanced setup* option
+      And I click the Continue button
+    Then I see the Device name page
+    When I fill a device name and click Continue button
+    Then I see the Create or import facility page
+    When I click the New facility button
+    Then The *New facility - step 1 of 6* page loads
+      And I see *Non-formal* and *Formal* options for facility type
+    When I select *Formal*
+      And I give some name of my new facility
+      And I click the Continue button
+    Then The *New facility - step 2 of 6* page loads
+      And I see *Enable guest access?* options
+    When I select *No* and click Continue button
+    Then The "New facility - step 3 of 6" page loads
+      And I see the "Allow anyone to create their own learner account?" options
+    When I select *No* and click Continue button
+    Then The *New facility - step 4 of 6* page loads
+      And I see *Enable passwords on learner accounts?* options
+    When I select *No* and click Continue button
+    Then The *New facility - step 5 of 6* page loads
+      And I see *Create super admin account* form
+    When I fill the form with valid data and click Continue button
+    Then The *New facility - step 6 of 6* page loads
+      And I see *Responsibilities as an administrator* text
+      And I see the Finish button
+    When I click the Finish button
+    Then I am logged in to Kolibri
diff --git a/kolibri/core/auth/test/test_roles_and_membership.py b/kolibri/core/auth/test/test_roles_and_membership.py
--- a/kolibri/core/auth/test/test_roles_and_membership.py
+++ b/kolibri/core/auth/test/test_roles_and_membership.py
@@ -115,7 +115,9 @@ def test_admin_can_read_learner_object(self):
         self.assertTrue(self.admin.can_read(self.learner))
 
     def test_learner_is_in_list_of_readable_objects(self):
-        self.assertIn(
+        # This should not be present as we are no longer supporting classroom membership
+        # solely by virtue of being a member of a group in that class.
+        self.assertNotIn(
             self.learner, self.admin.filter_readable(FacilityUser.objects.all())
         )