Repository: oppia/oppia

Issue:
Email from the Contributor Dashboard Team contains the wrong link
The emails from the Contributor Dashboard Team contains the wrong link. The hyperlink labeled "admin roles page" directs to "https://www.oppia.org/admin#/roles" which is an error page (see screenshot attached). It should redirect to "http://www.oppia.org/contributor-dashboard-admin". Please fix. 

![admin dashboard email](https://github.com/oppia/oppia/assets/102471032/479d1801-6d67-481b-9ffd-d8a0253501b8)

![admin error page](https://github.com/oppia/oppia/assets/102471032/b554ed0c-3f7b-44fa-8b79-5d623dd6f7cd)



Discussion:
Hey I would like to work on this issue. Please can you assign me?
I would love to work on this issue, it'll be nice if you could assign it to me.
Please mention the file name to make the changes
**Update on the Pull Request:**

Hello everyone,

I've submitted a pull request that addresses the issue mentioned in this thread. The pull request is titled: "Fix #19165: Update "admin roles page" link in notification email."

**Changes Introduced:**
- Updated the "admin roles page" link in the notification email to redirect correctly.

**Testing Done:**
- [x] Tested the changes locally and ensured that the notification email now contains the correct link.

**Request for Review:**
I would appreciate it if reviewers could take a look at the changes and provide feedback. Your insights will be valuable in ensuring the quality of the fix, and I'd love to contribute further in the Organisation.

Thank you!

@takshakmudgal I don't think your changes work. If you would like to take up this issue then please show proof that they do work by triggering the email being sent and showing what it looks like (when running this locally it will typically show up in your terminal server logs). See the guidance for claiming issues [here](https://github.com/oppia/oppia/wiki/Contributing-code-to-Oppia#how-to-tackle-good-first-issues). 

(The above also applies for anyone else who is interested in taking up this issue.)

Thanks!
can I work on this issue please assign me this issue
hii @seanlip i made the below change in the file location: /home/administrator/opensource/oppia/core/domain/email_manager.py
![Screenshot from 2023-11-22 23-34-22](https://github.com/oppia/oppia/assets/81969353/4281bf47-a87f-4240-903c-71cd2be8d50a)



could you please tell, how can i test is it logically right or not ?

@Preetam078 Try to trigger the function that sends it somehow (trace through the codebase to see what triggers it), and then look at your server terminal when it runs. The text of the sent email should appear there and you can check whether it is fully correct.
Hi @Preetam078 , I would like to work on this issue.
@seanlip I think we can fix it by using feconf.CONTRIBUTOR_DASHBOARD_ADMIN_URL instead feconf.ADMIN_URL and removing #/roles in ADMIN_NOTIFICATION_FOR_SUGGESTIONS_NEEDING_REVIEW_EMAIL_DATA declaration in `core/domain/email_manager.py`.

![image](https://github.com/oppia/oppia/assets/93824505/590d77c6-68a4-4051-bda8-90035c03e489)
Can I work in this issue.

@seanlip , @chris7716 Hey! I can't create PR can you help me with that.
hey i would like to work on the issue please assign me that issue
@jayam04 Please see https://github.com/oppia/oppia/issues/19157#issuecomment-1823715026. I need to see the proof that you've got it working and tested before I can assign you to the issue.

@Jatingupta9120 Please follow the instructions for claiming an issue, outlined [here](https://github.com/oppia/oppia/issues/19157#issuecomment-1815996169). Thanks.
@seanlip Please assign me this issue

1. I will modify the email template in core/domain/email_manager.py to correct the hyperlink for the "admin roles page."

**Before:**
`'<a href="%s%s#/roles">admin roles page</a> and either:'`

**After:**
`'<a href="%s%s">admin roles page</a> and either:'`

2. I will update the relevant code to use the correct URL for the admin roles page.

**Before**
`feconf.OPPIA_SITE_URL, feconf.ADMIN_URL,`

**After:**
`feconf.OPPIA_SITE_URL, feconf.CONTRIBUTOR_DASHBOARD_ADMIN_URL,`

I will ensure that the changes do not introduce any new issues by running unit tests. Additionally, I will manually test the email functionality to verify that the hyperlink now correctly directs users to the updated admin roles page URL.
('feconf.CONTRIBUTOR_DASHBOARD_ADMIN_URL').
@Parvezkhan0 See my [comment](https://github.com/oppia/oppia/issues/19157#issuecomment-1831950745) to @jayam04 above. I need to know that you know how to test this locally, which is why I need to see a screenshot of the email showing up in your local server terminal.
@seanlip I have seen your [comment](https://github.com/oppia/oppia/issues/19157#issuecomment-1823715026) before, I have doubts about testing locally as I think script requires google-cloud credentials to send email, which surely one won't have for local testing. Can you help me more about how to testing. 
Also I don't think testing is required as `feconf.ADMIN_URL` and `feconf.CONTRIBUTOR_DASHBOARD_ADMIN_URL` are literal strings which translates to `admin` and `contributor-dashboard-admin` respectively. So changing it will work as expected.
You will need to test and show proof that your changes work; this is not negotiable since we do not want to break the production servers for our end users.

You'll need to trace through the code to figure out how to trigger the email sending (it's fine to do it artificially, e.g. just call the function within your dev code) and the email should show up in your server logs. (See dev_mode_email_services.py for how this works locally -- instead of sending an email, it just prints it.)

If you need specific help, follow the instructions in https://github.com/oppia/oppia/wiki/Debugging-Docs to write a debugging doc and explain what you've done, so that folks can help you easily. Thanks.
hii @seanlip sorry i was off for quiet, could you please give the path to reproduce the "way to trigger the function in the test".
I don't have more to say than what I mentioned in the comment above. You'll need to trace through the code to understand how the email gets sent. If you have trouble then please document your investigation in a debugging doc so that we can help with the missing bits.
hi @seanlip
I have figured out the solution and successfully passed the backend tests. however, finally during manual testing in the local server during signing in as a super admin following network error in occurring,

ERROR:root:Frontend error: 
Error: A network error (such as timeout, interrupted connection or unreachable host) has occurred.

    at URL: http://localhost:8181/login?return_url=%2F
INFO     2023-12-01 15:02:13,811 module.py:883] default: "POST /frontend_errors HTTP/1.1" 200 30

If anyone can provide any help in figuring this out it would be really helpful in solving this issue.

edited: also while adding a new user in firebase authentication emulator suite is not responding.

Thank you and Regards
@masterboy376 can you help me with manual testing of code.
> @masterboy376 can you help me with manual testing of code.

Sure @jayam04 , as much as I could.
How are you calling function that triggers this email, I tried using dev_mode_email_services.py while server was running, but got error: google-cloud credentials required. Can you tell me how to tested manually (specifically how you got `at URL: http://localhost:8181/login?return_url=%2F` error)
> How are you calling function that triggers this email, I tried using dev_mode_email_services.py while server was running, but got error: google-cloud credentials required. Can you tell me how to tested manually (specifically how you got `at URL: http://localhost:8181/login?return_url=%2F` error)

I think you need to login first as admin and then try to call dev_mode_email_services.py while server is running

> How are you calling function that triggers this email, I tried using dev_mode_email_services.py while server was running, but got error: google-cloud credentials required. Can you tell me how to tested manually (specifically how you got `at URL: http://localhost:8181/login?return_url=%2F` error)

You need to sign in as an admin in a dev server and then try using dev_mode_email_service.py.
Hello @seanlip , I would like to work on this issue.

In "core/domain/email_manager.py" file I will make following code changes

![image](https://github.com/oppia/oppia/assets/119884665/49d8dd6d-eabd-4aa9-9427-fb59bd24804d)

![image](https://github.com/oppia/oppia/assets/119884665/183c0f6c-7a40-4f2d-8d24-cf6f566f4fb9)

In one terminal, I have opened shell of oppia-dev-server container (since I am using docker) and using 'curl' I have triggered 'cron' job which sends the email.('akashpaloju@gmail.com' is a super admin here )

![image](https://github.com/oppia/oppia/assets/119884665/0a42d95b-aa30-4a36-b76a-6d04c256acec)

In 2nd terminal I have opened logs of dev-server container, so when I trigger that particular cron job, the email body and  email details was logged in logs according to the code in  " core/platform/email/dev_mode_email_services.py " file
In  "dev_mode_email_services.py " file I have just added `logging.info(html_body)` line only to show the output (I will undo it.)

Logs: Arrow indicating new url link in href .

![logs-oppia](https://github.com/oppia/oppia/assets/119884665/70a0cabc-9813-4f8b-b8ef-f314554a566e)

In firebase I have created following users for testing,

![image](https://github.com/oppia/oppia/assets/119884665/3e35b02b-c972-4867-9a34-00f8df9062e7)

I request you to please assign me this issue. Thanks!
Thanks @AkashPaloju, looks pretty good. Feel free to take this issue, I've assigned you. Thanks! 

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
@@ -324,7 +324,7 @@
         'There are suggestions on the <a href="%s%s">Contributor Dashboard</a> '
         'that have been waiting for more than %s days for review. Please take '
         'a look at the suggestions mentioned below and help them get reviewed '
-        'by going to the <a href="%s%s#/roles">admin roles page</a> and either:'
+        'by going to the <a href="%s%s">admin roles page</a> and either:'
         '<br><br><ul>'
         '<li>Add more reviewers to the suggestion types that have suggestions '
         'waiting too long for a review</li><br>'
@@ -1761,7 +1761,7 @@ def _send_suggestions_waiting_too_long_email(
             curriculum_admin_usernames[index], feconf.OPPIA_SITE_URL,
             feconf.CONTRIBUTOR_DASHBOARD_URL,
             suggestion_models.SUGGESTION_REVIEW_WAIT_TIME_THRESHOLD_IN_DAYS,
-            feconf.OPPIA_SITE_URL, feconf.ADMIN_URL,
+            feconf.OPPIA_SITE_URL, feconf.CONTRIBUTOR_DASHBOARD_ADMIN_URL,
             list_of_suggestion_descriptions)
 
         _send_email(


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
@@ -4440,7 +4440,7 @@ def test_email_sent_to_admin_if_question_has_waited_too_long_for_a_review(
             '<a href="%s%s">Contributor Dashboard</a> that have been waiting '
             'for more than 0 days for review. Please take a look at the '
             'suggestions mentioned below and help them get reviewed by going '
-            'to the <a href="%s%s#/roles">admin roles page</a> and either:'
+            'to the <a href="%s%s">admin roles page</a> and either:'
             '<br><br><ul>'
             '<li>Add more reviewers to the suggestion types that have '
             'suggestions waiting too long for a review</li><br>'
@@ -4459,7 +4459,7 @@ def test_email_sent_to_admin_if_question_has_waited_too_long_for_a_review(
             'Best Wishes!<br><br>'
             '- The Oppia Contributor Dashboard Team' % (
                 feconf.OPPIA_SITE_URL, feconf.CONTRIBUTOR_DASHBOARD_URL,
-                feconf.OPPIA_SITE_URL, feconf.ADMIN_URL)
+                feconf.OPPIA_SITE_URL, feconf.CONTRIBUTOR_DASHBOARD_ADMIN_URL)
         )
 
         with self.can_send_emails_ctx, self.log_new_error_ctx:
@@ -4513,7 +4513,7 @@ def test_email_sent_to_admin_if_multiple_questions_have_waited_for_review(
             '<a href="%s%s">Contributor Dashboard</a> that have been waiting '
             'for more than 0 days for review. Please take a look at the '
             'suggestions mentioned below and help them get reviewed by going '
-            'to the <a href="%s%s#/roles">admin roles page</a> and either:'
+            'to the <a href="%s%s">admin roles page</a> and either:'
             '<br><br><ul>'
             '<li>Add more reviewers to the suggestion types that have '
             'suggestions waiting too long for a review</li><br>'
@@ -4535,7 +4535,7 @@ def test_email_sent_to_admin_if_multiple_questions_have_waited_for_review(
             'Best Wishes!<br><br>'
             '- The Oppia Contributor Dashboard Team' % (
                 feconf.OPPIA_SITE_URL, feconf.CONTRIBUTOR_DASHBOARD_URL,
-                feconf.OPPIA_SITE_URL, feconf.ADMIN_URL)
+                feconf.OPPIA_SITE_URL, feconf.CONTRIBUTOR_DASHBOARD_ADMIN_URL)
         )
 
         with self.can_send_emails_ctx, self.log_new_error_ctx:
@@ -4583,7 +4583,7 @@ def test_email_sent_to_admin_if_translation_has_waited_too_long_for_review(
             '<a href="%s%s">Contributor Dashboard</a> that have been waiting '
             'for more than 0 days for review. Please take a look at the '
             'suggestions mentioned below and help them get reviewed by going '
-            'to the <a href="%s%s#/roles">admin roles page</a> and either:'
+            'to the <a href="%s%s">admin roles page</a> and either:'
             '<br><br><ul>'
             '<li>Add more reviewers to the suggestion types that have '
             'suggestions waiting too long for a review</li><br>'
@@ -4602,7 +4602,7 @@ def test_email_sent_to_admin_if_translation_has_waited_too_long_for_review(
             'Best Wishes!<br><br>'
             '- The Oppia Contributor Dashboard Team' % (
                 feconf.OPPIA_SITE_URL, feconf.CONTRIBUTOR_DASHBOARD_URL,
-                feconf.OPPIA_SITE_URL, feconf.ADMIN_URL)
+                feconf.OPPIA_SITE_URL, feconf.CONTRIBUTOR_DASHBOARD_ADMIN_URL)
         )
 
         with self.can_send_emails_ctx, self.log_new_error_ctx:
@@ -4656,7 +4656,7 @@ def test_email_sent_to_admin_if_multi_translations_have_waited_for_review(
             '<a href="%s%s">Contributor Dashboard</a> that have been waiting '
             'for more than 0 days for review. Please take a look at the '
             'suggestions mentioned below and help them get reviewed by going '
-            'to the <a href="%s%s#/roles">admin roles page</a> and either:'
+            'to the <a href="%s%s">admin roles page</a> and either:'
             '<br><br><ul>'
             '<li>Add more reviewers to the suggestion types that have '
             'suggestions waiting too long for a review</li><br>'
@@ -4678,7 +4678,7 @@ def test_email_sent_to_admin_if_multi_translations_have_waited_for_review(
             'Best Wishes!<br><br>'
             '- The Oppia Contributor Dashboard Team' % (
                 feconf.OPPIA_SITE_URL, feconf.CONTRIBUTOR_DASHBOARD_URL,
-                feconf.OPPIA_SITE_URL, feconf.ADMIN_URL)
+                feconf.OPPIA_SITE_URL, feconf.CONTRIBUTOR_DASHBOARD_ADMIN_URL)
         )
 
         with self.can_send_emails_ctx, self.log_new_error_ctx:
@@ -4740,7 +4740,7 @@ def test_email_sent_to_admin_if_multi_suggestion_types_waiting_for_review(
             '<a href="%s%s">Contributor Dashboard</a> that have been waiting '
             'for more than 0 days for review. Please take a look at the '
             'suggestions mentioned below and help them get reviewed by going '
-            'to the <a href="%s%s#/roles">admin roles page</a> and either:'
+            'to the <a href="%s%s">admin roles page</a> and either:'
             '<br><br><ul>'
             '<li>Add more reviewers to the suggestion types that have '
             'suggestions waiting too long for a review</li><br>'
@@ -4762,7 +4762,7 @@ def test_email_sent_to_admin_if_multi_suggestion_types_waiting_for_review(
             'Best Wishes!<br><br>'
             '- The Oppia Contributor Dashboard Team' % (
                 feconf.OPPIA_SITE_URL, feconf.CONTRIBUTOR_DASHBOARD_URL,
-                feconf.OPPIA_SITE_URL, feconf.ADMIN_URL)
+                feconf.OPPIA_SITE_URL, feconf.CONTRIBUTOR_DASHBOARD_ADMIN_URL)
         )
 
         with self.can_send_emails_ctx, self.log_new_error_ctx:
@@ -4841,7 +4841,7 @@ def test_email_sent_to_multiple_admins(self) -> None:
             '<a href="%s%s">Contributor Dashboard</a> that have been waiting '
             'for more than 0 days for review. Please take a look at the '
             'suggestions mentioned below and help them get reviewed by going '
-            'to the <a href="%s%s#/roles">admin roles page</a> and either:'
+            'to the <a href="%s%s">admin roles page</a> and either:'
             '<br><br><ul>'
             '<li>Add more reviewers to the suggestion types that have '
             'suggestions waiting too long for a review</li><br>'
@@ -4860,7 +4860,7 @@ def test_email_sent_to_multiple_admins(self) -> None:
             'Best Wishes!<br><br>'
             '- The Oppia Contributor Dashboard Team' % (
                 feconf.OPPIA_SITE_URL, feconf.CONTRIBUTOR_DASHBOARD_URL,
-                feconf.OPPIA_SITE_URL, feconf.ADMIN_URL)
+                feconf.OPPIA_SITE_URL, feconf.CONTRIBUTOR_DASHBOARD_ADMIN_URL)
         )
         expected_email_html_body_admin_2 = (
             'Hi user2,'
@@ -4869,7 +4869,7 @@ def test_email_sent_to_multiple_admins(self) -> None:
             '<a href="%s%s">Contributor Dashboard</a> that have been waiting '
             'for more than 0 days for review. Please take a look at the '
             'suggestions mentioned below and help them get reviewed by going '
-            'to the <a href="%s%s#/roles">admin roles page</a> and either:'
+            'to the <a href="%s%s">admin roles page</a> and either:'
             '<br><br><ul>'
             '<li>Add more reviewers to the suggestion types that have '
             'suggestions waiting too long for a review</li><br>'
@@ -4888,7 +4888,7 @@ def test_email_sent_to_multiple_admins(self) -> None:
             'Best Wishes!<br><br>'
             '- The Oppia Contributor Dashboard Team' % (
                 feconf.OPPIA_SITE_URL, feconf.CONTRIBUTOR_DASHBOARD_URL,
-                feconf.OPPIA_SITE_URL, feconf.ADMIN_URL))
+                feconf.OPPIA_SITE_URL, feconf.CONTRIBUTOR_DASHBOARD_ADMIN_URL))
 
         with self.can_send_emails_ctx, self.log_new_error_ctx:
             with self.swap_get_platform_parameter_value, self.swap(