Repository: learningequality/kolibri

Issue:
validation message is shown immediately on auto-focus of multi-facility account creation page

### Observed behavior

minor issue with auto-focus after showing facility selection modal:

* on the sign in page, no validation is initially displayed (correct)
* on create account page, validation is immediately displayed

| sign in | create account |
|--|--|
| ![image](https://user-images.githubusercontent.com/2367265/63043409-08404880-be81-11e9-9bc9-db7d42468c06.png) | ![image](https://user-images.githubusercontent.com/2367265/63043424-0fffed00-be81-11e9-88cd-860bee9b49ab.png)|
| ![image](https://user-images.githubusercontent.com/2367265/63043223-a1bb2a80-be80-11e9-979d-3c14cfc0841b.png) | ![image](https://user-images.githubusercontent.com/2367265/63043244-af70b000-be80-11e9-92cf-0dafc06e67c6.png) |


### Expected behavior

no validation is initially displayed

### User-facing consequences

slightly aggressive validation

### Steps to reproduce

* Create a second facility, e.g. using `http://localhost:8000/api/auth/facility/`
* navigate to account creation page `http://localhost:8000/en/user/#/create_account`
* refresh and choose a facility
* note that validation message is shown immediately

### Context

0.12.8


Discussion:
This might be happening since, on the Sign Up Page, the "Full name" field has "autofocus=true". So the field is focused on the first load, then blurred when the modal pops up and focus is given to the modal.

If this is what's happening, we might be able unblur that field immediately before the modal shows up. IDK if that will get be fast enough, though.
this would also be addressed more generally by implementing https://github.com/learningequality/kolibri/issues/2184

I'm sort of inclined to do that for 0.13.x - would you be interested in taking it on?
@indirectlylit is this issue still available?
@Tlazypanda it may have been addressed by the work on https://github.com/learningequality/kolibri/issues/2184 during 0.13

However – if you're interested – it would be super helpful to confirm whether or not this is true.  You can generate multiple facilities by running:

```
kolibri manage generateuserdata --facilities 2
```



Resolving patch:
diff --git a/kolibri/core/auth/serializers.py b/kolibri/core/auth/serializers.py
--- a/kolibri/core/auth/serializers.py
+++ b/kolibri/core/auth/serializers.py
@@ -91,6 +91,7 @@ class Meta:
             "location",
             "allow_guest_access",
             "registered",
+            "preset",
         )
 
     def get_allow_guest_access(self, instance):
diff --git a/kolibri/plugins/learn/kolibri_plugin.py b/kolibri/plugins/learn/kolibri_plugin.py
--- a/kolibri/plugins/learn/kolibri_plugin.py
+++ b/kolibri/plugins/learn/kolibri_plugin.py
@@ -7,6 +7,7 @@
 from kolibri.core.auth.constants.user_kinds import ANONYMOUS
 from kolibri.core.auth.constants.user_kinds import LEARNER
 from kolibri.core.content.hooks import ContentNodeDisplayHook
+from kolibri.core.device.utils import get_device_setting
 from kolibri.core.device.utils import is_landing_page
 from kolibri.core.device.utils import LANDING_PAGE_LEARN
 from kolibri.core.hooks import NavigationHook
@@ -44,6 +45,10 @@ class LearnNavItem(NavigationHook):
 class LearnAsset(webpack_hooks.WebpackBundleHook):
     bundle_id = "app"
 
+    @property
+    def plugin_data(self):
+        return {"allowGuestAccess": get_device_setting("allow_guest_access")}
+
 
 @register_hook
 class LearnContentNodeHook(ContentNodeDisplayHook):
diff --git a/kolibri/plugins/user/kolibri_plugin.py b/kolibri/plugins/user/kolibri_plugin.py
--- a/kolibri/plugins/user/kolibri_plugin.py
+++ b/kolibri/plugins/user/kolibri_plugin.py
@@ -3,6 +3,7 @@
 from __future__ import unicode_literals
 
 from kolibri.core.auth.constants.user_kinds import ANONYMOUS
+from kolibri.core.device.utils import get_device_setting
 from kolibri.core.device.utils import is_landing_page
 from kolibri.core.device.utils import LANDING_PAGE_LEARN
 from kolibri.core.hooks import NavigationHook
@@ -23,7 +24,10 @@ class UserAsset(webpack_hooks.WebpackBundleHook):
 
     @property
     def plugin_data(self):
-        return {"oidcProviderEnabled": OIDCProviderHook.is_enabled()}
+        return {
+            "oidcProviderEnabled": OIDCProviderHook.is_enabled(),
+            "allowGuestAccess": get_device_setting("allow_guest_access"),
+        }
 
 
 @register_hook


Test patch:
diff --git a/kolibri/plugins/user/assets/test/views/sign-in-page.spec.js b/kolibri/plugins/user/assets/test/views/sign-in-page.spec.js
--- a/kolibri/plugins/user/assets/test/views/sign-in-page.spec.js
+++ b/kolibri/plugins/user/assets/test/views/sign-in-page.spec.js
@@ -5,11 +5,18 @@ import makeStore from '../makeStore';
 jest.mock('kolibri.urls');
 
 function makeWrapper() {
+  const store = makeStore();
+  store.state.facilityId = '123';
+  store.state.core.facilities.push({
+    id: '123',
+    name: 'test facility',
+  });
   return mount(SignInPage, {
-    store: makeStore(),
+    store,
   });
 }
 
+//
 describe('signInPage component', () => {
   it('smoke test', () => {
     const wrapper = makeWrapper();
diff --git a/kolibri/plugins/user/assets/test/views/sign-up-page.spec.js b/kolibri/plugins/user/assets/test/views/sign-up-page.spec.js
--- a/kolibri/plugins/user/assets/test/views/sign-up-page.spec.js
+++ b/kolibri/plugins/user/assets/test/views/sign-up-page.spec.js
@@ -9,6 +9,7 @@ localVue.use(VueRouter);
 function makeWrapper() {
   const store = makeStore();
   store.state.core.facilities = [{ id: 1, name: 'facility' }];
+  store.state.facilityId = 1;
   return mount(SignUpPage, {
     store,
     router: new VueRouter({