Repository: oppia/oppia

Issue:
code refactor: remove code for publicize and unpublish from ExplorationStatusHandler
makePublic and makePublicized function are implemented in frontend to manage the publish/publicized status for an exploration. They are called only for publishing and unpublicizing the exploration as unpublishing and publicizing are dealt in ExplorationModeratorRightsHandler. 

Refactor those to reflect this.


Discussion:
Howdy @1995YogeshSharma! I notice that you have several issues assigned to you know and at least one open PR. Please finish those before taking on more. I'm going to deassign you from these new issues for now.
@anthkris ..... These issues are asides of the GSoC work. Sean, suggested to open separate issues for them so as not to block that PR.
Thanks for the info! I'll reassign you.

Resolving patch:
diff --git a/core/controllers/editor.py b/core/controllers/editor.py
--- a/core/controllers/editor.py
+++ b/core/controllers/editor.py
@@ -365,67 +365,52 @@ def put(self, exploration_id):
 class ExplorationStatusHandler(EditorHandler):
     """Handles publishing or publicizing of an exploration."""
 
-    def _publish_exploration(self, exploration_id, make_public):
-        """Publish/Unpublish an exploration based on make_public boolean.
+    def _publish_exploration(self, exploration_id):
+        """Publish an exploration.
 
         Args:
             exploration_id: str. Id of the exploration.
-            make_public: bool. Whether to publish the exploration or
-                unpublish it.
 
         Raises:
             InvalidInputException: Given exploration is invalid.
         """
         exploration = exp_services.get_exploration_by_id(exploration_id)
-        if make_public:
-            try:
-                exploration.validate(strict=True)
-            except utils.ValidationError as e:
-                raise self.InvalidInputException(e)
+        try:
+            exploration.validate(strict=True)
+        except utils.ValidationError as e:
+            raise self.InvalidInputException(e)
 
-            exp_services.publish_exploration_and_update_user_profiles(
-                self.user_id, exploration_id)
-            exp_services.index_explorations_given_ids([exploration_id])
-        else:
-            rights_manager.unpublish_exploration(
-                self.user_id, exploration_id)
-            exp_services.delete_documents_from_search_index([
-                exploration_id])
+        exp_services.publish_exploration_and_update_user_profiles(
+            self.user_id, exploration_id)
+        exp_services.index_explorations_given_ids([exploration_id])
 
-    def _publicize_exploration(self, exploration_id, make_publicized):
-        """Publicize/Unpublicize and exploration based on make_publicized
-        boolean.
+    def _unpublicize_exploration(self, exploration_id):
+        """Unpublicize an exploration.
 
         Args:
             exploration_id: str. Id of the exploration.
-            make_publicized: bool. Whether to publicize the exploration or
-                unpublicize it.
 
         Raises:
             InvalidInputException: Given exploration is invalid.
         """
         exploration = exp_services.get_exploration_by_id(exploration_id)
-        if make_publicized:
-            try:
-                exploration.validate(strict=True)
-            except utils.ValidationError as e:
-                raise self.InvalidInputException(e)
+        try:
+            exploration.validate(strict=True)
+        except utils.ValidationError as e:
+            raise self.InvalidInputException(e)
 
-            rights_manager.publicize_exploration(
-                self.user_id, exploration_id)
-        else:
-            rights_manager.unpublicize_exploration(
-                self.user_id, exploration_id)
+        rights_manager.unpublicize_exploration(
+            self.user_id, exploration_id)
 
     @acl_decorators.can_publish_exploration
     def put(self, exploration_id):
         make_public = self.payload.get('make_public')
-        make_publicized = self.payload.get('make_publicized')
+        make_unpublicized = self.payload.get('make_unpublicized')
 
         if make_public is not None:
-            self._publish_exploration(exploration_id, make_public)
-        elif make_publicized is not None:
-            self._publicize_exploration(exploration_id, make_publicized)
+            self._publish_exploration(exploration_id)
+        elif make_unpublicized is not None:
+            self._unpublicize_exploration(exploration_id)
 
         self.render_json({
             'rights': rights_manager.get_exploration_rights(


Test patch: