Move student.views to student/urls.py

This commit is contained in:
Robert Raposa
2016-10-06 12:00:22 -04:00
parent 51167aedef
commit fea03e466c
5 changed files with 96 additions and 71 deletions

View File

@@ -5,7 +5,6 @@ from ratelimitbackend import admin
from cms.djangoapps.contentstore.views.program import ProgramAuthoringView, ProgramsIdTokenView
from cms.djangoapps.contentstore.views.organization import OrganizationListView
from student.views import LogoutView
admin.autodiscover()
@@ -19,6 +18,8 @@ LIBRARY_KEY_PATTERN = r'(?P<library_key_string>library-v1:[^/+]+\+[^/+]+)'
urlpatterns = patterns(
'',
url(r'', include('student.urls')),
url(r'^transcripts/upload$', 'contentstore.views.upload_transcripts', name='upload_transcripts'),
url(r'^transcripts/download$', 'contentstore.views.download_transcripts', name='download_transcripts'),
url(r'^transcripts/check$', 'contentstore.views.check_transcripts', name='check_transcripts'),
@@ -60,18 +61,6 @@ urlpatterns = patterns(
url(r'^update_lang/', include('dark_lang.urls', namespace='darklang')),
)
# User creation and updating views
urlpatterns += patterns(
'',
url(r'^create_account$', 'student.views.create_account', name='create_account'),
url(r'^activate/(?P<key>[^/]*)$', 'student.views.activate_account', name='activate'),
# ajax view that actually does the work
url(r'^login_post$', 'student.views.login_user', name='login_post'),
url(r'^logout$', LogoutView.as_view(), name='logout'),
)
# restful api
urlpatterns += patterns(
'contentstore.views',
@@ -159,12 +148,6 @@ if settings.FEATURES.get('AUTH_USE_CAS'):
urlpatterns += patterns('', url(r'^admin/', include(admin.site.urls)),)
# enable automatic login
if settings.FEATURES.get('AUTOMATIC_AUTH_FOR_TESTING'):
urlpatterns += (
url(r'^auto_auth$', 'student.views.auto_auth'),
)
# enable entrance exams
if settings.FEATURES.get('ENTRANCE_EXAMS'):
urlpatterns += (

View File

@@ -14,12 +14,18 @@ import ddt
import json
class AutoAuthTestCase(UrlResetMixin, TestCase):
"""
Base class for AutoAuth Tests that properly resets the urls.py
"""
URLCONF_MODULES = ['student.urls']
@ddt.ddt
class AutoAuthEnabledTestCase(UrlResetMixin, TestCase):
class AutoAuthEnabledTestCase(AutoAuthTestCase):
"""
Tests for the Auto auth view that we have for load testing.
"""
COURSE_ID_MONGO = 'edX/Test101/2014_Spring'
COURSE_ID_SPLIT = 'course-v1:edX+Test101+2014_Spring'
COURSE_IDS_DDT = (
@@ -256,7 +262,7 @@ class AutoAuthEnabledTestCase(UrlResetMixin, TestCase):
return response
class AutoAuthDisabledTestCase(UrlResetMixin, TestCase):
class AutoAuthDisabledTestCase(AutoAuthTestCase):
"""
Test that the page is inaccessible with default settings
"""

View File

@@ -0,0 +1,64 @@
"""
URLs for student app
"""
from django.conf import settings
from django.conf.urls import patterns, url
from student.views import LogoutView
urlpatterns = (
'student.views',
url(r'^logout$', LogoutView.as_view(), name='logout'),
# TODO: standardize login
# login endpoint used by cms.
url(r'^login_post$', 'login_user', name='login_post'),
# login endpoints used by lms.
url(r'^login_ajax$', 'login_user', name="login"),
url(r'^login_ajax/(?P<error>[^/]*)$', 'login_user'),
url(r'^email_confirm/(?P<key>[^/]*)$', 'confirm_email_change'),
url(r'^create_account$', 'create_account', name='create_account'),
url(r'^activate/(?P<key>[^/]*)$', 'activate_account', name="activate"),
url(r'^accounts/disable_account_ajax$', 'disable_account_ajax', name="disable_account_ajax"),
url(r'^accounts/manage_user_standing', 'manage_user_standing', name='manage_user_standing'),
url(r'^change_setting$', 'change_setting', name='change_setting'),
url(r'^change_email_settings$', 'change_email_settings', name='change_email_settings'),
)
# enable automatic login
if settings.FEATURES.get('AUTOMATIC_AUTH_FOR_TESTING'):
urlpatterns += (
url(r'^auto_auth$', 'auto_auth'),
)
urlpatterns = patterns(*urlpatterns)
# password reset mixes student.views with django views
urlpatterns += (
url(r'^password_reset/$', 'student.views.password_reset', name='password_reset'),
# Obsolete Django views for password resets
# TODO: Replace with Mako-ized views
url(r'^password_change/$', 'django.contrib.auth.views.password_change', name='password_change'),
url(r'^password_change_done/$', 'django.contrib.auth.views.password_change_done', name='password_change_done'),
url(
r'^password_reset_complete/$',
'django.contrib.auth.views.password_reset_complete',
name='password_reset_complete',
),
url(
r'^password_reset_confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
'student.views.password_reset_confirm_wrapper',
name='password_reset_confirm',
),
url(r'^password_reset_done/$', 'django.contrib.auth.views.password_reset_done', name='password_reset_done'),
)

View File

@@ -556,6 +556,18 @@ def is_course_blocked(request, redeemed_registration_codes, course_key):
@login_required
@ensure_csrf_cookie
def dashboard(request):
"""
Provides the LMS dashboard view
TODO: This is lms specific and does not belong in common code.
Arguments:
request: The request object.
Returns:
The dashboard response.
"""
user = request.user
platform_name = configuration_helpers.get_value("platform_name", settings.PLATFORM_NAME)
@@ -998,6 +1010,8 @@ def change_enrollment(request, check_access=True):
"""
Modify the enrollment status for the logged-in user.
TODO: This is lms specific and does not belong in common code.
The request parameter must be a POST request (other methods return 405)
that specifies course_id and enrollment_action parameters. If course_id or
enrollment_action is not specified, if course_id is not valid, if

View File

@@ -16,7 +16,6 @@ from openedx.core.djangoapps.catalog.models import CatalogIntegration
from openedx.core.djangoapps.programs.models import ProgramsApiConfig
from openedx.core.djangoapps.self_paced.models import SelfPacedConfiguration
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from student.views import LogoutView
# Uncomment the next two lines to enable the admin:
if settings.DEBUG or settings.FEATURES.get('ENABLE_DJANGO_ADMIN_SITE'):
@@ -27,11 +26,12 @@ urlpatterns = (
'',
url(r'^$', 'branding.views.index', name="root"), # Main marketing page, or redirect to courseware
url(r'^dashboard$', 'student.views.dashboard', name="dashboard"),
url(r'^login_ajax$', 'student.views.login_user', name="login"),
url(r'^login_ajax/(?P<error>[^/]*)$', 'student.views.login_user'),
url(r'^email_confirm/(?P<key>[^/]*)$', 'student.views.confirm_email_change'),
url(r'', include('student.urls')),
# TODO: Move lms specific student views out of common code
url(r'^dashboard$', 'student.views.dashboard', name="dashboard"),
url(r'^change_enrollment$', 'student.views.change_enrollment', name='change_enrollment'),
url(r'^event$', 'track.views.user_track'),
url(r'^performance$', 'openedx.core.djangoapps.performance.views.performance_log'),
url(r'^segmentio/event$', 'track.views.segmentio.segmentio_event'),
@@ -39,30 +39,6 @@ urlpatterns = (
# TODO: Is this used anymore? What is STATIC_GRAB?
url(r'^t/(?P<template>[^/]*)$', 'static_template_view.views.index'),
url(r'^accounts/manage_user_standing', 'student.views.manage_user_standing',
name='manage_user_standing'),
url(r'^accounts/disable_account_ajax$', 'student.views.disable_account_ajax',
name="disable_account_ajax"),
url(r'^logout$', LogoutView.as_view(), name='logout'),
url(r'^create_account$', 'student.views.create_account', name='create_account'),
url(r'^activate/(?P<key>[^/]*)$', 'student.views.activate_account', name="activate"),
url(r'^password_reset/$', 'student.views.password_reset', name='password_reset'),
## Obsolete Django views for password resets
## TODO: Replace with Mako-ized views
url(r'^password_change/$', 'django.contrib.auth.views.password_change',
name='password_change'),
url(r'^password_change_done/$', 'django.contrib.auth.views.password_change_done',
name='password_change_done'),
url(r'^password_reset_confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
'student.views.password_reset_confirm_wrapper',
name='password_reset_confirm'),
url(r'^password_reset_complete/$', 'django.contrib.auth.views.password_reset_complete',
name='password_reset_complete'),
url(r'^password_reset_done/$', 'django.contrib.auth.views.password_reset_done',
name='password_reset_done'),
url(r'^heartbeat$', include('openedx.core.djangoapps.heartbeat.urls')),
# Note: these are older versions of the User API that will eventually be
@@ -123,6 +99,8 @@ urlpatterns += (
url(r'^dashboard/', include('learner_dashboard.urls')),
)
# TODO: This needs to move to a separate urls.py once the student_account and
# student views below find a home together
if settings.FEATURES["ENABLE_COMBINED_LOGIN_REGISTRATION"]:
# Backwards compatibility with old URL structure, but serve the new views
urlpatterns += (
@@ -332,26 +310,11 @@ urlpatterns += (
'courseware.module_render.xqueue_callback',
name='xqueue_callback',
),
url(
r'^change_setting$',
'student.views.change_setting',
name='change_setting',
),
# TODO: These views need to be updated before they work
url(r'^calculate$', 'util.views.calculate'),
url(r'^courses/?$', 'branding.views.courses', name="courses"),
url(
r'^change_enrollment$',
'student.views.change_enrollment',
name='change_enrollment',
),
url(
r'^change_email_settings$',
'student.views.change_email_settings',
name='change_email_settings',
),
#About the course
url(
@@ -933,11 +896,6 @@ urlpatterns += (
url(r'^debug/show_parameters$', 'debug.views.show_parameters'),
)
# enable automatic login
if settings.FEATURES.get('AUTOMATIC_AUTH_FOR_TESTING'):
urlpatterns += (
url(r'^auto_auth$', 'student.views.auto_auth'),
)
# Third-party auth.
if settings.FEATURES.get('ENABLE_THIRD_PARTY_AUTH'):