From 7b4b6c3539d38e91fe776bfccc6c615d3fb26f5d Mon Sep 17 00:00:00 2001 From: Nimisha Asthagiri Date: Mon, 29 Apr 2019 03:13:54 -0400 Subject: [PATCH] Move notifier and notification_prefs to discussion/ --- .github/CODEOWNERS | 1 - lms/djangoapps/discussion/README.rst | 2 -- .../{ => discussion}/notification_prefs/README.rst | 0 .../{ => discussion}/notification_prefs/__init__.py | 0 .../notification_prefs/features/__init__.py | 0 .../notification_prefs/features/unsubscribe.feature | 0 .../notification_prefs/features/unsubscribe.py | 2 +- lms/djangoapps/{ => discussion}/notification_prefs/tests.py | 6 ++++-- lms/djangoapps/{ => discussion}/notification_prefs/views.py | 2 +- lms/djangoapps/{ => discussion}/notifier_api/README.rst | 0 lms/djangoapps/{ => discussion}/notifier_api/__init__.py | 0 lms/djangoapps/{ => discussion}/notifier_api/serializers.py | 2 +- lms/djangoapps/{ => discussion}/notifier_api/tests.py | 4 ++-- lms/djangoapps/{ => discussion}/notifier_api/urls.py | 2 +- lms/djangoapps/{ => discussion}/notifier_api/views.py | 4 ++-- lms/envs/common.py | 5 ----- lms/urls.py | 4 ++-- openedx/core/djangoapps/user_authn/views/register.py | 4 +++- .../core/djangoapps/user_authn/views/tests/test_register.py | 2 +- 19 files changed, 18 insertions(+), 22 deletions(-) rename lms/djangoapps/{ => discussion}/notification_prefs/README.rst (100%) rename lms/djangoapps/{ => discussion}/notification_prefs/__init__.py (100%) rename lms/djangoapps/{ => discussion}/notification_prefs/features/__init__.py (100%) rename lms/djangoapps/{ => discussion}/notification_prefs/features/unsubscribe.feature (100%) rename lms/djangoapps/{ => discussion}/notification_prefs/features/unsubscribe.py (90%) rename lms/djangoapps/{ => discussion}/notification_prefs/tests.py (97%) rename lms/djangoapps/{ => discussion}/notification_prefs/views.py (98%) rename lms/djangoapps/{ => discussion}/notifier_api/README.rst (100%) rename lms/djangoapps/{ => discussion}/notifier_api/__init__.py (100%) rename lms/djangoapps/{ => discussion}/notifier_api/serializers.py (96%) rename lms/djangoapps/{ => discussion}/notifier_api/tests.py (98%) rename lms/djangoapps/{ => discussion}/notifier_api/urls.py (80%) rename lms/djangoapps/{ => discussion}/notifier_api/views.py (89%) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index f6854e4c52a8..fb2367e6b18a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -23,7 +23,6 @@ common/lib/xmodule/xmodule/html_module.py @edx/platform-core-extensions common/lib/xmodule/xmodule/video_module @edx/platform-core-extensions lms/djangoapps/discussion/ @edx/platform-core-extensions lms/djangoapps/edxnotes @edx/platform-core-extensions -lms/djangoapps/notifier_api/ @edx/platform-core-extensions # Analytics common/djangoapps/track/ @edx/edx-data-engineering diff --git a/lms/djangoapps/discussion/README.rst b/lms/djangoapps/discussion/README.rst index fe28467f6592..dd85fe0516cb 100644 --- a/lms/djangoapps/discussion/README.rst +++ b/lms/djangoapps/discussion/README.rst @@ -10,8 +10,6 @@ Discussions related functionality is scattered across a number of places and sho * ``common/djangoapps/django_comment_common`` * ``lms/djangoapps/discussion`` -* ``lms/djangoapps/notification_prefs`` -* ``lms/djangoapps/notifier_api`` * ``openedx/core/lib/xblock_builtin/xblock_discussion`` Ideally, what we want in the long term is for all of this extracted into a new repository that holds the code for both the inline discussion XBlock as well as all the Django apps. Use of the notifier API should be replaced with edx-ace. diff --git a/lms/djangoapps/notification_prefs/README.rst b/lms/djangoapps/discussion/notification_prefs/README.rst similarity index 100% rename from lms/djangoapps/notification_prefs/README.rst rename to lms/djangoapps/discussion/notification_prefs/README.rst diff --git a/lms/djangoapps/notification_prefs/__init__.py b/lms/djangoapps/discussion/notification_prefs/__init__.py similarity index 100% rename from lms/djangoapps/notification_prefs/__init__.py rename to lms/djangoapps/discussion/notification_prefs/__init__.py diff --git a/lms/djangoapps/notification_prefs/features/__init__.py b/lms/djangoapps/discussion/notification_prefs/features/__init__.py similarity index 100% rename from lms/djangoapps/notification_prefs/features/__init__.py rename to lms/djangoapps/discussion/notification_prefs/features/__init__.py diff --git a/lms/djangoapps/notification_prefs/features/unsubscribe.feature b/lms/djangoapps/discussion/notification_prefs/features/unsubscribe.feature similarity index 100% rename from lms/djangoapps/notification_prefs/features/unsubscribe.feature rename to lms/djangoapps/discussion/notification_prefs/features/unsubscribe.feature diff --git a/lms/djangoapps/notification_prefs/features/unsubscribe.py b/lms/djangoapps/discussion/notification_prefs/features/unsubscribe.py similarity index 90% rename from lms/djangoapps/notification_prefs/features/unsubscribe.py rename to lms/djangoapps/discussion/notification_prefs/features/unsubscribe.py index 627816cb4207..60219b4d5ee0 100644 --- a/lms/djangoapps/notification_prefs/features/unsubscribe.py +++ b/lms/djangoapps/discussion/notification_prefs/features/unsubscribe.py @@ -1,7 +1,7 @@ from django.contrib.auth.models import User from lettuce import step, world -from notification_prefs import NOTIFICATION_PREF_KEY +from lms.djangoapps.discussion.notification_prefs import NOTIFICATION_PREF_KEY from openedx.core.djangoapps.user_api.preferences.api import get_user_preference, set_user_preference USERNAME = "robot" diff --git a/lms/djangoapps/notification_prefs/tests.py b/lms/djangoapps/discussion/notification_prefs/tests.py similarity index 97% rename from lms/djangoapps/notification_prefs/tests.py rename to lms/djangoapps/discussion/notification_prefs/tests.py index 54b50d447695..f44e0bc1f09b 100644 --- a/lms/djangoapps/notification_prefs/tests.py +++ b/lms/djangoapps/discussion/notification_prefs/tests.py @@ -9,8 +9,10 @@ from django.test.utils import override_settings from mock import patch -from notification_prefs import NOTIFICATION_PREF_KEY -from notification_prefs.views import UsernameCipher, ajax_disable, ajax_enable, ajax_status, set_subscription +from lms.djangoapps.discussion.notification_prefs import NOTIFICATION_PREF_KEY +from lms.djangoapps.discussion.notification_prefs.views import ( + UsernameCipher, ajax_disable, ajax_enable, ajax_status, set_subscription, +) from openedx.core.djangoapps.user_api.models import UserPreference from student.tests.factories import UserFactory from util.testing import UrlResetMixin diff --git a/lms/djangoapps/notification_prefs/views.py b/lms/djangoapps/discussion/notification_prefs/views.py similarity index 98% rename from lms/djangoapps/notification_prefs/views.py rename to lms/djangoapps/discussion/notification_prefs/views.py index 18c11f6b31e4..db21239f5748 100644 --- a/lms/djangoapps/notification_prefs/views.py +++ b/lms/djangoapps/discussion/notification_prefs/views.py @@ -22,7 +22,7 @@ from six import text_type from edxmako.shortcuts import render_to_response -from notification_prefs import NOTIFICATION_PREF_KEY +from lms.djangoapps.discussion.notification_prefs import NOTIFICATION_PREF_KEY from openedx.core.djangoapps.user_api.models import UserPreference from openedx.core.djangoapps.user_api.preferences.api import delete_user_preference diff --git a/lms/djangoapps/notifier_api/README.rst b/lms/djangoapps/discussion/notifier_api/README.rst similarity index 100% rename from lms/djangoapps/notifier_api/README.rst rename to lms/djangoapps/discussion/notifier_api/README.rst diff --git a/lms/djangoapps/notifier_api/__init__.py b/lms/djangoapps/discussion/notifier_api/__init__.py similarity index 100% rename from lms/djangoapps/notifier_api/__init__.py rename to lms/djangoapps/discussion/notifier_api/__init__.py diff --git a/lms/djangoapps/notifier_api/serializers.py b/lms/djangoapps/discussion/notifier_api/serializers.py similarity index 96% rename from lms/djangoapps/notifier_api/serializers.py rename to lms/djangoapps/discussion/notifier_api/serializers.py index e20796a3cf50..e886e815609a 100644 --- a/lms/djangoapps/notifier_api/serializers.py +++ b/lms/djangoapps/discussion/notifier_api/serializers.py @@ -2,7 +2,7 @@ from django.http import Http404 from rest_framework import serializers -from lms.djangoapps.notification_prefs import NOTIFICATION_PREF_KEY +from lms.djangoapps.discussion.notification_prefs import NOTIFICATION_PREF_KEY from openedx.core.djangoapps.course_groups.cohorts import is_course_cohorted from openedx.core.djangoapps.lang_pref import LANGUAGE_KEY diff --git a/lms/djangoapps/notifier_api/tests.py b/lms/djangoapps/discussion/notifier_api/tests.py similarity index 98% rename from lms/djangoapps/notifier_api/tests.py rename to lms/djangoapps/discussion/notifier_api/tests.py index 3ede34e2c338..ea9e686d376d 100644 --- a/lms/djangoapps/notifier_api/tests.py +++ b/lms/djangoapps/discussion/notifier_api/tests.py @@ -8,8 +8,8 @@ from opaque_keys.edx.locator import CourseLocator from django_comment_common.models import Permission, Role -from notification_prefs import NOTIFICATION_PREF_KEY -from notifier_api.views import NotifierUsersViewSet +from lms.djangoapps.discussion.notification_prefs import NOTIFICATION_PREF_KEY +from lms.djangoapps.discussion.notifier_api.views import NotifierUsersViewSet from openedx.core.djangoapps.course_groups.tests.helpers import CohortFactory from openedx.core.djangoapps.lang_pref import LANGUAGE_KEY from openedx.core.djangoapps.user_api.models import UserPreference diff --git a/lms/djangoapps/notifier_api/urls.py b/lms/djangoapps/discussion/notifier_api/urls.py similarity index 80% rename from lms/djangoapps/notifier_api/urls.py rename to lms/djangoapps/discussion/notifier_api/urls.py index b5ee7726704f..14b4bc1b06b6 100644 --- a/lms/djangoapps/notifier_api/urls.py +++ b/lms/djangoapps/discussion/notifier_api/urls.py @@ -5,7 +5,7 @@ from django.conf.urls import include, url from rest_framework import routers -from notifier_api.views import NotifierUsersViewSet +from lms.djangoapps.discussion.notifier_api.views import NotifierUsersViewSet notifier_api_router = routers.DefaultRouter() notifier_api_router.register(r'users', NotifierUsersViewSet, base_name="notifier_users") diff --git a/lms/djangoapps/notifier_api/views.py b/lms/djangoapps/discussion/notifier_api/views.py similarity index 89% rename from lms/djangoapps/notifier_api/views.py rename to lms/djangoapps/discussion/notifier_api/views.py index 2786cfb96a4e..71fe38cf036d 100644 --- a/lms/djangoapps/notifier_api/views.py +++ b/lms/djangoapps/discussion/notifier_api/views.py @@ -3,8 +3,8 @@ from rest_framework.response import Response from rest_framework.viewsets import ReadOnlyModelViewSet -from notification_prefs import NOTIFICATION_PREF_KEY -from notifier_api.serializers import NotifierUserSerializer +from lms.djangoapps.discussion.notification_prefs import NOTIFICATION_PREF_KEY +from lms.djangoapps.discussion.notifier_api.serializers import NotifierUserSerializer from openedx.core.lib.api.permissions import ApiKeyHeaderPermission diff --git a/lms/envs/common.py b/lms/envs/common.py index ee8799917115..172aab6919d3 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -2139,11 +2139,6 @@ def _make_locale_paths(settings): # Shopping cart 'shoppingcart', - # Notification preferences setting - 'notification_prefs', - - 'notifier_api', - # Different Course Modes 'course_modes.apps.CourseModesConfig', diff --git a/lms/urls.py b/lms/urls.py index de454a14aa79..5be7a50ea053 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -21,12 +21,12 @@ from django_comment_common.models import ForumsConfig from lms.djangoapps.certificates import views as certificates_views from lms.djangoapps.discussion import views as discussion_views +from lms.djangoapps.discussion.notification_prefs import views as notification_prefs_views from lms.djangoapps.instructor.views import coupons as instructor_coupons_views from lms.djangoapps.instructor.views import instructor_dashboard as instructor_dashboard_views from lms.djangoapps.instructor.views import registration_codes as instructor_registration_codes_views from lms.djangoapps.instructor_task import views as instructor_task_views from notes import views as notes_views -from notification_prefs import views as notification_prefs_views from openedx.core.djangoapps.auth_exchange.views import LoginWithAccessTokenView from openedx.core.djangoapps.catalog.models import CatalogIntegration from openedx.core.djangoapps.common_views.xblock import xblock_resource @@ -84,7 +84,7 @@ # subsumed by api/user listed below. url(r'^user_api/', include('openedx.core.djangoapps.user_api.legacy_urls')), - url(r'^notifier_api/', include('notifier_api.urls')), + url(r'^notifier_api/', include('lms.djangoapps.discussion.notifier_api.urls')), url(r'^i18n/', include('django.conf.urls.i18n')), diff --git a/openedx/core/djangoapps/user_authn/views/register.py b/openedx/core/djangoapps/user_authn/views/register.py index f969bf92ab94..43ee1acf829e 100644 --- a/openedx/core/djangoapps/user_authn/views/register.py +++ b/openedx/core/djangoapps/user_authn/views/register.py @@ -15,8 +15,10 @@ from django.dispatch import Signal from django.utils.translation import get_language from django.utils.translation import ugettext as _ + # Note that this lives in LMS, so this dependency should be refactored. -from notification_prefs.views import enable_notifications +# TODO Have the discussions code subscribe to the REGISTER_USER signal instead. +from lms.djangoapps.discussion.notification_prefs.views import enable_notifications from pytz import UTC from requests import HTTPError from six import text_type diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_register.py b/openedx/core/djangoapps/user_authn/views/tests/test_register.py index 78874e0cefbc..1da4cad5bde3 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_register.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_register.py @@ -17,7 +17,7 @@ from django.contrib.auth.hashers import make_password from django_comment_common.models import ForumsConfig -from notification_prefs import NOTIFICATION_PREF_KEY +from lms.djangoapps.discussion.notification_prefs import NOTIFICATION_PREF_KEY from openedx.core.djangoapps.user_authn.views.register import ( REGISTRATION_AFFILIATE_ID, REGISTRATION_UTM_CREATED_AT, REGISTRATION_UTM_PARAMETERS, _skip_activation_email,