Repository: oppia/oppia

Issue:
Exploration ownership cannot be transferred to the community
Create a simple exploration and publish it. Then go to the settings tab and click "Transfer ownership to the community", then click the green button in the modal. An orange warning appears saying "No change was made to this exploration". Instead, ownership should transferred to the community.
Exploration ownership cannot be transferred to the community
Create a simple exploration and publish it. Then go to the settings tab and click "Transfer ownership to the community", then click the green button in the modal. An orange warning appears saying "No change was made to this exploration". Instead, ownership should transferred to the community.


Discussion:
I think it should be `'make_community_owned'` here instead of `'is_community_owned'`
https://github.com/oppia/oppia/blob/54f978a32248fd16de44689e19d9f83fadc06841/core/controllers/editor.py#L348
/cc @seanlip 
(introduced [here](https://github.com/oppia/oppia/pull/3641/files#diff-f539af1da991345c436a49a41821b7e3L414))
I think it should be `'make_community_owned'` here instead of `'is_community_owned'`
https://github.com/oppia/oppia/blob/54f978a32248fd16de44689e19d9f83fadc06841/core/controllers/editor.py#L348
/cc @seanlip 
(introduced [here](https://github.com/oppia/oppia/pull/3641/files#diff-f539af1da991345c436a49a41821b7e3L414))

Resolving patch:
diff --git a/core/controllers/editor.py b/core/controllers/editor.py
--- a/core/controllers/editor.py
+++ b/core/controllers/editor.py
@@ -345,7 +345,7 @@ def put(self, exploration_id):
         version = self.payload.get('version')
         _require_valid_version(version, exploration.version)
 
-        make_community_owned = self.payload.get('is_community_owned')
+        make_community_owned = self.payload.get('make_community_owned')
         new_member_username = self.payload.get('new_member_username')
         new_member_role = self.payload.get('new_member_role')
         viewable_if_private = self.payload.get('viewable_if_private')


Test patch:
diff --git a/core/controllers/editor_test.py b/core/controllers/editor_test.py
--- a/core/controllers/editor_test.py
+++ b/core/controllers/editor_test.py
@@ -1105,11 +1105,12 @@ class ExplorationRightsIntegrationTest(BaseEditorControllerTest):
     COLLABORATOR2_USERNAME = 'collab2'
     COLLABORATOR3_EMAIL = 'collaborator3@example.com'
     COLLABORATOR3_USERNAME = 'collab3'
+    RANDOM_USER_EMAIL = 'randomuser@example.com'
+    RANDOM_USER_USERNAME = 'randomuser'
 
-    def test_exploration_rights_handler(self):
-        """Test exploration rights handler."""
-
-        # Create several users
+    def test_for_assign_role_for_exploration(self):
+        """Test exploration rights handler for assign role for exploration."""
+        # Create several users.
         self.signup(
             self.COLLABORATOR_EMAIL, username=self.COLLABORATOR_USERNAME)
         self.signup(
@@ -1171,7 +1172,7 @@ def test_exploration_rights_handler(self):
         self.assert_can_edit(response.body)
         csrf_token = self.get_csrf_token_from_response(response)
 
-        # Check that collaborator can add a new state called 'State 4'
+        # Check that collaborator can add a new state called 'State 4'.
         add_url = '%s/%s' % (feconf.EXPLORATION_DATA_PREFIX, exp_id)
         response_dict = self.put_json(
             add_url,
@@ -1193,7 +1194,7 @@ def test_exploration_rights_handler(self):
         )
         self.assertIn('State 4', response_dict['states'])
 
-        # Check that collaborator cannot add new members
+        # Check that collaborator cannot add new members.
         exploration = exp_services.get_exploration_by_id(exp_id)
         rights_url = '%s/%s' % (feconf.EXPLORATION_RIGHTS_PREFIX, exp_id)
         response_dict = self.put_json(
@@ -1213,7 +1214,7 @@ def test_exploration_rights_handler(self):
         self.assert_can_edit(response.body)
         csrf_token = self.get_csrf_token_from_response(response)
 
-        # Check that collaborator2 can add a new state called 'State 5'
+        # Check that collaborator2 can add a new state called 'State 5'.
         add_url = '%s/%s' % (feconf.EXPLORATION_DATA_PREFIX, exp_id)
         response_dict = self.put_json(
             add_url,
@@ -1248,6 +1249,48 @@ def test_exploration_rights_handler(self):
 
         self.logout()
 
+    def test_transfering_ownership_to_the_community(self):
+        """Test exploration rights handler for transfering ownership to the
+        community.
+        """
+        # Owner creates an exploration.
+        self.login(self.OWNER_EMAIL)
+        exp_id = 'exp_id'
+        self.save_new_valid_exploration(
+            exp_id, self.owner_id, title='My Exploration',
+            end_state_name='END')
+        response = self.testapp.get('/create/%s' % exp_id)
+        csrf_token = self.get_csrf_token_from_response(response)
+        rights_manager.publish_exploration(self.owner, exp_id)
+
+        # Owner transfers ownership to the community.
+        exploration = exp_services.get_exploration_by_id(exp_id)
+        rights_url = '%s/%s' % (feconf.EXPLORATION_RIGHTS_PREFIX, exp_id)
+        self.put_json(
+            rights_url, {
+                'version': exploration.version,
+                'make_community_owned': True
+            }, csrf_token)
+
+        self.logout()
+
+        # Create a random user.
+        self.signup(
+            self.RANDOM_USER_EMAIL, username=self.RANDOM_USER_USERNAME)
+
+        # Check community_owned_status value.
+        exp_summary = exp_services.get_exploration_summary_by_id(exp_id)
+        community_owned_status = exp_summary.community_owned
+        self.assertTrue(community_owned_status)
+
+        # Check that any random user can access editor page and can edit.
+        self.login(self.RANDOM_USER_EMAIL)
+        response = self.testapp.get('/create/%s' % exp_id)
+        self.assertEqual(response.status_int, 200)
+        self.assert_can_edit(response.body)
+
+        self.logout()
+
 
 class UserExplorationEmailsIntegrationTest(BaseEditorControllerTest):
     """Test the handler for user email notification preferences."""