INCR-196 Migrating common/djanjoapps/student/signals and views (#20138)

This commit is contained in:
Jolyon Bloomfield
2019-04-03 15:16:55 -04:00
committed by Jeremy Bowman
parent eff3a07005
commit 26351509ee
6 changed files with 39 additions and 42 deletions

View File

@@ -1,7 +1,9 @@
from __future__ import absolute_import
from student.signals.signals import (
ENROLLMENT_TRACK_UPDATED,
UNENROLL_DONE,
ENROLL_STATUS_CHANGE,
ENROLLMENT_TRACK_UPDATED,
REFUND_ORDER,
SAILTHRU_AUDIT_PURCHASE
SAILTHRU_AUDIT_PURCHASE,
UNENROLL_DONE
)

View File

@@ -7,14 +7,8 @@ from django.conf import settings
from django.utils import timezone
from openedx.core.djangoapps.user_api.config.waffle import PREVENT_AUTH_USER_WRITES, waffle
from student.helpers import (
AccountValidationError,
USERNAME_EXISTS_MSG_FMT
)
from student.models import (
is_email_retired,
is_username_retired,
)
from student.helpers import USERNAME_EXISTS_MSG_FMT, AccountValidationError
from student.models import is_email_retired, is_username_retired
def update_last_login(sender, user, **kwargs): # pylint: disable=unused-argument

View File

@@ -1,6 +1,8 @@
"""
Enrollment track related signals.
"""
from __future__ import absolute_import
from django.dispatch import Signal
ENROLLMENT_TRACK_UPDATED = Signal(providing_args=['user', 'course_key'])

View File

@@ -2,6 +2,7 @@
Combines all of the broken out student views
"""
# pylint: disable=wildcard-import
from dashboard import *
from management import *
from __future__ import absolute_import
from .dashboard import * # pylint: disable=wildcard-import
from .management import * # pylint: disable=wildcard-import

View File

@@ -2,6 +2,8 @@
Dashboard view and supporting methods
"""
from __future__ import absolute_import
import datetime
import logging
from collections import defaultdict
@@ -11,14 +13,14 @@ from completion.utilities import get_key_to_last_completed_course_block
from django.conf import settings
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.urls import reverse
from django.shortcuts import redirect
from django.urls import reverse
from django.utils.translation import ugettext as _
from django.views.decorators.csrf import ensure_csrf_cookie
from edx_django_utils import monitoring as monitoring_utils
from opaque_keys.edx.keys import CourseKey
from pytz import UTC
from six import text_type, iteritems
from six import iteritems, text_type
import track.views
from bulk_email.models import BulkEmailFlag, Optout # pylint: disable=import-error
@@ -27,6 +29,7 @@ from courseware.access import has_access
from edxmako.shortcuts import render_to_response, render_to_string
from entitlements.models import CourseEntitlement
from lms.djangoapps.commerce.utils import EcommerceService # pylint: disable=import-error
from lms.djangoapps.experiments.utils import get_dashboard_course_info, get_experiment_dashboard_metadata_context
from lms.djangoapps.verify_student.services import IDVerificationService
from openedx.core.djangoapps.catalog.utils import (
get_programs,
@@ -37,16 +40,15 @@ from openedx.core.djangoapps.credit.email_utils import get_credit_provider_attri
from openedx.core.djangoapps.programs.models import ProgramsApiConfig
from openedx.core.djangoapps.programs.utils import ProgramDataExtender, ProgramProgressMeter
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.user_api.accounts.utils import is_secondary_email_feature_enabled_for_user
from openedx.core.djangoapps.user_authn.cookies import set_logged_in_cookies
from openedx.core.djangoapps.util.maintenance_banner import add_maintenance_banner
from openedx.core.djangoapps.waffle_utils import WaffleFlag, WaffleFlagNamespace
from openedx.core.djangoapps.user_api.accounts.utils import is_secondary_email_feature_enabled_for_user
from openedx.core.djangolib.markup import HTML, Text
from openedx.features.enterprise_support.api import get_dashboard_consent_notification
from lms.djangoapps.experiments.utils import get_experiment_dashboard_metadata_context, get_dashboard_course_info
from openedx.features.journals.api import journals_enabled
from shoppingcart.api import order_history
from shoppingcart.models import CourseRegistrationCode, DonationConfiguration
from openedx.core.djangoapps.user_authn.cookies import set_logged_in_cookies
from student.helpers import cert_info, check_verify_status_by_course
from student.models import (
AccountRecovery,
@@ -471,7 +473,7 @@ def _credit_statuses(user, course_enrollments):
for attribute in CourseEnrollmentAttribute.objects.filter(
namespace="credit",
name="provider_id",
enrollment__in=credit_enrollments.values()
enrollment__in=list(credit_enrollments.values())
).select_related("enrollment")
}
@@ -705,7 +707,7 @@ def student_dashboard(request):
bundles_on_dashboard_flag = WaffleFlag(experiments_namespace, u'bundles_on_dashboard')
# TODO: Delete this code and the relevant HTML code after testing LEARNER-3072 is complete
if bundles_on_dashboard_flag.is_enabled() and inverted_programs and inverted_programs.items():
if bundles_on_dashboard_flag.is_enabled() and inverted_programs and list(inverted_programs.items()):
if len(course_enrollments) < 4:
for program in inverted_programs.values():
try:

View File

@@ -2,22 +2,22 @@
Student Views
"""
from __future__ import absolute_import
import datetime
import logging
import uuid
from collections import namedtuple
from bulk_email.models import Optout
from courseware.courses import get_courses, sort_by_announcement, sort_by_start_date
import six
from django.conf import settings
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import AnonymousUser, User
from django.contrib.auth.views import password_reset_confirm
from django.contrib.sites.models import Site
from django.core.exceptions import ObjectDoesNotExist
from django.core import mail
from django.urls import reverse
from django.core.exceptions import ObjectDoesNotExist
from django.core.validators import ValidationError, validate_email
from django.db import transaction
from django.db.models.signals import post_save
@@ -26,11 +26,12 @@ from django.http import Http404, HttpResponse, HttpResponseBadRequest, HttpRespo
from django.shortcuts import redirect
from django.template.context_processors import csrf
from django.template.response import TemplateResponse
from django.urls import reverse
from django.utils.encoding import force_bytes, force_text
from django.utils.http import base36_to_int, urlsafe_base64_encode
from django.utils.translation import ugettext as _
from django.views.decorators.csrf import csrf_exempt, ensure_csrf_cookie
from django.views.decorators.http import require_GET, require_POST, require_http_methods
from django.views.decorators.http import require_GET, require_http_methods, require_POST
from edx_ace import ace
from edx_ace.recipient import Recipient
from edx_django_utils import monitoring as monitoring_utils
@@ -41,14 +42,13 @@ from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from pytz import UTC
from six import text_type
from xmodule.modulestore.django import modulestore
import track.views
from course_modes.models import CourseMode
from edx_ace import ace
from edx_ace.recipient import Recipient
from edxmako.shortcuts import render_to_response, render_to_string, marketing_link
from entitlements.models import CourseEntitlement
import track.views
from bulk_email.models import Optout
from course_modes.models import CourseMode
from courseware.courses import get_courses, sort_by_announcement, sort_by_start_date
from edxmako.shortcuts import marketing_link, render_to_response, render_to_string
from entitlements.models import CourseEntitlement
from openedx.core.djangoapps.ace_common.template_context import get_base_template_context
from openedx.core.djangoapps.catalog.utils import get_programs_with_type
from openedx.core.djangoapps.embargo import api as embargo_api
@@ -60,18 +60,13 @@ from openedx.core.djangoapps.theming import helpers as theming_helpers
from openedx.core.djangoapps.theming.helpers import get_current_site
from openedx.core.djangoapps.user_api.accounts.utils import is_secondary_email_feature_enabled
from openedx.core.djangoapps.user_api.config.waffle import PREVENT_AUTH_USER_WRITES, SYSTEM_MAINTENANCE_MSG, waffle
from openedx.core.djangoapps.user_api.errors import UserNotFound, UserAPIInternalError
from openedx.core.djangoapps.user_api.errors import UserAPIInternalError, UserNotFound
from openedx.core.djangoapps.user_api.models import UserRetirementRequest
from openedx.core.djangoapps.user_api.preferences import api as preferences_api
from openedx.core.djangolib.markup import HTML, Text
from openedx.features.journals.api import get_journals_context
from student.forms import AccountCreationForm, PasswordResetFormNoActive, get_registration_extension_form
from student.helpers import (
DISABLE_UNENROLL_CERT_STATES,
cert_info,
generate_activation_email_context,
)
from student.helpers import DISABLE_UNENROLL_CERT_STATES, cert_info, generate_activation_email_context
from student.message_types import EmailChange, EmailChangeConfirmation, PasswordReset, RecoveryEmailCreate
from student.models import (
AccountRecovery,
@@ -85,7 +80,7 @@ from student.models import (
UserSignupSource,
UserStanding,
create_comments_service_user,
email_exists_or_retired,
email_exists_or_retired
)
from student.signals import REFUND_ORDER
from student.tasks import send_activation_email
@@ -94,6 +89,7 @@ from util.bad_request_rate_limiter import BadRequestRateLimiter
from util.db import outer_atomic
from util.json_request import JsonResponse
from util.password_policy_validators import normalize_password, validate_password
from xmodule.modulestore.django import modulestore
log = logging.getLogger("edx.student")
@@ -389,7 +385,7 @@ def change_enrollment(request, check_access=True):
return HttpResponse(redirect_url)
if CourseEntitlement.check_for_existing_entitlement_and_enroll(user=user, course_run_key=course_id):
return HttpResponse(reverse('courseware', args=[unicode(course_id)]))
return HttpResponse(reverse('courseware', args=[six.text_type(course_id)]))
# Check that auto enrollment is allowed for this course
# (= the course is NOT behind a paywall)