Repository: oppia/oppia

Issue:
Review message not shown in creator login after reviewer accepts the translation 

**Describe the bug**
Review message not shown in creator login after reviewer accepts the translation 

**To Reproduce**
Steps to reproduce the behavior:
 1. Go to 'oppiatestserver.org'
 2. Click on 'Contributor dashboard' from Account A
 3. Navigate to Translate Text and translate a text selecting a language and topic
 4. Now login to account B and select the same language and topic to review
 5. Review the text and accept it with some message 
 6. Now login to account A and check the message in Accepted translation 

**Observed behavior**
Reviewer message not shown from account A

**Expected behavior**
Message should be shown for accepted/rejected flows

**Screenshots**
![image](https://user-images.githubusercontent.com/56336353/163600535-ee5d1823-3079-4383-bd40-6cc9c96e9dc4.png)
![image](https://user-images.githubusercontent.com/56336353/163600558-e7d7029a-e5e9-4d86-a4b0-febf7c52b9f3.png)
Message shown for rejected translation
![image](https://user-images.githubusercontent.com/56336353/163600578-27beb52c-21a2-46a3-b402-30dbe09cdb40.png)

**Desktop (please complete the following information; delete this section if the issue does not arise on desktop):**
 OS: [Chrome OS]
Browser [chrome]
Browser-version [99.0.4844.86 (Official Build) (64-bit)]


Discussion:
Treating this as a regression for now since it's serious
@sagangwee PTAL
@bhavukJain Can you take a look at this?
@bhavukJain @sagangwee could you give an update on this? It's blocking the release
Hi, I am beginning to look at this. 
Hi, just want to double check, has this issue only recently surfaced and it was working fine earlier? That is, testing for this flow (i.e. checking whether review message appears or not for accepted suggestions) been only recently tested? Or was this flow tested earlier as well and the message was appearing before? 
@bhavukJain We can't really test this on prod very easily, so I don't know whether it happens there. Release testing isn't very prescriptive (on purpose so that testers explore more user paths), so last month's testers might not have explored this particular journey

Also, this is a bug that definitely could have gone unnoticed in prod because contributors might just assume the reviewer left no comments, and the reviewer never gets to see the contributor's view.
So it looks like we only intended to surface the review message for rejected translations (https://github.com/oppia/oppia/pull/11622). I believe this was because we assumed a review message for an accepted translation wouldn't be useful to the translator and would only be supplied by a reviewer for bookkeeping purposes. Though I suppose a reviewer could add a thank-you note or something similar.

We could either:
1. Hide the "Review message: " string for accepted translations and continue to not surface the review message for accepted translations.
2. Surface the review message for accepted translations.
@sagangwee I think this is your call as the team lead, but I'd favor option (2) because it keeps things consistent, and therefore (probably) simpler

Resolving patch:
diff --git a/core/controllers/contributor_dashboard.py b/core/controllers/contributor_dashboard.py
--- a/core/controllers/contributor_dashboard.py
+++ b/core/controllers/contributor_dashboard.py
@@ -150,7 +150,7 @@ def _get_skill_opportunities_with_corresponding_topic_name(self, cursor):
             classroom_topic_ids.extend(classroom_dict['topic_ids'])
         classroom_topics = topic_fetchers.get_topics_by_ids(classroom_topic_ids)
         # Associate each skill with one classroom topic name.
-        # TODO(#8912): Associate each skill/skill opportunity with  all linked
+        # TODO(#8912): Associate each skill/skill opportunity with all linked
         # topics.
         classroom_topic_skill_id_to_topic_name = {}
         for topic in classroom_topics:
@@ -506,8 +506,8 @@ def get(self):
         })
 
 
-class AllTopicNamesHandler(base.BaseHandler):
-    """Provides names of all existing topics in the datastore."""
+class TranslatableTopicNamesHandler(base.BaseHandler):
+    """Provides names of all translatable topics in the datastore."""
 
     GET_HANDLER_ERROR_RETURN_TYPE = feconf.HANDLER_TYPE_JSON
     URL_PATH_ARGS_SCHEMAS = {}
@@ -517,7 +517,8 @@ class AllTopicNamesHandler(base.BaseHandler):
 
     @acl_decorators.open_access
     def get(self):
-        topic_summaries = topic_fetchers.get_all_topic_summaries()
+        # Only published topics are translatable.
+        topic_summaries = topic_fetchers.get_published_topic_summaries()
         topic_names = [summary.name for summary in topic_summaries]
         self.values = {
             'topic_names': topic_names
diff --git a/core/domain/topic_fetchers.py b/core/domain/topic_fetchers.py
--- a/core/domain/topic_fetchers.py
+++ b/core/domain/topic_fetchers.py
@@ -336,6 +336,21 @@ def get_multi_topic_summaries(topic_ids):
     return topic_summaries
 
 
+def get_published_topic_summaries():
+    """Returns the summaries of all published topics present in the datastore.
+
+    Returns:
+        list(TopicSummary). The list of summaries of all published topics
+        present in the datastore.
+    """
+    topic_id_to_topic_rights = get_all_topic_rights()
+    published_topic_ids = [
+        topic_id
+        for topic_id, topic_rights in topic_id_to_topic_rights.items()
+        if topic_rights.topic_is_published]
+    return get_multi_topic_summaries(published_topic_ids)
+
+
 def get_all_skill_ids_assigned_to_some_topic():
     """Returns the ids of all the skills that are linked to some topics.
 
diff --git a/main.py b/main.py
--- a/main.py
+++ b/main.py
@@ -295,8 +295,8 @@ def get_redirect_route(
         r'/retrivefeaturedtranslationlanguages',
         contributor_dashboard.FeaturedTranslationLanguagesHandler),
     get_redirect_route(
-        r'/getalltopicnames',
-        contributor_dashboard.AllTopicNamesHandler),
+        r'/gettranslatabletopicnames',
+        contributor_dashboard.TranslatableTopicNamesHandler),
     get_redirect_route(
         r'%s' % feconf.NEW_SKILL_URL,
         topics_and_skills_dashboard.NewSkillHandler),


Test patch:
diff --git a/core/controllers/contributor_dashboard_test.py b/core/controllers/contributor_dashboard_test.py
--- a/core/controllers/contributor_dashboard_test.py
+++ b/core/controllers/contributor_dashboard_test.py
@@ -908,11 +908,11 @@ def test_get_featured_translation_languages(self):
         )
 
 
-class AllTopicNamesHandlerTest(test_utils.GenericTestBase):
-    """Test for the AllTopicNamesHandler."""
+class TranslatableTopicNamesHandlerTest(test_utils.GenericTestBase):
+    """Test for the TranslatableTopicNamesHandler."""
 
     def setUp(self):
-        super(AllTopicNamesHandlerTest, self).setUp()
+        super(TranslatableTopicNamesHandlerTest, self).setUp()
         self.signup(self.CURRICULUM_ADMIN_EMAIL, self.CURRICULUM_ADMIN_USERNAME)
         self.signup(self.OWNER_EMAIL, self.OWNER_USERNAME)
 
@@ -921,8 +921,8 @@ def setUp(self):
 
         self.set_curriculum_admins([self.CURRICULUM_ADMIN_USERNAME])
 
-    def test_get_all_topic_names(self):
-        response = self.get_json('/getalltopicnames')
+    def test_get_translatable_topic_names(self):
+        response = self.get_json('/gettranslatabletopicnames')
         self.assertEqual(
             response,
             {'topic_names': []}
@@ -940,9 +940,14 @@ def test_get_all_topic_names(self):
                 'dummy-subtopic-three')]
         topic.next_subtopic_id = 2
         topic_services.save_new_topic(self.owner_id, topic)
+
+        # Unpublished topics should not be returned.
+        response = self.get_json('/gettranslatabletopicnames')
+        self.assertEqual(len(response['topic_names']), 0)
+
         topic_services.publish_topic(topic_id, self.admin_id)
 
-        response = self.get_json('/getalltopicnames')
+        response = self.get_json('/gettranslatabletopicnames')
         self.assertEqual(
             response,
             {'topic_names': ['topic']}
diff --git a/core/domain/topic_fetchers_test.py b/core/domain/topic_fetchers_test.py
--- a/core/domain/topic_fetchers_test.py
+++ b/core/domain/topic_fetchers_test.py
@@ -342,6 +342,33 @@ def test_get_multi_summaries(self):
         self.assertEqual(topic_summaries[0].subtopic_count, 1)
         self.assertIsNone(topic_summaries[1])
 
+    def test_get_published_summaries(self):
+        # Unpublished topics should not be returned.
+        topic_summaries = topic_fetchers.get_published_topic_summaries()
+        self.assertEqual(len(topic_summaries), 0)
+
+        # Publish the topic.
+        changelist = [topic_domain.TopicChange({
+            'cmd': topic_domain.CMD_MOVE_SKILL_ID_TO_SUBTOPIC,
+            'old_subtopic_id': None,
+            'new_subtopic_id': self.subtopic_id,
+            'skill_id': self.skill_id_1
+        })]
+        topic_services.update_topic_and_subtopic_pages(
+            self.user_id_admin, self.TOPIC_ID, changelist,
+            'Updated subtopic skill ids.')
+        topic_services.publish_topic(self.TOPIC_ID, self.user_id_admin)
+
+        topic_summaries = topic_fetchers.get_published_topic_summaries()
+
+        self.assertEqual(len(topic_summaries), 1)
+        self.assertEqual(topic_summaries[0].name, 'Name')
+        self.assertEqual(topic_summaries[0].canonical_story_count, 0)
+        self.assertEqual(topic_summaries[0].additional_story_count, 0)
+        self.assertEqual(topic_summaries[0].total_skill_count, 2)
+        self.assertEqual(topic_summaries[0].uncategorized_skill_count, 1)
+        self.assertEqual(topic_summaries[0].subtopic_count, 1)
+
     def test_get_all_skill_ids_assigned_to_some_topic(self):
         change_list = [topic_domain.TopicChange({
             'cmd': topic_domain.CMD_MOVE_SKILL_ID_TO_SUBTOPIC,