Repository: oppia/oppia

Issue:
Clicking on any of the share links opens the exploration editor.
**How To Reproduce:**
- Create an exploration and publish it.
- Navigate to creator dashboard and switch to tile layout.
- Click on any of the sharing links.

**Observed Behavior:**
When any of the sharing links is clicked on the exploration summary card on creator dashboard, the exploration editor opens up.



Discussion:

Resolving patch:
diff --git a/core/domain/email_manager.py b/core/domain/email_manager.py
--- a/core/domain/email_manager.py
+++ b/core/domain/email_manager.py
@@ -154,7 +154,7 @@ def _require_sender_id_is_valid(intent, sender_id):
 
 def _send_email(
         recipient_id, sender_id, intent, email_subject, email_html_body,
-        bcc_admin=False):
+        sender_email, bcc_admin=False):
     """Sends an email to the given recipient.
 
     This function should be used for sending all user-facing emails.
@@ -187,14 +187,14 @@ def _send_email(
         return
 
     def _send_email_in_transaction():
-        sender_email = '%s <%s>' % (
-            EMAIL_SENDER_NAME.value, feconf.SYSTEM_EMAIL_ADDRESS)
+        sender_name_email = '%s <%s>' % (
+            EMAIL_SENDER_NAME.value, sender_email)
 
         email_services.send_mail(
-            sender_email, recipient_email, email_subject,
+            sender_name_email, recipient_email, email_subject,
             cleaned_plaintext_body, cleaned_html_body, bcc_admin)
         email_models.SentEmailModel.create(
-            recipient_id, recipient_email, sender_id, sender_email, intent,
+            recipient_id, recipient_email, sender_id, sender_name_email, intent,
             email_subject, cleaned_html_body, datetime.datetime.utcnow())
 
     return transaction_services.run_in_transaction(_send_email_in_transaction)
@@ -223,7 +223,7 @@ def send_post_signup_email(user_id):
 
     _send_email(
         user_id, feconf.SYSTEM_COMMITTER_ID, feconf.EMAIL_INTENT_SIGNUP,
-        email_subject, email_body)
+        email_subject, email_body, feconf.NOREPLY_EMAIL_ADDRESS)
 
 
 def require_valid_intent(intent):
@@ -288,7 +288,7 @@ def send_moderator_action_email(
             EMAIL_FOOTER.value))
     _send_email(
         recipient_id, sender_id, intent, email_subject, full_email_content,
-        bcc_admin=True)
+        feconf.SYSTEM_EMAIL_ADDRESS, bcc_admin=True)
 
 
 def send_role_notification_email(
@@ -355,7 +355,8 @@ def send_role_notification_email(
 
     _send_email(
         recipient_id, feconf.SYSTEM_COMMITTER_ID,
-        feconf.EMAIL_INTENT_EDITOR_ROLE_NOTIFICATION, email_subject, email_body)
+        feconf.EMAIL_INTENT_EDITOR_ROLE_NOTIFICATION, email_subject, email_body,
+        feconf.NOREPLY_EMAIL_ADDRESS)
 
 
 def send_feedback_message_email(recipient_id, feedback_messages):
@@ -408,5 +409,5 @@ def send_feedback_message_email(recipient_id, feedback_messages):
     _send_email(
         recipient_id, feconf.SYSTEM_COMMITTER_ID,
         feconf.EMAIL_INTENT_FEEDBACK_MESSAGE_NOTIFICATION,
-        email_subject, email_body)
+        email_subject, email_body, feconf.NOREPLY_EMAIL_ADDRESS)
 
diff --git a/feconf.py b/feconf.py
--- a/feconf.py
+++ b/feconf.py
@@ -174,6 +174,7 @@ def get_empty_ratings():
 SYSTEM_COMMITTER_ID = 'admin'
 SYSTEM_EMAIL_ADDRESS = 'system@example.com'
 ADMIN_EMAIL_ADDRESS = 'testadmin@example.com'
+NOREPLY_EMAIL_ADDRESS = 'noreply@example.com'
 # Ensure that SYSTEM_EMAIL_ADDRESS and ADMIN_EMAIL_ADDRESS are both valid and
 # correspond to owners of the app before setting this to True. If
 # SYSTEM_EMAIL_ADDRESS is not that of an app owner, email messages from this


Test patch:
diff --git a/core/domain/email_manager_test.py b/core/domain/email_manager_test.py
--- a/core/domain/email_manager_test.py
+++ b/core/domain/email_manager_test.py
@@ -166,7 +166,7 @@ def test_role_emails_sent_are_correct(self):
                 sent_email_model.sender_id, feconf.SYSTEM_COMMITTER_ID)
             self.assertEqual(
                 sent_email_model.sender_email,
-                'Site Admin <%s>' % feconf.SYSTEM_EMAIL_ADDRESS)
+                'Site Admin <%s>' % feconf.NOREPLY_EMAIL_ADDRESS)
             self.assertEqual(
                 sent_email_model.intent,
                 feconf.EMAIL_INTENT_EDITOR_ROLE_NOTIFICATION)
@@ -573,7 +573,7 @@ def test_contents_of_signup_email_are_correct(self):
 
             self.assertEqual(
                 messages[0].sender,
-                'Email Sender <%s>' % feconf.SYSTEM_EMAIL_ADDRESS)
+                'Email Sender <%s>' % feconf.NOREPLY_EMAIL_ADDRESS)
             self.assertEqual(messages[0].to, self.EDITOR_EMAIL)
             self.assertEqual(messages[0].subject, 'Welcome!')
             self.assertEqual(
@@ -695,7 +695,7 @@ def test_record_of_sent_email_is_written_to_datastore(self):
                 sent_email_model.sender_id, feconf.SYSTEM_COMMITTER_ID)
             self.assertEqual(
                 sent_email_model.sender_email,
-                'Email Sender <%s>' % feconf.SYSTEM_EMAIL_ADDRESS)
+                'Email Sender <%s>' % feconf.NOREPLY_EMAIL_ADDRESS)
             self.assertEqual(
                 sent_email_model.intent, feconf.EMAIL_INTENT_SIGNUP)
             self.assertEqual(
@@ -771,7 +771,8 @@ def _log_error_for_tests(error_message):
             # pylint: disable=protected-access
             email_manager._send_email(
                 self.new_user_id, feconf.SYSTEM_COMMITTER_ID,
-                feconf.EMAIL_INTENT_SIGNUP, 'Email Subject', 'Email Body')
+                feconf.EMAIL_INTENT_SIGNUP, 'Email Subject', 'Email Body',
+                feconf.SYSTEM_EMAIL_ADDRESS)
             # pylint: enable=protected-access
 
             # An error should be recorded in the logs.
@@ -814,7 +815,8 @@ def _log_error_for_tests(error_message):
             # pylint: disable=protected-access
             email_manager._send_email(
                 self.new_user_id, feconf.SYSTEM_COMMITTER_ID,
-                feconf.EMAIL_INTENT_SIGNUP, 'Email Subject', 'Email Body')
+                feconf.EMAIL_INTENT_SIGNUP, 'Email Subject', 'Email Body',
+                feconf.SYSTEM_EMAIL_ADDRESS)
 
             # Check that a new email was sent.
             messages = self.mail_stub.get_sent_messages(to=self.NEW_USER_EMAIL)
@@ -830,7 +832,8 @@ def _log_error_for_tests(error_message):
 
             email_manager._send_email(
                 self.new_user_id, feconf.SYSTEM_COMMITTER_ID,
-                feconf.EMAIL_INTENT_SIGNUP, 'Email Subject', 'Email Body')
+                feconf.EMAIL_INTENT_SIGNUP, 'Email Subject', 'Email Body',
+                feconf.SYSTEM_EMAIL_ADDRESS)
             # pylint: enable=protected-access
 
             # An error should be recorded in the logs.
@@ -872,7 +875,8 @@ def test_sending_email_with_different_recipient_but_same_hash(self):
             # pylint: disable=protected-access
             email_manager._send_email(
                 self.new_user_id, feconf.SYSTEM_COMMITTER_ID,
-                feconf.EMAIL_INTENT_SIGNUP, 'Email Subject', 'Email Body')
+                feconf.EMAIL_INTENT_SIGNUP, 'Email Subject', 'Email Body',
+                feconf.SYSTEM_EMAIL_ADDRESS)
             # pylint: enable=protected-access
 
             # Check that a new email was sent.
@@ -923,7 +927,8 @@ def test_sending_email_with_different_subject_but_same_hash(self):
             # pylint: disable=protected-access
             email_manager._send_email(
                 self.new_user_id, feconf.SYSTEM_COMMITTER_ID,
-                feconf.EMAIL_INTENT_SIGNUP, 'Email Subject', 'Email Body')
+                feconf.EMAIL_INTENT_SIGNUP, 'Email Subject', 'Email Body',
+                feconf.SYSTEM_EMAIL_ADDRESS)
             # pylint: enable=protected-access
 
             # Check that a new email was sent.
@@ -974,7 +979,8 @@ def test_sending_email_with_different_body_but_same_hash(self):
             # pylint: disable=protected-access
             email_manager._send_email(
                 self.new_user_id, feconf.SYSTEM_COMMITTER_ID,
-                feconf.EMAIL_INTENT_SIGNUP, 'Email Subject', 'Email Body')
+                feconf.EMAIL_INTENT_SIGNUP, 'Email Subject', 'Email Body',
+                feconf.SYSTEM_EMAIL_ADDRESS)
             # pylint: enable=protected-access
 
             # Check that a new email was sent.
@@ -1041,7 +1047,8 @@ def test_duplicate_emails_are_sent_after_some_time_has_elapsed(self):
             # pylint: disable=protected-access
             email_manager._send_email(
                 self.new_user_id, feconf.SYSTEM_COMMITTER_ID,
-                feconf.EMAIL_INTENT_SIGNUP, 'Email Subject', 'Email Body')
+                feconf.EMAIL_INTENT_SIGNUP, 'Email Subject', 'Email Body',
+                feconf.SYSTEM_EMAIL_ADDRESS)
             # pylint: enable=protected-access
 
             # Check that a new email was sent.
@@ -1146,7 +1153,7 @@ def test_correct_email_body_is_sent(self):
                 sent_email_model.sender_id, feconf.SYSTEM_COMMITTER_ID)
             self.assertEqual(
                 sent_email_model.sender_email,
-                'Site Admin <%s>' % feconf.SYSTEM_EMAIL_ADDRESS)
+                'Site Admin <%s>' % feconf.NOREPLY_EMAIL_ADDRESS)
             self.assertEqual(
                 sent_email_model.intent,
                 feconf.EMAIL_INTENT_FEEDBACK_MESSAGE_NOTIFICATION)