prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  <Improvement> Not showing user is exist notification on UI.
  
  ### Observed behavior
  We are able to create user using CREATE AN ACCOUNT option which is on login page of kolibri. But when someone uses existing username to create account, it will not show any kind of existing user notification on UI.
  Not able to distinguish whether account is exist or not.
  ### Expected behavior
  It must show existing username notification on UI if user is exist.
  
  
  ### Steps to reproduce
  1. Login with Admin and go to the facility.
  2. Click on settings.
  3. Select Allow learners to create accounts.
  4. Logout and click on CREATE AN ACCOUNT button and use existing username to create account.
  
  ### Context
  
   * Kolibri version : Kolibri 0.11.0 
   * Operating system : ubuntu 14.04
   * Browser : Chrome
  
  ### Screenshots:
  ![1](https://user-images.githubusercontent.com/12776071/49732114-840b4500-fca3-11e8-9917-a08ae5515d26.png)
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `kolibri/core/auth/serializers.py`
  Content:
  ```
  1 from __future__ import absolute_import
  2 from __future__ import print_function
  3 from __future__ import unicode_literals
  4 
  5 from rest_framework import serializers
  6 from rest_framework.validators import UniqueTogetherValidator
  7 
  8 from .constants.collection_kinds import LEARNERGROUP
  9 from .models import Classroom
  10 from .models import Facility
  11 from .models import FacilityDataset
  12 from .models import FacilityUser
  13 from .models import LearnerGroup
  14 from .models import Membership
  15 from .models import Role
  16 from kolibri.core import error_constants
  17 
  18 
  19 class RoleSerializer(serializers.ModelSerializer):
  20     collection_parent = serializers.SerializerMethodField()
  21 
  22     class Meta:
  23         model = Role
  24         fields = ('id', 'kind', 'collection', 'user', 'collection_parent',)
  25 
  26     def get_collection_parent(self, instance):
  27         if instance.collection.parent is not None:
  28             return instance.collection.parent.id
  29         else:
  30             return None
  31 
  32 
  33 class FacilityUserSerializer(serializers.ModelSerializer):
  34     roles = RoleSerializer(many=True, read_only=True)
  35 
  36     class Meta:
  37         model = FacilityUser
  38         extra_kwargs = {'password': {'write_only': True}}
  39         fields = ('id', 'username', 'full_name', 'password', 'facility', 'roles', 'is_superuser')
  40 
  41     def create(self, validated_data):
  42         if FacilityUser.objects.filter(username__iexact=validated_data['username']).exists():
  43             raise serializers.ValidationError(detail={'username': ['An account with that username already exists.']},
  44                                               code=error_constants.USERNAME_ALREADY_EXISTS)
  45         return super(FacilityUserSerializer, self).create(validated_data)
  46 
  47     def update(self, instance, validated_data):
  48         if validated_data.get('username') and FacilityUser.objects.exclude(id__exact=instance.id).filter(username__iexact=validated_data['username']).exists():
  49             raise serializers.ValidationError(detail={'username': ['An account with that username already exists.']},
  50                                               code=error_constants.USERNAME_ALREADY_EXISTS)
  51         return super(FacilityUserSerializer, self).update(instance, validated_data)
  52 
  53 
  54 class FacilityUserSignupSerializer(FacilityUserSerializer):
  55 
  56     def validate_username(self, value):
  57         if FacilityUser.objects.filter(username__iexact=value).exists():
  58             raise serializers.ValidationError(detail={'username': ['An account with that username already exists.']},
  59                                               code=error_constants.USERNAME_ALREADY_EXISTS)
  60         return value
  61 
  62 
  63 class FacilityUsernameSerializer(serializers.ModelSerializer):
  64 
  65     class Meta:
  66         model = FacilityUser
  67         fields = ('username', )
  68 
  69 
  70 class MembershipSerializer(serializers.ModelSerializer):
  71 
  72     class Meta:
  73         model = Membership
  74         fields = ('id', 'collection', 'user')
  75 
  76     def create(self, validated_data):
  77         user = validated_data["user"]
  78         collection = validated_data["collection"]
  79         if collection.kind == LEARNERGROUP and user.memberships.filter(collection__parent=collection.parent).exists():
  80             # We are trying to create a membership for a user in a group, but they already belong to a group
  81             # in the same class as this group. We may want to allow this, but the frontend does not currently
  82             # support this. Error!
  83             raise serializers.ValidationError(detail={'classroom': 'This user is already in a group in this class'},
  84                                               code=error_constants.USER_ALREADY_IN_GROUP_IN_CLASS)
  85         return super(MembershipSerializer, self).create(validated_data)
  86 
  87 
  88 class FacilityDatasetSerializer(serializers.ModelSerializer):
  89 
  90     class Meta:
  91         model = FacilityDataset
  92         fields = ('id', 'learner_can_edit_username', 'learner_can_edit_name', 'learner_can_edit_password',
  93                   'learner_can_sign_up', 'learner_can_delete_account', 'learner_can_login_with_no_password',
  94                   'show_download_button_in_learn', 'description', 'location', 'allow_guest_access')
  95 
  96 
  97 class FacilitySerializer(serializers.ModelSerializer):
  98     dataset = FacilityDatasetSerializer(read_only=True)
  99     default = serializers.SerializerMethodField()
  100 
  101     class Meta:
  102         model = Facility
  103         extra_kwargs = {'id': {'read_only': True}, 'dataset': {'read_only': True}}
  104         fields = ('id', 'name', 'dataset', 'default')
  105 
  106     def get_default(self, instance):
  107         return instance == Facility.get_default_facility()
  108 
  109 
  110 class PublicFacilitySerializer(serializers.ModelSerializer):
  111 
  112     class Meta:
  113         model = Facility
  114         fields = ('dataset', 'name')
  115 
  116 
  117 class ClassroomSerializer(serializers.ModelSerializer):
  118     learner_count = serializers.SerializerMethodField()
  119     coaches = serializers.SerializerMethodField()
  120 
  121     def get_learner_count(self, instance):
  122         return instance.get_members().count()
  123 
  124     def get_coaches(self, instance):
  125         return FacilityUserSerializer(instance.get_coaches(), many=True).data
  126 
  127     class Meta:
  128         model = Classroom
  129         fields = (
  130             'id',
  131             'name',
  132             'parent',
  133             'learner_count',
  134             'coaches',
  135         )
  136 
  137         validators = [
  138             UniqueTogetherValidator(
  139                 queryset=Classroom.objects.all(),
  140                 fields=('parent', 'name')
  141             )
  142         ]
  143 
  144 
  145 class LearnerGroupSerializer(serializers.ModelSerializer):
  146 
  147     user_ids = serializers.SerializerMethodField()
  148 
  149     def get_user_ids(self, group):
  150         return [str(user_id['id']) for user_id in group.get_members().values('id')]
  151 
  152     class Meta:
  153         model = LearnerGroup
  154         fields = ('id', 'name', 'parent', 'user_ids')
  155 
  156         validators = [
  157             UniqueTogetherValidator(
  158                 queryset=Classroom.objects.all(),
  159                 fields=('parent', 'name')
  160             )
  161         ]
  162
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: 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
  @@ -55,8 +55,10 @@
   
       def validate_username(self, value):
           if FacilityUser.objects.filter(username__iexact=value).exists():
  -            raise serializers.ValidationError(detail={'username': ['An account with that username already exists.']},
  -                                              code=error_constants.USERNAME_ALREADY_EXISTS)
  +            raise serializers.ValidationError(
  +                detail='An account with that username already exists.',
  +                code=error_constants.USERNAME_ALREADY_EXISTS
  +            )
           return value
  
verification_info: {"golden_diff": "diff --git a/kolibri/core/auth/serializers.py b/kolibri/core/auth/serializers.py\n--- a/kolibri/core/auth/serializers.py\n+++ b/kolibri/core/auth/serializers.py\n@@ -55,8 +55,10 @@\n \n     def validate_username(self, value):\n         if FacilityUser.objects.filter(username__iexact=value).exists():\n-            raise serializers.ValidationError(detail={'username': ['An account with that username already exists.']},\n-                                              code=error_constants.USERNAME_ALREADY_EXISTS)\n+            raise serializers.ValidationError(\n+                detail='An account with that username already exists.',\n+                code=error_constants.USERNAME_ALREADY_EXISTS\n+            )\n         return value\n", "issue": "<Improvement> Not showing user is exist notification on UI.\n\r\n### Observed behavior\r\nWe are able to create user using CREATE AN ACCOUNT option which is on login page of kolibri. But when someone uses existing username to create account, it will not show any kind of existing user notification on UI.\r\nNot able to distinguish whether account is exist or not.\r\n### Expected behavior\r\nIt must show existing username notification on UI if user is exist.\r\n\r\n\r\n### Steps to reproduce\r\n1. Login with Admin and go to the facility.\r\n2. Click on settings.\r\n3. Select Allow learners to create accounts.\r\n4. Logout and click on CREATE AN ACCOUNT button and use existing username to create account.\r\n\r\n### Context\r\n\r\n * Kolibri version : Kolibri 0.11.0 \r\n * Operating system : ubuntu 14.04\r\n * Browser : Chrome\r\n\r\n### Screenshots:\r\n![1](https://user-images.githubusercontent.com/12776071/49732114-840b4500-fca3-11e8-9917-a08ae5515d26.png)\r\n\r\n\n", "before_files": [{"content": "from __future__ import absolute_import\nfrom __future__ import print_function\nfrom __future__ import unicode_literals\n\nfrom rest_framework import serializers\nfrom rest_framework.validators import UniqueTogetherValidator\n\nfrom .constants.collection_kinds import LEARNERGROUP\nfrom .models import Classroom\nfrom .models import Facility\nfrom .models import FacilityDataset\nfrom .models import FacilityUser\nfrom .models import LearnerGroup\nfrom .models import Membership\nfrom .models import Role\nfrom kolibri.core import error_constants\n\n\nclass RoleSerializer(serializers.ModelSerializer):\n    collection_parent = serializers.SerializerMethodField()\n\n    class Meta:\n        model = Role\n        fields = ('id', 'kind', 'collection', 'user', 'collection_parent',)\n\n    def get_collection_parent(self, instance):\n        if instance.collection.parent is not None:\n            return instance.collection.parent.id\n        else:\n            return None\n\n\nclass FacilityUserSerializer(serializers.ModelSerializer):\n    roles = RoleSerializer(many=True, read_only=True)\n\n    class Meta:\n        model = FacilityUser\n        extra_kwargs = {'password': {'write_only': True}}\n        fields = ('id', 'username', 'full_name', 'password', 'facility', 'roles', 'is_superuser')\n\n    def create(self, validated_data):\n        if FacilityUser.objects.filter(username__iexact=validated_data['username']).exists():\n            raise serializers.ValidationError(detail={'username': ['An account with that username already exists.']},\n                                              code=error_constants.USERNAME_ALREADY_EXISTS)\n        return super(FacilityUserSerializer, self).create(validated_data)\n\n    def update(self, instance, validated_data):\n        if validated_data.get('username') and FacilityUser.objects.exclude(id__exact=instance.id).filter(username__iexact=validated_data['username']).exists():\n            raise serializers.ValidationError(detail={'username': ['An account with that username already exists.']},\n                                              code=error_constants.USERNAME_ALREADY_EXISTS)\n        return super(FacilityUserSerializer, self).update(instance, validated_data)\n\n\nclass FacilityUserSignupSerializer(FacilityUserSerializer):\n\n    def validate_username(self, value):\n        if FacilityUser.objects.filter(username__iexact=value).exists():\n            raise serializers.ValidationError(detail={'username': ['An account with that username already exists.']},\n                                              code=error_constants.USERNAME_ALREADY_EXISTS)\n        return value\n\n\nclass FacilityUsernameSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = FacilityUser\n        fields = ('username', )\n\n\nclass MembershipSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = Membership\n        fields = ('id', 'collection', 'user')\n\n    def create(self, validated_data):\n        user = validated_data[\"user\"]\n        collection = validated_data[\"collection\"]\n        if collection.kind == LEARNERGROUP and user.memberships.filter(collection__parent=collection.parent).exists():\n            # We are trying to create a membership for a user in a group, but they already belong to a group\n            # in the same class as this group. We may want to allow this, but the frontend does not currently\n            # support this. Error!\n            raise serializers.ValidationError(detail={'classroom': 'This user is already in a group in this class'},\n                                              code=error_constants.USER_ALREADY_IN_GROUP_IN_CLASS)\n        return super(MembershipSerializer, self).create(validated_data)\n\n\nclass FacilityDatasetSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = FacilityDataset\n        fields = ('id', 'learner_can_edit_username', 'learner_can_edit_name', 'learner_can_edit_password',\n                  'learner_can_sign_up', 'learner_can_delete_account', 'learner_can_login_with_no_password',\n                  'show_download_button_in_learn', 'description', 'location', 'allow_guest_access')\n\n\nclass FacilitySerializer(serializers.ModelSerializer):\n    dataset = FacilityDatasetSerializer(read_only=True)\n    default = serializers.SerializerMethodField()\n\n    class Meta:\n        model = Facility\n        extra_kwargs = {'id': {'read_only': True}, 'dataset': {'read_only': True}}\n        fields = ('id', 'name', 'dataset', 'default')\n\n    def get_default(self, instance):\n        return instance == Facility.get_default_facility()\n\n\nclass PublicFacilitySerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = Facility\n        fields = ('dataset', 'name')\n\n\nclass ClassroomSerializer(serializers.ModelSerializer):\n    learner_count = serializers.SerializerMethodField()\n    coaches = serializers.SerializerMethodField()\n\n    def get_learner_count(self, instance):\n        return instance.get_members().count()\n\n    def get_coaches(self, instance):\n        return FacilityUserSerializer(instance.get_coaches(), many=True).data\n\n    class Meta:\n        model = Classroom\n        fields = (\n            'id',\n            'name',\n            'parent',\n            'learner_count',\n            'coaches',\n        )\n\n        validators = [\n            UniqueTogetherValidator(\n                queryset=Classroom.objects.all(),\n                fields=('parent', 'name')\n            )\n        ]\n\n\nclass LearnerGroupSerializer(serializers.ModelSerializer):\n\n    user_ids = serializers.SerializerMethodField()\n\n    def get_user_ids(self, group):\n        return [str(user_id['id']) for user_id in group.get_members().values('id')]\n\n    class Meta:\n        model = LearnerGroup\n        fields = ('id', 'name', 'parent', 'user_ids')\n\n        validators = [\n            UniqueTogetherValidator(\n                queryset=Classroom.objects.all(),\n                fields=('parent', 'name')\n            )\n        ]\n", "path": "kolibri/core/auth/serializers.py"}], "after_files": [{"content": "from __future__ import absolute_import\nfrom __future__ import print_function\nfrom __future__ import unicode_literals\n\nfrom rest_framework import serializers\nfrom rest_framework.validators import UniqueTogetherValidator\n\nfrom .constants.collection_kinds import LEARNERGROUP\nfrom .models import Classroom\nfrom .models import Facility\nfrom .models import FacilityDataset\nfrom .models import FacilityUser\nfrom .models import LearnerGroup\nfrom .models import Membership\nfrom .models import Role\nfrom kolibri.core import error_constants\n\n\nclass RoleSerializer(serializers.ModelSerializer):\n    collection_parent = serializers.SerializerMethodField()\n\n    class Meta:\n        model = Role\n        fields = ('id', 'kind', 'collection', 'user', 'collection_parent',)\n\n    def get_collection_parent(self, instance):\n        if instance.collection.parent is not None:\n            return instance.collection.parent.id\n        else:\n            return None\n\n\nclass FacilityUserSerializer(serializers.ModelSerializer):\n    roles = RoleSerializer(many=True, read_only=True)\n\n    class Meta:\n        model = FacilityUser\n        extra_kwargs = {'password': {'write_only': True}}\n        fields = ('id', 'username', 'full_name', 'password', 'facility', 'roles', 'is_superuser')\n\n    def create(self, validated_data):\n        if FacilityUser.objects.filter(username__iexact=validated_data['username']).exists():\n            raise serializers.ValidationError(detail={'username': ['An account with that username already exists.']},\n                                              code=error_constants.USERNAME_ALREADY_EXISTS)\n        return super(FacilityUserSerializer, self).create(validated_data)\n\n    def update(self, instance, validated_data):\n        if validated_data.get('username') and FacilityUser.objects.exclude(id__exact=instance.id).filter(username__iexact=validated_data['username']).exists():\n            raise serializers.ValidationError(detail={'username': ['An account with that username already exists.']},\n                                              code=error_constants.USERNAME_ALREADY_EXISTS)\n        return super(FacilityUserSerializer, self).update(instance, validated_data)\n\n\nclass FacilityUserSignupSerializer(FacilityUserSerializer):\n\n    def validate_username(self, value):\n        if FacilityUser.objects.filter(username__iexact=value).exists():\n            raise serializers.ValidationError(\n                detail='An account with that username already exists.',\n                code=error_constants.USERNAME_ALREADY_EXISTS\n            )\n        return value\n\n\nclass FacilityUsernameSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = FacilityUser\n        fields = ('username', )\n\n\nclass MembershipSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = Membership\n        fields = ('id', 'collection', 'user')\n\n    def create(self, validated_data):\n        user = validated_data[\"user\"]\n        collection = validated_data[\"collection\"]\n        if collection.kind == LEARNERGROUP and user.memberships.filter(collection__parent=collection.parent).exists():\n            # We are trying to create a membership for a user in a group, but they already belong to a group\n            # in the same class as this group. We may want to allow this, but the frontend does not currently\n            # support this. Error!\n            raise serializers.ValidationError(detail={'classroom': 'This user is already in a group in this class'},\n                                              code=error_constants.USER_ALREADY_IN_GROUP_IN_CLASS)\n        return super(MembershipSerializer, self).create(validated_data)\n\n\nclass FacilityDatasetSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = FacilityDataset\n        fields = ('id', 'learner_can_edit_username', 'learner_can_edit_name', 'learner_can_edit_password',\n                  'learner_can_sign_up', 'learner_can_delete_account', 'learner_can_login_with_no_password',\n                  'show_download_button_in_learn', 'description', 'location', 'allow_guest_access')\n\n\nclass FacilitySerializer(serializers.ModelSerializer):\n    dataset = FacilityDatasetSerializer(read_only=True)\n    default = serializers.SerializerMethodField()\n\n    class Meta:\n        model = Facility\n        extra_kwargs = {'id': {'read_only': True}, 'dataset': {'read_only': True}}\n        fields = ('id', 'name', 'dataset', 'default')\n\n    def get_default(self, instance):\n        return instance == Facility.get_default_facility()\n\n\nclass PublicFacilitySerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = Facility\n        fields = ('dataset', 'name')\n\n\nclass ClassroomSerializer(serializers.ModelSerializer):\n    learner_count = serializers.SerializerMethodField()\n    coaches = serializers.SerializerMethodField()\n\n    def get_learner_count(self, instance):\n        return instance.get_members().count()\n\n    def get_coaches(self, instance):\n        return FacilityUserSerializer(instance.get_coaches(), many=True).data\n\n    class Meta:\n        model = Classroom\n        fields = (\n            'id',\n            'name',\n            'parent',\n            'learner_count',\n            'coaches',\n        )\n\n        validators = [\n            UniqueTogetherValidator(\n                queryset=Classroom.objects.all(),\n                fields=('parent', 'name')\n            )\n        ]\n\n\nclass LearnerGroupSerializer(serializers.ModelSerializer):\n\n    user_ids = serializers.SerializerMethodField()\n\n    def get_user_ids(self, group):\n        return [str(user_id['id']) for user_id in group.get_members().values('id')]\n\n    class Meta:\n        model = LearnerGroup\n        fields = ('id', 'name', 'parent', 'user_ids')\n\n        validators = [\n            UniqueTogetherValidator(\n                queryset=Classroom.objects.all(),\n                fields=('parent', 'name')\n            )\n        ]\n", "path": "kolibri/core/auth/serializers.py"}]}