Skip to content

Commit

Permalink
Merge pull request #2677 from onaio/fix-2676
Browse files Browse the repository at this point in the history
Fix exception thrown when updating organization profile
  • Loading branch information
FrankApiyo authored Aug 26, 2024
2 parents 4b8ef74 + ad12aee commit a201c91
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1054,8 +1054,8 @@ def test_put_role_user_none_existent(self):
def test_update_org_name(self):
self._org_create()

# update name
data = {"name": "Dennis2"}
# update name and email
data = {"name": "Dennis2", "email": "[email protected]"}
request = self.factory.patch("/", data=data, **self.extra)
response = self.view(request, user="denoinc")
self.assertEqual(response.data["name"], "Dennis2")
Expand Down
5 changes: 4 additions & 1 deletion onadata/libs/serializers/organization_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ def update(self, instance, validated_data):
first_name, last_name = _get_first_last_names(validated_data.get("name"))
instance.user.first_name = first_name
instance.user.last_name = last_name
instance.user.save()

if "email" in validated_data:
instance.user.email = validated_data.pop("email")

instance.user.save()
return super().update(instance, validated_data)

def create(self, validated_data):
Expand Down

0 comments on commit a201c91

Please sign in to comment.