Commit ffc2a0eb by bmedx

common urls cleanup for Django 1.11

- Remove usage of django.urls.patterns
- Change urls tuples to lists
- Make all string view names callables
parent 0255592c
......@@ -5,6 +5,8 @@ development mode; otherwise, it is ignored.
"""
from django.conf.urls import url
urlpatterns = (
url(r'^dev_mode$', 'contentstore.views.dev.dev_mode', name='dev_mode'),
)
from contentstore.views.dev import dev_mode
urlpatterns = [
url(r'^dev_mode$', dev_mode, name='dev_mode'),
]
from django.conf import settings
from django.conf.urls import patterns, url
from django.conf.urls import url
from course_modes import views
urlpatterns = patterns(
'',
# pylint seems to dislike as_view() calls because it's a `classonlymethod` instead of `classmethod`, so we disable the warning
urlpatterns = [
url(r'^choose/{}/$'.format(settings.COURSE_ID_PATTERN), views.ChooseModeView.as_view(), name='course_modes_choose'),
)
]
# Enable verified mode creation
if settings.FEATURES.get('MODE_CREATION_FOR_TESTING'):
urlpatterns += (
url(r'^create_mode/{}/$'.format(settings.COURSE_ID_PATTERN), 'course_modes.views.create_mode', name='create_mode'),
urlpatterns.append(
url(r'^create_mode/{}/$'.format(settings.COURSE_ID_PATTERN),
views.create_mode,
name='create_mode'),
)
......@@ -3,28 +3,18 @@ URLs for the Enrollment API
"""
from django.conf import settings
from django.conf.urls import patterns, url
from django.conf.urls import url
from .views import EnrollmentCourseDetailView, EnrollmentListView, EnrollmentView
urlpatterns = patterns(
'enrollment.views',
url(
r'^enrollment/{username},{course_key}$'.format(
username=settings.USERNAME_PATTERN, course_key=settings.COURSE_ID_PATTERN
),
EnrollmentView.as_view(),
name='courseenrollment'
),
url(
r'^enrollment/{course_key}$'.format(course_key=settings.COURSE_ID_PATTERN),
EnrollmentView.as_view(),
name='courseenrollment'
),
urlpatterns = [
url(r'^enrollment/{username},{course_key}$'.format(
username=settings.USERNAME_PATTERN,
course_key=settings.COURSE_ID_PATTERN),
EnrollmentView.as_view(), name='courseenrollment'),
url(r'^enrollment/{course_key}$'.format(course_key=settings.COURSE_ID_PATTERN),
EnrollmentView.as_view(), name='courseenrollment'),
url(r'^enrollment$', EnrollmentListView.as_view(), name='courseenrollments'),
url(
r'^course/{course_key}$'.format(course_key=settings.COURSE_ID_PATTERN),
EnrollmentCourseDetailView.as_view(),
name='courseenrollmentdetails'
),
)
url(r'^course/{course_key}$'.format(course_key=settings.COURSE_ID_PATTERN),
EnrollmentCourseDetailView.as_view(), name='courseenrollmentdetails'),
]
......@@ -3,65 +3,58 @@ URLs for student app
"""
from django.conf import settings
from django.conf.urls import patterns, url
from django.conf.urls import url
from django.contrib.auth.views import password_reset_complete
from student.views import LogoutView
import student.views
urlpatterns = (
'student.views',
url(r'^logout$', LogoutView.as_view(), name='logout'),
urlpatterns = [
url(r'^logout$', student.views.LogoutView.as_view(), name='logout'),
# TODO: standardize login
# login endpoint used by cms.
url(r'^login_post$', 'login_user', name='login_post'),
url(r'^login_post$', student.views.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'^login_ajax$', student.views.login_user, name="login"),
url(r'^login_ajax/(?P<error>[^/]*)$', student.views.login_user),
url(r'^email_confirm/(?P<key>[^/]*)$', 'confirm_email_change'),
url(r'^email_confirm/(?P<key>[^/]*)$', student.views.confirm_email_change),
url(r'^create_account$', 'create_account', name='create_account'),
url(r'^activate/(?P<key>[^/]*)$', 'activate_account', name="activate"),
url(r'^create_account$', student.views.create_account, name='create_account'),
url(r'^activate/(?P<key>[^/]*)$', student.views.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'^accounts/disable_account_ajax$', student.views.disable_account_ajax, name="disable_account_ajax"),
url(r'^accounts/manage_user_standing', student.views.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'),
url(r'^change_setting$', student.views.change_setting, name='change_setting'),
url(r'^change_email_settings$', student.views.change_email_settings, name='change_email_settings'),
# password reset in student.views (see below for password reset django views)
url(r'^password_reset/$', 'password_reset', name='password_reset'),
url(r'^password_reset/$', student.views.password_reset, name='password_reset'),
url(
r'^password_reset_confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
'password_reset_confirm_wrapper',
student.views.password_reset_confirm_wrapper,
name='password_reset_confirm',
),
url(r'^course_run/{}/refund_status$'.format(settings.COURSE_ID_PATTERN),
'course_run_refund_status',
student.views.course_run_refund_status,
name="course_run_refund_status"),
)
]
# enable automatic login
if settings.FEATURES.get('AUTOMATIC_AUTH_FOR_TESTING'):
urlpatterns += (
url(r'^auto_auth$', 'auto_auth'),
)
# add all student.views url patterns
urlpatterns = patterns(*urlpatterns)
urlpatterns += [
url(r'^auto_auth$', student.views.auto_auth),
]
# password reset django views (see above for password reset student.views)
urlpatterns += patterns(
'django.contrib.auth.views',
urlpatterns += [
# TODO: Replace with Mako-ized views
url(
r'^password_reset_complete/$',
'password_reset_complete',
password_reset_complete,
name='password_reset_complete',
),
)
]
""" URL configuration for the third party auth API """
from django.conf import settings
from django.conf.urls import patterns, url
from django.conf.urls import url
from .views import UserMappingView, UserView
PROVIDER_PATTERN = r'(?P<provider_id>[\w.+-]+)(?:\:(?P<idp_slug>[\w.+-]+))?'
urlpatterns = patterns(
'',
urlpatterns = [
url(
r'^v0/users/{username_pattern}$'.format(username_pattern=settings.USERNAME_PATTERN),
UserView.as_view(),
......@@ -20,4 +19,4 @@ urlpatterns = patterns(
UserMappingView.as_view(),
name='third_party_auth_user_mapping_api',
),
)
]
"""Url configuration for the auth module."""
from django.conf.urls import include, patterns, url
from django.conf.urls import include, url
from .views import inactive_user_view, lti_login_and_complete_view, post_to_custom_auth_form, saml_metadata_view
urlpatterns = patterns(
'',
urlpatterns = [
url(r'^auth/inactive', inactive_user_view, name="third_party_inactive_redirect"),
url(r'^auth/custom_auth_entry', post_to_custom_auth_form, name='tpa_post_to_custom_auth_form'),
url(r'^auth/saml/metadata.xml', saml_metadata_view),
url(r'^auth/login/(?P<backend>lti)/$', lti_login_and_complete_view),
url(r'^auth/', include('social_django.urls', namespace='social')),
)
]
......@@ -3,19 +3,18 @@ URLs for track app
"""
from django.conf import settings
from django.conf.urls import patterns, url
from django.conf.urls import url
urlpatterns = (
'track.views',
import track.views
import track.views.segmentio
url(r'^event$', 'user_track'),
url(r'^segmentio/event$', 'segmentio.segmentio_event'),
)
urlpatterns = [
url(r'^event$', track.views.user_track),
url(r'^segmentio/event$', track.views.segmentio.segmentio_event),
]
if settings.FEATURES.get('ENABLE_SQL_TRACKING_LOGS'):
urlpatterns += (
url(r'^event_logs$', 'view_tracking_log'),
url(r'^event_logs/(?P<args>.+)$', 'view_tracking_log'),
)
urlpatterns = patterns(*urlpatterns)
urlpatterns += [
url(r'^event_logs$', track.views.view_tracking_log),
url(r'^event_logs/(?P<args>.+)$', track.views.view_tracking_log),
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment