Repository: oppia/oppia

Issue:
Remove unneeded constants
We used `constants.ENABLE_ACCOUNT_DELETION` and `constants.ENABLE_ACCOUNT_EXPORT` while we were implementing the deletion and export features. Right now these constants are always set to `true` and no longer needed, thus they can be fully removed from the codebase.

Steps to work on this issue:
1. Pick one of the constants.
2. Search the constant in the codebase and remove it from everywhere.
3. Make sure that all tests are passing.

- `constants.ENABLE_ACCOUNT_DELETION`
- `constants.ENABLE_ACCOUNT_EXPORT`
Remove unneeded constants
We used `constants.ENABLE_ACCOUNT_DELETION` and `constants.ENABLE_ACCOUNT_EXPORT` while we were implementing the deletion and export features. Right now these constants are always set to `true` and no longer needed, thus they can be fully removed from the codebase.

Steps to work on this issue:
1. Pick one of the constants.
2. Search the constant in the codebase and remove it from everywhere.
3. Make sure that all tests are passing.

- `constants.ENABLE_ACCOUNT_DELETION`
- `constants.ENABLE_ACCOUNT_EXPORT`


Discussion:
Hi, i would like to work on this issue
@himanshu007-creator I have assigned you `constants.ENABLE_ACCOUNT_DELETION`
hi, i would also like to work on this

Hi I would like to work on this issue
```constants.ENABLE_ACCOUNT_EXPORT``` also which file is this?
Hey, I would also like to work on this.
Hey, I would like to work on this.

@Aarjav-Jain Done.

@raghavTinker @mohithk100 @adi-214 Sorry, everything is taken already.
@vojtechjelinek I know this issue has been assigned and solved but can you explain the process of doing it ? like finding it in which file and everything. I am new to open source so just want to learn all of it.
> @vojtechjelinek I know this issue has been assigned and solved but can you explain the process of doing it ? like finding it in which file and everything. I am new to open source so just want to learn all of it.

@ABHIGPT401 you can do a global search in codebase for finding these constants. These are defined here in [constants.ts](https://github.com/oppia/oppia/blob/develop/assets/constants.ts) file. The issue aims at removing all instances of these constants eg.`ENABLE_ACCOUNT_EXPORT` all throughout the codebase(in whatsoever file they are present).
Got it! Thank You so much @mridul-netizen !
Hi! @vojtechjelinek I would also like to work on this issue.
@rishidyno Everything in this issue is already taken.
> @rishidyno Everything in this issue is already taken.

Ok! no problem will work on some other issue then.
Is there any task open in this issue? @vojtechjelinek 
Hi @vojtechjelinek! I see it has been plenty of time since the issue was opened and is not closed yet.

If there's anything available to work on, I'd love to. Thanks.
Hi, i would like to work on this issue
@himanshu007-creator I have assigned you `constants.ENABLE_ACCOUNT_DELETION`
hi, i would also like to work on this

Hi I would like to work on this issue
```constants.ENABLE_ACCOUNT_EXPORT``` also which file is this?
Hey, I would also like to work on this.
Hey, I would like to work on this.

@Aarjav-Jain Done.

@raghavTinker @mohithk100 @adi-214 Sorry, everything is taken already.
@vojtechjelinek I know this issue has been assigned and solved but can you explain the process of doing it ? like finding it in which file and everything. I am new to open source so just want to learn all of it.
> @vojtechjelinek I know this issue has been assigned and solved but can you explain the process of doing it ? like finding it in which file and everything. I am new to open source so just want to learn all of it.

@ABHIGPT401 you can do a global search in codebase for finding these constants. These are defined here in [constants.ts](https://github.com/oppia/oppia/blob/develop/assets/constants.ts) file. The issue aims at removing all instances of these constants eg.`ENABLE_ACCOUNT_EXPORT` all throughout the codebase(in whatsoever file they are present).
Got it! Thank You so much @mridul-netizen !
Hi! @vojtechjelinek I would also like to work on this issue.
@rishidyno Everything in this issue is already taken.
> @rishidyno Everything in this issue is already taken.

Ok! no problem will work on some other issue then.
Is there any task open in this issue? @vojtechjelinek 
Hi @vojtechjelinek! I see it has been plenty of time since the issue was opened and is not closed yet.

If there's anything available to work on, I'd love to. Thanks.

Resolving patch:
diff --git a/core/controllers/access_validators.py b/core/controllers/access_validators.py
--- a/core/controllers/access_validators.py
+++ b/core/controllers/access_validators.py
@@ -17,7 +17,6 @@
 from __future__ import annotations
 
 from core import feconf
-from core.constants import constants
 from core.controllers import acl_decorators
 from core.controllers import base
 from core.domain import classroom_services
@@ -123,30 +122,6 @@ def get(self, username: str) -> None:
             raise self.PageNotFoundException
 
 
-class AccountDeletionIsEnabledValidationHandler(base.BaseHandler):
-    """Checks whether account deletion is enabled."""
-
-    GET_HANDLER_ERROR_RETURN_TYPE = feconf.HANDLER_TYPE_JSON
-
-    # Type[str, Any] is used to match the type defined for this attribute in
-    # its parent class `base.BaseHandler`.
-    URL_PATH_ARGS_SCHEMAS: Dict[str, Any] = {}
-
-    # Type[str, Any] is used to match the type defined for this attribute in
-    # its parent class `base.BaseHandler`.
-    HANDLER_ARGS_SCHEMAS: Dict[str, Any] = {
-        'GET': {}
-    }
-
-    # Using type ignore[misc] here because untyped decorator makes function
-    # "get" also untyped.
-    @acl_decorators.open_access # type: ignore[misc]
-    def get(self) -> None:
-        """Handles GET requests."""
-        if not constants.ENABLE_ACCOUNT_DELETION:
-            raise self.PageNotFoundException
-
-
 class ReleaseCoordinatorAccessValidationHandler(base.BaseHandler):
     """Validates access to release coordinator page."""
 
diff --git a/core/controllers/profile.py b/core/controllers/profile.py
--- a/core/controllers/profile.py
+++ b/core/controllers/profile.py
@@ -24,7 +24,6 @@
 
 from core import feconf
 from core import utils
-from core.constants import constants
 from core.controllers import acl_decorators
 from core.controllers import base
 from core.domain import email_manager
@@ -404,9 +403,6 @@ class DeleteAccountHandler(base.BaseHandler):
     @acl_decorators.can_manage_own_account
     def delete(self):
         """Handles DELETE requests."""
-        if not constants.ENABLE_ACCOUNT_DELETION:
-            raise self.PageNotFoundException
-
         wipeout_service.pre_delete_user(self.user_id)
         self.render_json({'success': True})
 
@@ -419,9 +415,6 @@ class ExportAccountHandler(base.BaseHandler):
     @acl_decorators.can_manage_own_account
     def get(self):
         """Handles GET requests."""
-        if not constants.ENABLE_ACCOUNT_EXPORT:
-            raise self.PageNotFoundException
-
         # Retrieve user data.
         user_takeout_object = takeout_service.export_data_for_user(
             self.user_id)
diff --git a/main.py b/main.py
--- a/main.py
+++ b/main.py
@@ -219,11 +219,6 @@ def get_redirect_route(
         feconf.ACCESS_VALIDATION_HANDLER_PREFIX,
         access_validators.ProfileExistsValidationHandler),
 
-    get_redirect_route(
-        r'%s/account_deletion_is_enabled' %
-        feconf.ACCESS_VALIDATION_HANDLER_PREFIX,
-        access_validators.AccountDeletionIsEnabledValidationHandler),
-
     get_redirect_route(
         r'%s/can_access_release_coordinator_page' %
         feconf.ACCESS_VALIDATION_HANDLER_PREFIX,


Test patch:
diff --git a/core/controllers/access_validators_test.py b/core/controllers/access_validators_test.py
--- a/core/controllers/access_validators_test.py
+++ b/core/controllers/access_validators_test.py
@@ -17,7 +17,6 @@
 from __future__ import annotations
 
 from core import feconf
-from core.constants import constants
 from core.domain import config_services
 from core.tests import test_utils
 
@@ -92,27 +91,6 @@ def test_release_coordinator_passes_validation(self) -> None:
             ACCESS_VALIDATION_HANDLER_PREFIX)
 
 
-class AccountDeletionIsEnabledValidationHandlerTests(
-        test_utils.GenericTestBase):
-
-    def setUp(self) -> None:
-        super(AccountDeletionIsEnabledValidationHandlerTests, self).setUp()
-        self.signup(self.EDITOR_EMAIL, self.EDITOR_USERNAME)
-        self.login(self.EDITOR_EMAIL)
-
-    def test_delete_account_validation_returns_true_if_enabled(self) -> None:
-        with self.swap(constants, 'ENABLE_ACCOUNT_DELETION', True):
-            self.get_html_response( # type: ignore[no-untyped-call]
-                '%s/account_deletion_is_enabled' %
-                ACCESS_VALIDATION_HANDLER_PREFIX)
-
-    def test_delete_account_validation_returns_false_if_disabled(self) -> None:
-        with self.swap(constants, 'ENABLE_ACCOUNT_DELETION', False):
-            self.get_json(
-                '%s/account_deletion_is_enabled' %
-                ACCESS_VALIDATION_HANDLER_PREFIX, expected_status_int=404)
-
-
 class ProfileExistsValidationHandlerTests(test_utils.GenericTestBase):
 
     def setUp(self) -> None:
diff --git a/core/controllers/profile_test.py b/core/controllers/profile_test.py
--- a/core/controllers/profile_test.py
+++ b/core/controllers/profile_test.py
@@ -811,9 +811,8 @@ def setUp(self):
         self.login(self.EDITOR_EMAIL)
 
     def test_get_delete_account_page(self):
-        with self.swap(constants, 'ENABLE_ACCOUNT_DELETION', True):
-            response = self.get_html_response('/delete-account')
-            self.assertIn(b'<oppia-root></oppia-root>', response.body)
+        response = self.get_html_response('/delete-account')
+        self.assertIn(b'<oppia-root></oppia-root>', response.body)
 
 
 class BulkEmailWebhookEndpointTests(test_utils.GenericTestBase):
@@ -908,13 +907,8 @@ def setUp(self):
         self.login(self.EDITOR_EMAIL)
 
     def test_delete_delete_account_page(self):
-        with self.swap(constants, 'ENABLE_ACCOUNT_DELETION', True):
-            data = self.delete_json('/delete-account-handler')
-            self.assertEqual(data, {'success': True})
-
-    def test_delete_delete_account_page_disabled(self):
-        with self.swap(constants, 'ENABLE_ACCOUNT_DELETION', False):
-            self.delete_json('/delete-account-handler', expected_status_int=404)
+        data = self.delete_json('/delete-account-handler')
+        self.assertEqual(data, {'success': True})
 
 
 class ExportAccountHandlerTests(test_utils.GenericTestBase):
@@ -970,11 +964,10 @@ def test_export_account_handler(self):
             deleted=user_settings.deleted
         ).put()
 
-        constants_swap = self.swap(constants, 'ENABLE_ACCOUNT_EXPORT', True)
         time_swap = self.swap(
             user_services, 'record_user_logged_in', lambda *args: None)
 
-        with constants_swap, time_swap:
+        with time_swap:
             data = self.get_custom_response(
                 '/export-account-handler', 'text/plain')
 
@@ -1033,11 +1026,10 @@ def test_data_does_not_export_if_user_id_leaked(self):
             deleted=user_settings.deleted
         ).put()
 
-        constants_swap = self.swap(constants, 'ENABLE_ACCOUNT_EXPORT', True)
         time_swap = self.swap(
             user_services, 'record_user_logged_in', lambda *args: None)
 
-        with constants_swap, time_swap:
+        with time_swap:
             data = self.get_custom_response(
                 '/export-account-handler', 'text/plain')
 
@@ -1054,27 +1046,16 @@ def test_data_does_not_export_if_user_id_leaked(self):
                 ]
             )
 
-    def test_export_account_handler_disabled_logged_in(self):
-        with self.swap(constants, 'ENABLE_ACCOUNT_EXPORT', False):
-            self.get_json('/export-account-handler', expected_status_int=404)
-
-    def test_export_account_hander_disabled_logged_out(self):
-        self.logout()
-        with self.swap(constants, 'ENABLE_ACCOUNT_EXPORT', False):
-            self.get_json('/export-account-handler', expected_status_int=401)
-
     def test_export_account_handler_enabled_logged_out(self):
         self.logout()
-        with self.swap(constants, 'ENABLE_ACCOUNT_EXPORT', True):
-            self.get_json('/export-account-handler', expected_status_int=401)
+        self.get_json('/export-account-handler', expected_status_int=401)
 
 
 class PendingAccountDeletionPageTests(test_utils.GenericTestBase):
 
     def test_get_pending_account_deletion_page(self):
-        with self.swap(constants, 'ENABLE_ACCOUNT_DELETION', True):
-            response = self.get_html_response('/pending-account-deletion')
-            self.assertIn(b'<oppia-root></oppia-root>', response.body)
+        response = self.get_html_response('/pending-account-deletion')
+        self.assertIn(b'<oppia-root></oppia-root>', response.body)
 
 
 class UsernameCheckHandlerTests(test_utils.GenericTestBase):
diff --git a/scripts/run_lighthouse_tests.py b/scripts/run_lighthouse_tests.py
--- a/scripts/run_lighthouse_tests.py
+++ b/scripts/run_lighthouse_tests.py
@@ -197,10 +197,6 @@ def main(args=None):
         run_webpack_compilation()
 
     with contextlib.ExitStack() as stack:
-        stack.enter_context(common.inplace_replace_file_context(
-            common.CONSTANTS_FILE_PATH,
-            '"ENABLE_ACCOUNT_DELETION": .*',
-            '"ENABLE_ACCOUNT_DELETION": true,'))
         stack.enter_context(servers.managed_redis_server())
         stack.enter_context(servers.managed_elasticsearch_dev_server())