Commit bebdc069 by bmedx

LMS urls cleanup for Django 1.11

- Remove usage of django.urls.patterns
- Change urls tuples to lists
- Make all string view names callables
- This is the third urls update for LMS
parent 0255592c
""" Grades API URLs. """
"""
Grades API URLs.
"""
from django.conf import settings
from django.conf.urls import patterns, url
from django.conf.urls import url
from lms.djangoapps.grades.api import views
urlpatterns = patterns(
'',
urlpatterns = [
url(
r'^v0/course_grade/{course_id}/users/$'.format(
course_id=settings.COURSE_ID_PATTERN,
......@@ -18,4 +20,4 @@ urlpatterns = patterns(
),
views.CourseGradingPolicy.as_view(), name='course_grading_policy'
),
)
]
......@@ -3,15 +3,15 @@ LTI Provider API endpoint urls.
"""
from django.conf import settings
from django.conf.urls import patterns, url
from django.conf.urls import url
urlpatterns = patterns(
'',
from lti_provider import views
urlpatterns = [
url(
r'^courses/{course_id}/{usage_id}$'.format(
course_id=settings.COURSE_ID_PATTERN,
usage_id=settings.USAGE_ID_PATTERN
),
'lti_provider.views.lti_launch', name="lti_provider_launch"),
)
views.lti_launch, name="lti_provider_launch"),
]
"""
URLs for course_info API
"""
from django.conf import settings
from django.conf.urls import patterns, url
from django.conf.urls import url
from .views import CourseHandoutsList, CourseUpdatesList
urlpatterns = patterns(
'mobile_api.course_info.views',
urlpatterns = [
url(
r'^{}/handouts$'.format(settings.COURSE_ID_PATTERN),
CourseHandoutsList.as_view(),
......@@ -18,4 +18,4 @@ urlpatterns = patterns(
CourseUpdatesList.as_view(),
name='course-updates-list'
),
)
]
"""
URLs for mobile API
"""
from django.conf.urls import include, patterns, url
from django.conf.urls import include, url
from .users.views import my_user_info
urlpatterns = patterns(
'',
urlpatterns = [
url(r'^users/', include('mobile_api.users.urls')),
url(r'^my_user_info', my_user_info),
url(r'^video_outlines/', include('mobile_api.video_outlines.urls')),
url(r'^course_info/', include('mobile_api.course_info.urls')),
)
]
"""
URLs for user API
"""
from django.conf import settings
from django.conf.urls import patterns, url
from django.conf.urls import url
from .views import UserCourseEnrollmentsList, UserCourseStatus, UserDetail
urlpatterns = patterns(
'mobile_api.users.views',
urlpatterns = [
url('^' + settings.USERNAME_PATTERN + '$', UserDetail.as_view(), name='user-detail'),
url(
'^' + settings.USERNAME_PATTERN + '/course_enrollments/$',
......@@ -17,4 +17,4 @@ urlpatterns = patterns(
url('^{}/course_status_info/{}'.format(settings.USERNAME_PATTERN, settings.COURSE_ID_PATTERN),
UserCourseStatus.as_view(),
name='user-course-status')
)
]
"""
URLs for video outline API
"""
from django.conf import settings
from django.conf.urls import patterns, url
from django.conf.urls import url
from .views import VideoSummaryList, VideoTranscripts
urlpatterns = patterns(
'mobile_api.video_outlines.views',
urlpatterns = [
url(
r'^courses/{}$'.format(settings.COURSE_ID_PATTERN),
VideoSummaryList.as_view(),
......@@ -18,4 +18,4 @@ urlpatterns = patterns(
VideoTranscripts.as_view(),
name='video-transcripts-detail'
),
)
]
from django.conf.urls import patterns, url
"""
URL definitions for the notes app
"""
from django.conf.urls import url
from notes.api import api_request
id_regex = r"(?P<note_id>[0-9A-Fa-f]+)"
urlpatterns = patterns('notes.api',
url(r'^api$', 'api_request', {'resource': 'root'}, name='notes_api_root'),
url(r'^api/annotations$', 'api_request', {'resource': 'notes'}, name='notes_api_notes'),
url(r'^api/annotations/' + id_regex + r'$', 'api_request', {'resource': 'note'}, name='notes_api_note'),
url(r'^api/search', 'api_request', {'resource': 'search'}, name='notes_api_search')
)
urlpatterns = [
url(r'^api$', api_request, {'resource': 'root'}, name='notes_api_root'),
url(r'^api/annotations$', api_request, {'resource': 'notes'}, name='notes_api_notes'),
url(r'^api/annotations/' + id_regex + r'$', api_request, {'resource': 'note'}, name='notes_api_note'),
url(r'^api/search', api_request, {'resource': 'search'}, name='notes_api_search')
]
from django.conf.urls import include, patterns, url
"""
URLs for the notifier api app
"""
from django.conf.urls import include, url
from rest_framework import routers
from notifier_api.views import NotifierUsersViewSet
notifier_api_router = routers.DefaultRouter()
notifier_api_router.register(r'users', NotifierUsersViewSet, base_name="notifier_users")
urlpatterns = patterns(
'',
urlpatterns = [
url(r'^v1/', include(notifier_api_router.urls)),
)
]
......@@ -3,6 +3,8 @@ URLs for the rss_proxy djangoapp.
"""
from django.conf.urls import url
from rss_proxy.views import proxy
urlpatterns = [
url(r"^$", "rss_proxy.views.proxy", name="proxy"),
url(r'^$', proxy, name='proxy'),
]
......@@ -1383,7 +1383,7 @@ class ShoppingCartViewsTests(SharedModuleStoreTestCase, XssTestMixin):
self._assert_404(reverse('shoppingcart.views.use_code', args=[]), use_post=True)
self._assert_404(reverse('shoppingcart.views.update_user_cart', args=[]))
self._assert_404(reverse('shoppingcart.views.reset_code_redemption', args=[]), use_post=True)
self._assert_404(reverse('shoppingcart.views.billing_details', args=[]))
self._assert_404(reverse('billing_details', args=[]))
def test_upgrade_postpay_callback_emits_ga_event(self):
# Enroll as honor in the course with the current user.
......@@ -1693,7 +1693,7 @@ class ShoppingcartViewsClosedEnrollment(ModuleStoreTestCase):
self.testing_course.enrollment_end = self.nextday
self.testing_course = self.update_course(self.testing_course, self.user.id)
resp = self.client.post(reverse('shoppingcart.views.billing_details'))
resp = self.client.post(reverse('billing_details'))
self.assertEqual(resp.status_code, 200)
self.assertTrue(json.loads(resp.content)['is_course_enrollment_closed'])
......
"""
Defines the shoppingcart URLs
"""
from django.conf import settings
from django.conf.urls import patterns, url
from django.conf.urls import url
from shoppingcart import views
urlpatterns = [
# Both the ~accept and ~reject callback pages are handled here
url(r'^postpay_callback/$', views.postpay_callback, name='shoppingcart.views.postpay_callback'),
urlpatterns = patterns(
'shoppingcart.views',
url(r'^receipt/(?P<ordernum>[0-9]*)/$', views.show_receipt, name='shoppingcart.views.show_receipt'),
url(r'^donation/$', views.donate, name='donation'),
url(r'^csv_report/$', views.csv_report, name='payment_csv_report'),
url(r'^postpay_callback/$', 'postpay_callback'), # Both the ~accept and ~reject callback pages are handled here
url(r'^receipt/(?P<ordernum>[0-9]*)/$', 'show_receipt'),
url(r'^donation/$', 'donate', name='donation'),
url(r'^csv_report/$', 'csv_report', name='payment_csv_report'),
# These following URLs are only valid if the ENABLE_SHOPPING_CART feature flag is set
url(r'^$', 'show_cart'),
url(r'^clear/$', 'clear_cart'),
url(r'^remove_item/$', 'remove_item'),
url(r'^add/course/{}/$'.format(settings.COURSE_ID_PATTERN), 'add_course_to_cart', name='add_course_to_cart'),
url(r'^register/redeem/(?P<registration_code>[0-9A-Za-z]+)/$', 'register_code_redemption', name='register_code_redemption'),
url(r'^use_code/$', 'use_code'),
url(r'^update_user_cart/$', 'update_user_cart'),
url(r'^reset_code_redemption/$', 'reset_code_redemption'),
url(r'^billing_details/$', 'billing_details', name='billing_details'),
url(r'^verify_cart/$', 'verify_cart'),
)
url(r'^$', views.show_cart, name='shoppingcart.views.show_cart'),
url(r'^clear/$', views.clear_cart, name='shoppingcart.views.clear_cart'),
url(r'^remove_item/$', views.remove_item, name='shoppingcart.views.remove_item'),
url(r'^add/course/{}/$'.format(settings.COURSE_ID_PATTERN), views.add_course_to_cart, name='add_course_to_cart'),
url(r'^register/redeem/(?P<registration_code>[0-9A-Za-z]+)/$',
views.register_code_redemption, name='register_code_redemption'),
url(r'^use_code/$', views.use_code, name='shoppingcart.views.use_code'),
url(r'^update_user_cart/$', views.update_user_cart, name='shoppingcart.views.update_user_cart'),
url(r'^reset_code_redemption/$', views.reset_code_redemption, name='shoppingcart.views.reset_code_redemption'),
url(r'^billing_details/$', views.billing_details, name='billing_details'),
url(r'^verify_cart/$', views.verify_cart, name='shoppingcart.views.verify_cart'),
]
if settings.FEATURES.get('ENABLE_PAYMENT_FAKE'):
from shoppingcart.tests.payment_fake import PaymentFakeView
urlpatterns += patterns(
'shoppingcart.tests.payment_fake',
url(r'^payment_fake', PaymentFakeView.as_view()),
)
urlpatterns += [
url(r'^payment_fake', PaymentFakeView.as_view(), name='shoppingcart.views.payment_fake'),
]
......@@ -3,34 +3,31 @@ URLs for static_template_view app
"""
from django.conf import settings
from django.conf.urls import patterns, url
from django.conf.urls import url
urlpatterns = (
'static_template_view.views',
# TODO: Is this used anymore? What is STATIC_GRAB?
url(r'^t/(?P<template>[^/]*)$', 'index'),
from static_template_view import views
urlpatterns = [
# Semi-static views (these need to be rendered and have the login bar, but don't change)
url(r'^404$', 'render', {'template': '404.html'}, name="404"),
url(r'^404$', views.render, {'template': '404.html'}, name="404"),
# display error page templates, for testing purposes
url(r'^404$', 'render_404'), # Can this be deleted? Test test_404_microsites fails with this.
url(r'^500$', 'render_500'),
url(r'^blog$', 'render', {'template': 'blog.html'}, name="blog"),
url(r'^contact$', 'render', {'template': 'contact.html'}, name="contact"),
url(r'^donate$', 'render', {'template': 'donate.html'}, name="donate"),
url(r'^faq$', 'render', {'template': 'faq.html'}, name="faq"),
url(r'^help$', 'render', {'template': 'help.html'}, name="help_edx"),
url(r'^jobs$', 'render', {'template': 'jobs.html'}, name="jobs"),
url(r'^news$', 'render', {'template': 'news.html'}, name="news"),
url(r'^press$', 'render', {'template': 'press.html'}, name="press"),
url(r'^media-kit$', 'render', {'template': 'media-kit.html'}, name="media-kit"),
url(r'^copyright$', 'render', {'template': 'copyright.html'}, name="copyright"),
url(r'^404$', views.render_404), # Can this be deleted? Test test_404_microsites fails with this.
url(r'^500$', views.render_500),
url(r'^blog$', views.render, {'template': 'blog.html'}, name="blog"),
url(r'^contact$', views.render, {'template': 'contact.html'}, name="contact"),
url(r'^donate$', views.render, {'template': 'donate.html'}, name="donate"),
url(r'^faq$', views.render, {'template': 'faq.html'}, name="faq"),
url(r'^help$', views.render, {'template': 'help.html'}, name="help_edx"),
url(r'^jobs$', views.render, {'template': 'jobs.html'}, name="jobs"),
url(r'^news$', views.render, {'template': 'news.html'}, name="news"),
url(r'^press$', views.render, {'template': 'press.html'}, name="press"),
url(r'^media-kit$', views.render, {'template': 'media-kit.html'}, name="media-kit"),
url(r'^copyright$', views.render, {'template': 'copyright.html'}, name="copyright"),
# Press releases
url(r'^press/([_a-zA-Z0-9-]+)$', 'render_press_release', name='press_release'),
)
url(r'^press/([_a-zA-Z0-9-]+)$', views.render_press_release, name='press_release'),
]
# Only enable URLs for those marketing links actually enabled in the
# settings. Disable URLs by marking them as None.
......@@ -52,6 +49,4 @@ for key, value in settings.MKTG_URL_LINK_MAP.items():
# Make the assumption that the URL we want is the lowercased
# version of the map key
urlpatterns += (url(r'^%s$' % key.lower(), 'render', {'template': template}, name=value),)
urlpatterns = patterns(*urlpatterns)
urlpatterns.append(url(r'^%s$' % key.lower(), views.render, {'template': template}, name=value))
from django.conf import settings
from django.conf.urls import patterns, url
from django.conf.urls import url
urlpatterns = []
from student_account import views
if settings.FEATURES.get('ENABLE_COMBINED_LOGIN_REGISTRATION'):
urlpatterns += patterns(
'student_account.views',
url(r'^password$', 'password_change_request_handler', name='password_change_request'),
)
urlpatterns = [
url(r'^finish_auth$', views.finish_auth, name='finish_auth'),
url(r'^settings$', views.account_settings, name='account_settings'),
]
urlpatterns += patterns(
'student_account.views',
url(r'^finish_auth$', 'finish_auth', name='finish_auth'),
url(r'^settings$', 'account_settings', name='account_settings'),
)
if settings.FEATURES.get('ENABLE_COMBINED_LOGIN_REGISTRATION'):
urlpatterns += [
url(r'^password$', views.password_change_request_handler, name='password_change_request'),
]
"""
URLs for the student support app.
"""
from django.conf.urls import patterns, url
from django.conf.urls import url
from support import views
from lms.djangoapps.support.views.contact_us import ContactUsView
urlpatterns = patterns(
'',
urlpatterns = [
url(r'^$', views.index, name="index"),
url(r'^certificates/?$', views.CertificatesSupportView.as_view(), name="certificates"),
url(r'^refund/?$', views.RefundSupportView.as_view(), name="refund"),
......@@ -19,4 +18,4 @@ urlpatterns = patterns(
views.EnrollmentSupportListView.as_view(),
name="enrollment_list"
),
)
]
......@@ -2,11 +2,11 @@
URL mappings for the Survey feature
"""
from django.conf.urls import patterns, url
from django.conf.urls import url
urlpatterns = patterns(
'survey.views',
from survey import views
url(r'^(?P<survey_name>[0-9A-Za-z]+)/$', 'view_survey', name='view_survey'),
url(r'^(?P<survey_name>[0-9A-Za-z]+)/answers/$', 'submit_answers', name='submit_answers'),
)
urlpatterns = [
url(r'^(?P<survey_name>[0-9A-Za-z]+)/$', views.view_survey, name='view_survey'),
url(r'^(?P<survey_name>[0-9A-Za-z]+)/answers/$', views.submit_answers, name='submit_answers'),
]
"""Defines the URL routes for the Team API."""
"""
Defines the URL routes for the Team API.
"""
from django.conf import settings
from django.conf.urls import patterns, url
from django.conf.urls import url
from .views import (
MembershipDetailView,
......@@ -15,8 +17,7 @@ from .views import (
TEAM_ID_PATTERN = r'(?P<team_id>[a-z\d_-]+)'
TOPIC_ID_PATTERN = r'(?P<topic_id>[A-Za-z\d_.-]+)'
urlpatterns = patterns(
'',
urlpatterns = [
url(
r'^v0/teams/$',
TeamsListView.as_view(),
......@@ -55,4 +56,4 @@ urlpatterns = patterns(
MembershipDetailView.as_view(),
name="team_membership_detail"
)
)
]
"""Defines the URL routes for this app."""
"""
Defines the URL routes for this app.
"""
from django.conf.urls import patterns, url
from django.conf.urls import url
from django.contrib.auth.decorators import login_required
from .views import TeamsDashboardView
urlpatterns = patterns(
'teams.views',
urlpatterns = [
url(r"^/$", login_required(TeamsDashboardView.as_view()), name="teams_dashboard")
)
]
""" URL definitions for the verify_student app. """
"""
URL definitions for the verify_student app.
"""
from django.conf import settings
from django.conf.urls import patterns, url
from django.conf.urls import url
from lms.djangoapps.verify_student import views
urlpatterns = patterns(
'',
urlpatterns = [
# The user is starting the verification / payment process,
# most likely after enrolling in a course and selecting
# a "verified" track.
......@@ -104,12 +104,11 @@ urlpatterns = patterns(
views.ReverifyView.as_view(),
name="verify_student_reverify"
),
)
]
# Fake response page for incourse reverification ( software secure )
if settings.FEATURES.get('ENABLE_SOFTWARE_SECURE_FAKE'):
from lms.djangoapps.verify_student.tests.fake_software_secure import SoftwareSecureFakeView
urlpatterns += patterns(
'verify_student.tests.fake_software_secure',
urlpatterns += [
url(r'^software-secure-fake-response', SoftwareSecureFakeView.as_view()),
)
]
......@@ -297,7 +297,7 @@ from openedx.core.lib.courses import course_image_url
return false;
}
event.preventDefault();
location.href = "${reverse('shoppingcart.views.billing_details')}";
location.href = "${reverse('billing_details')}";
});
......
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