urls.py 32.5 KB
Newer Older
1 2 3 4
"""
URLs for LMS
"""

Piotr Mitros committed
5
from django.conf import settings
6
from django.conf.urls import patterns, include, url
7
from django.views.generic.base import RedirectView
8
from ratelimitbackend import admin
9
from django.conf.urls.static import static
10

11
from microsite_configuration import microsite
12
import auth_exchange.views
13

14
from config_models.views import ConfigurationModelCurrentAPIView
15
from openedx.core.djangoapps.programs.models import ProgramsApiConfig
16 17
from openedx.core.djangoapps.self_paced.models import SelfPacedConfiguration

Piotr Mitros committed
18
# Uncomment the next two lines to enable the admin:
19
if settings.DEBUG or settings.FEATURES.get('ENABLE_DJANGO_ADMIN_SITE'):
20
    admin.autodiscover()
Piotr Mitros committed
21

22
# Use urlpatterns formatted as within the Django docs with first parameter "stuck" to the open parenthesis
stv committed
23 24 25
urlpatterns = (
    '',

Calen Pennington committed
26
    url(r'^$', 'branding.views.index', name="root"),   # Main marketing page, or redirect to courseware
27
    url(r'^dashboard$', 'student.views.dashboard', name="dashboard"),
28 29
    url(r'^login_ajax$', 'student.views.login_user', name="login"),
    url(r'^login_ajax/(?P<error>[^/]*)$', 'student.views.login_user'),
30

31
    url(r'^email_confirm/(?P<key>[^/]*)$', 'student.views.confirm_email_change'),
32
    url(r'^event$', 'track.views.user_track'),
33
    url(r'^performance$', 'performance.views.performance_log'),
34
    url(r'^segmentio/event$', 'track.views.segmentio.segmentio_event'),
35 36 37

    # TODO: Is this used anymore? What is STATIC_GRAB?
    url(r'^t/(?P<template>[^/]*)$', 'static_template_view.views.index'),
38

39 40 41 42
    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"),
43

44
    url(r'^logout$', 'student.views.logout_user', name='logout'),
45
    url(r'^create_account$', 'student.views.create_account', name='create_account'),
46 47
    url(r'^activate/(?P<key>[^/]*)$', 'student.views.activate_account', name="activate"),

48
    url(r'^password_reset/$', 'student.views.password_reset', name='password_reset'),
49 50
    ## Obsolete Django views for password resets
    ## TODO: Replace with Mako-ized views
51 52 53 54
    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'),
55
    url(r'^password_reset_confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
56
        'student.views.password_reset_confirm_wrapper',
57 58 59 60 61
        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'),
62

63
    url(r'^heartbeat$', include('heartbeat.urls')),
64

Andy Armstrong committed
65
    # Note: these are older versions of the User API that will eventually be
66
    # subsumed by api/user listed below.
Andy Armstrong committed
67
    url(r'^user_api/', include('openedx.core.djangoapps.user_api.legacy_urls')),
68

69 70
    url(r'^notifier_api/', include('notifier_api.urls')),

71
    url(r'^i18n/', include('django.conf.urls.i18n')),
72

73 74
    # Feedback Form endpoint
    url(r'^submit_feedback$', 'util.views.submit_feedback'),
75

76
    # Enrollment API RESTful endpoints
77
    url(r'^api/enrollment/v1/', include('enrollment.urls')),
78

79 80 81
    # Courseware search endpoints
    url(r'^search/', include('search.urls')),

82 83
    # Course content API
    url(r'^api/course_structure/', include('course_structure_api.urls', namespace='course_structure_api')),
84

Nimisha Asthagiri committed
85 86 87
    # Course API
    url(r'^api/courses/', include('course_api.urls')),

88 89 90
    # User API endpoints
    url(r'^api/user/', include('openedx.core.djangoapps.user_api.urls')),

muzaffaryousaf committed
91
    # Bookmarks API endpoints
92
    url(r'^api/bookmarks/', include('openedx.core.djangoapps.bookmarks.urls')),
muzaffaryousaf committed
93

94 95
    # Profile Images API endpoints
    url(r'^api/profile_images/', include('openedx.core.djangoapps.profile_images.urls')),
96 97 98 99

    # Video Abstraction Layer used to allow video teams to manage video assets
    # independently of courseware. https://github.com/edx/edx-val
    url(r'^api/val/v0/', include('edxval.urls')),
100 101

    url(r'^api/commerce/', include('commerce.api.urls', namespace='commerce_api')),
Clinton Blackburn committed
102
    url(r'^api/credit/', include('openedx.core.djangoapps.credit.urls', app_name="credit", namespace='credit')),
103
    url(r'^rss_proxy/', include('rss_proxy.urls', namespace='rss_proxy')),
104
    url(r'^api/organizations/', include('organizations.urls', namespace='organizations')),
105

asadiqbal committed
106 107 108
    # Update session view
    url(r'^lang_pref/session_language', 'lang_pref.views.update_session_language', name='session_language'),

109 110 111 112
    # Multiple course modes and identity verification
    # TODO Namespace these!
    url(r'^course_modes/', include('course_modes.urls')),
    url(r'^verify_student/', include('verify_student.urls')),
113
)
114

115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
if settings.FEATURES["ENABLE_COMBINED_LOGIN_REGISTRATION"]:
    # Backwards compatibility with old URL structure, but serve the new views
    urlpatterns += (
        url(r'^login$', 'student_account.views.login_and_registration_form',
            {'initial_mode': 'login'}, name="signin_user"),
        url(r'^register$', 'student_account.views.login_and_registration_form',
            {'initial_mode': 'register'}, name="register_user"),
    )
else:
    # Serve the old views
    urlpatterns += (
        url(r'^login$', 'student.views.signin_user', name="signin_user"),
        url(r'^register$', 'student.views.register_user', name="register_user"),
    )

130 131 132 133 134
if settings.FEATURES["ENABLE_MOBILE_REST_API"]:
    urlpatterns += (
        url(r'^api/mobile/v0.5/', include('mobile_api.urls')),
    )

135 136
js_info_dict = {
    'domain': 'djangojs',
137 138
    # We need to explicitly include external Django apps that are not in LOCALE_PATHS.
    'packages': ('openassessment',),
139 140
}

Carson Gee committed
141 142 143 144 145 146
# sysadmin dashboard, to see what courses are loaded, to delete & load courses
if settings.FEATURES["ENABLE_SYSADMIN_DASHBOARD"]:
    urlpatterns += (
        url(r'^sysadmin/', include('dashboard.sysadmin_urls')),
    )

147
urlpatterns += (
148
    url(r'^support/', include('support.urls', app_name="support", namespace='support')),
149 150
)

151
# Semi-static views (these need to be rendered and have the login bar, but don't change)
152
urlpatterns += (
153
    url(r'^404$', 'static_template_view.views.render',
154
        {'template': '404.html'}, name="404"),
Piotr Mitros committed
155 156
)

157 158
# Favicon
favicon_path = microsite.get_value('favicon_path', settings.FAVICON_PATH)
159
urlpatterns += (url(
160
    r'^favicon\.ico$',
161
    RedirectView.as_view(url=settings.STATIC_URL + favicon_path, permanent=True)
162 163
),)

164
# Semi-static views only used by edX, not by themes
165
if not settings.FEATURES["USE_CUSTOM_THEME"]:
166
    urlpatterns += (
167 168 169 170 171 172 173 174 175 176
        url(r'^blog$', 'static_template_view.views.render',
            {'template': 'blog.html'}, name="blog"),
        url(r'^contact$', 'static_template_view.views.render',
            {'template': 'contact.html'}, name="contact"),
        url(r'^donate$', 'static_template_view.views.render',
            {'template': 'donate.html'}, name="donate"),
        url(r'^faq$', 'static_template_view.views.render',
            {'template': 'faq.html'}, name="faq"),
        url(r'^help$', 'static_template_view.views.render',
            {'template': 'help.html'}, name="help_edx"),
177 178
        url(r'^jobs$', 'static_template_view.views.render',
            {'template': 'jobs.html'}, name="jobs"),
179 180 181 182
        url(r'^news$', 'static_template_view.views.render',
            {'template': 'news.html'}, name="news"),
        url(r'^press$', 'static_template_view.views.render',
            {'template': 'press.html'}, name="press"),
183 184
        url(r'^media-kit$', 'static_template_view.views.render',
            {'template': 'media-kit.html'}, name="media-kit"),
185 186
        url(r'^copyright$', 'static_template_view.views.render',
            {'template': 'copyright.html'}, name="copyright"),
187

188
        # Press releases
189
        url(r'^press/([_a-zA-Z0-9-]+)$', 'static_template_view.views.render_press_release', name='press_release'),
190
    )
191 192 193 194 195 196 197 198 199

# Only enable URLs for those marketing links actually enabled in the
# settings. Disable URLs by marking them as None.
for key, value in settings.MKTG_URL_LINK_MAP.items():
    # Skip disabled URLs
    if value is None:
        continue

    # These urls are enabled separately
200
    if key == "ROOT" or key == "COURSES":
201 202
        continue

203 204 205 206 207 208
    # The MKTG_URL_LINK_MAP key specifies the template filename
    template = key.lower()
    if '.' not in template:
        # Append STATIC_TEMPLATE_VIEW_DEFAULT_FILE_EXTENSION if
        # no file extension was specified in the key
        template = "%s.%s" % (template, settings.STATIC_TEMPLATE_VIEW_DEFAULT_FILE_EXTENSION)
209 210 211

    # To allow theme templates to inherit from default templates,
    # prepend a standard prefix
212
    if settings.FEATURES["USE_CUSTOM_THEME"]:
213 214 215 216
        template = "theme-" + template

    # Make the assumption that the URL we want is the lowercased
    # version of the map key
217
    urlpatterns += (url(r'^%s$' % key.lower(),
218 219 220 221
                        'static_template_view.views.render',
                        {'template': template}, name=value),)


222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
# Multicourse wiki (Note: wiki urls must be above the courseware ones because of
# the custom tab catch-all)
if settings.WIKI_ENABLED:
    from wiki.urls import get_pattern as wiki_pattern
    from django_notify.urls import get_pattern as notify_pattern

    urlpatterns += (
        # First we include views from course_wiki that we use to override the default views.
        # They come first in the urlpatterns so they get resolved first
        url('^wiki/create-root/$', 'course_wiki.views.root_create', name='root_create'),
        url(r'^wiki/', include(wiki_pattern())),
        url(r'^notify/', include(notify_pattern())),

        # These urls are for viewing the wiki in the context of a course. They should
        # never be returned by a reverse() so they come after the other url patterns
237
        url(r'^courses/{}/course_wiki/?$'.format(settings.COURSE_ID_PATTERN),
238
            'course_wiki.views.course_wiki_redirect', name="course_wiki"),
239
        url(r'^courses/{}/wiki/'.format(settings.COURSE_KEY_REGEX), include(wiki_pattern())),
240 241
    )

stv committed
242 243 244 245 246
COURSE_URLS = patterns(
    '',
    url(
        r'^look_up_registration_code$',
        'instructor.views.registration_codes.look_up_registration_code',
stv committed
247
        name='look_up_registration_code',
stv committed
248 249 250 251
    ),
    url(
        r'^registration_code_details$',
        'instructor.views.registration_codes.registration_code_details',
stv committed
252 253
        name='registration_code_details',
    ),
stv committed
254 255 256 257
)
urlpatterns += (
    # jump_to URLs for direct access to a location in the course
    url(
stv committed
258 259 260 261 262
        r'^courses/{}/jump_to/(?P<location>.*)$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'courseware.views.jump_to',
        name='jump_to',
stv committed
263 264
    ),
    url(
stv committed
265 266 267 268 269
        r'^courses/{}/jump_to_id/(?P<module_id>.*)$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'courseware.views.jump_to_id',
        name='jump_to_id',
stv committed
270 271 272 273 274 275 276
    ),

    # xblock Handler APIs
    url(
        r'^courses/{course_key}/xblock/{usage_key}/handler/(?P<handler>[^/]*)(?:/(?P<suffix>.*))?$'.format(
            course_key=settings.COURSE_ID_PATTERN,
            usage_key=settings.USAGE_ID_PATTERN,
277
        ),
stv committed
278 279 280 281 282 283 284
        'courseware.module_render.handle_xblock_callback',
        name='xblock_handler',
    ),
    url(
        r'^courses/{course_key}/xblock/{usage_key}/handler_noauth/(?P<handler>[^/]*)(?:/(?P<suffix>.*))?$'.format(
            course_key=settings.COURSE_ID_PATTERN,
            usage_key=settings.USAGE_ID_PATTERN,
285
        ),
stv committed
286 287 288 289 290 291 292 293 294 295 296
        'courseware.module_render.handle_xblock_callback_noauth',
        name='xblock_handler_noauth',
    ),

    # xblock View API
    # (unpublished) API that returns JSON with the HTML fragment and related resources
    # for the xBlock's requested view.
    url(
        r'^courses/{course_key}/xblock/{usage_key}/view/(?P<view_name>[^/]*)$'.format(
            course_key=settings.COURSE_ID_PATTERN,
            usage_key=settings.USAGE_ID_PATTERN,
297
        ),
stv committed
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
        'courseware.module_render.xblock_view',
        name='xblock_view',
    ),

    # xblock Rendering View URL
    # URL to provide an HTML view of an xBlock. The view type (e.g., student_view) is
    # passed as a "view" parameter to the URL.
    # Note: This is not an API. Compare this with the xblock_view API above.
    url(
        r'^xblock/{usage_key_string}$'.format(usage_key_string=settings.USAGE_KEY_PATTERN),
        'courseware.views.render_xblock',
        name='render_xblock',
    ),

    # xblock Resource URL
    url(
        r'xblock/resource/(?P<block_type>[^/]+)/(?P<uri>.*)$',
        'openedx.core.djangoapps.common_views.xblock.xblock_resource',
        name='xblock_resource_url',
    ),

    url(
        r'^courses/{}/xqueue/(?P<userid>[^/]*)/(?P<mod_id>.*?)/(?P<dispatch>[^/]*)$'.format(
stv committed
321
            settings.COURSE_ID_PATTERN,
322
        ),
stv committed
323
        'courseware.module_render.xqueue_callback',
stv committed
324 325 326 327 328 329
        name='xqueue_callback',
    ),
    url(
        r'^change_setting$',
        'student.views.change_setting',
        name='change_setting',
stv committed
330 331 332 333 334 335
    ),

    # TODO: These views need to be updated before they work
    url(r'^calculate$', 'util.views.calculate'),

    url(r'^courses/?$', 'branding.views.courses', name="courses"),
stv committed
336 337 338 339 340 341 342 343 344 345
    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',
    ),
stv committed
346 347

    #About the course
stv committed
348 349 350 351 352 353 354
    url(
        r'^courses/{}/about$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'courseware.views.course_about',
        name='about_course',
    ),
stv committed
355 356

    #Inside the course
stv committed
357 358 359 360 361 362 363 364 365 366 367 368 369 370
    url(
        r'^courses/{}/$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'courseware.views.course_info',
        name='course_root',
    ),
    url(
        r'^courses/{}/info$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'courseware.views.course_info',
        name='info',
    ),
stv committed
371
    # TODO arjun remove when custom tabs in place, see courseware/courses.py
stv committed
372 373 374 375 376 377 378
    url(
        r'^courses/{}/syllabus$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'courseware.views.syllabus',
        name='syllabus',
    ),
stv committed
379

stv committed
380 381 382 383 384 385 386 387
    # Survey associated with a course
    url(
        r'^courses/{}/survey$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'courseware.views.course_survey',
        name='course_survey',
    ),
stv committed
388

stv committed
389 390 391 392 393 394 395 396 397 398 399 400 401 402
    url(
        r'^courses/{}/book/(?P<book_index>\d+)/$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'staticbook.views.index',
        name='book',
    ),
    url(
        r'^courses/{}/book/(?P<book_index>\d+)/(?P<page>\d+)$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'staticbook.views.index',
        name='book',
    ),
stv committed
403

stv committed
404 405 406 407 408 409 410 411 412 413 414 415 416 417
    url(
        r'^courses/{}/pdfbook/(?P<book_index>\d+)/$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'staticbook.views.pdf_index',
        name='pdf_book',
    ),
    url(
        r'^courses/{}/pdfbook/(?P<book_index>\d+)/(?P<page>\d+)$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'staticbook.views.pdf_index',
        name='pdf_book',
    ),
stv committed
418

stv committed
419 420 421 422 423 424 425
    url(
        r'^courses/{}/pdfbook/(?P<book_index>\d+)/chapter/(?P<chapter>\d+)/$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'staticbook.views.pdf_index',
        name='pdf_book',
    ),
stv committed
426 427
    url(
        r'^courses/{}/pdfbook/(?P<book_index>\d+)/chapter/(?P<chapter>\d+)/(?P<page>\d+)$'.format(
stv committed
428
            settings.COURSE_ID_PATTERN,
429
        ),
stv committed
430 431
        'staticbook.views.pdf_index',
        name='pdf_book',
stv committed
432 433
    ),

stv committed
434 435 436 437 438 439 440 441 442 443 444 445 446 447
    url(
        r'^courses/{}/htmlbook/(?P<book_index>\d+)/$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'staticbook.views.html_index',
        name='html_book',
    ),
    url(
        r'^courses/{}/htmlbook/(?P<book_index>\d+)/chapter/(?P<chapter>\d+)/$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'staticbook.views.html_index',
        name='html_book',
    ),
stv committed
448

stv committed
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
    url(
        r'^courses/{}/courseware/?$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'courseware.views.index',
        name='courseware',
    ),
    url(
        r'^courses/{}/courseware/(?P<chapter>[^/]*)/$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'courseware.views.index',
        name='courseware_chapter',
    ),
    url(
        r'^courses/{}/courseware/(?P<chapter>[^/]*)/(?P<section>[^/]*)/$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'courseware.views.index',
        name='courseware_section',
    ),
stv committed
470 471
    url(
        r'^courses/{}/courseware/(?P<chapter>[^/]*)/(?P<section>[^/]*)/(?P<position>[^/]*)/?$'.format(
stv committed
472
            settings.COURSE_ID_PATTERN,
473
        ),
stv committed
474 475
        'courseware.views.index',
        name='courseware_position',
stv committed
476 477
    ),

stv committed
478 479 480 481 482 483 484
    url(
        r'^courses/{}/progress$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'courseware.views.progress',
        name='progress',
    ),
stv committed
485
    # Takes optional student_id for instructor use--shows profile as that student sees it.
stv committed
486 487 488 489 490 491 492
    url(
        r'^courses/{}/progress/(?P<student_id>[^/]*)/$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'courseware.views.progress',
        name='student_progress',
    ),
stv committed
493 494

    # For the instructor
stv committed
495 496 497 498 499 500 501
    url(
        r'^courses/{}/instructor$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'instructor.views.instructor_dashboard.instructor_dashboard_2',
        name='instructor_dashboard',
    ),
stv committed
502 503


stv committed
504 505 506 507 508 509 510 511 512 513 514
    url(
        r'^courses/{}/set_course_mode_price$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'instructor.views.instructor_dashboard.set_course_mode_price',
        name='set_course_mode_price',
    ),
    url(
        r'^courses/{}/instructor/api/'.format(
            settings.COURSE_ID_PATTERN,
        ),
stv committed
515
        include('instructor.views.api_urls')),
stv committed
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
    url(
        r'^courses/{}/remove_coupon$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'instructor.views.coupons.remove_coupon',
        name='remove_coupon',
    ),
    url(
        r'^courses/{}/add_coupon$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'instructor.views.coupons.add_coupon',
        name='add_coupon',
    ),
    url(
        r'^courses/{}/update_coupon$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'instructor.views.coupons.update_coupon',
        name='update_coupon',
    ),
    url(
        r'^courses/{}/get_coupon_info$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'instructor.views.coupons.get_coupon_info',
        name='get_coupon_info',
    ),

    url(
        r'^courses/{}/'.format(
            settings.COURSE_ID_PATTERN,
        ),
        include(COURSE_URLS)
    ),
stv committed
551 552

    # Cohorts management
stv committed
553 554 555 556
    url(
        r'^courses/{}/cohorts/settings$'.format(
            settings.COURSE_KEY_PATTERN,
        ),
stv committed
557
        'openedx.core.djangoapps.course_groups.views.course_cohort_settings_handler',
stv committed
558 559 560 561 562 563 564 565 566 567 568 569 570
        name='course_cohort_settings',
    ),
    url(
        r'^courses/{}/cohorts/(?P<cohort_id>[0-9]+)?$'.format(
            settings.COURSE_KEY_PATTERN,
        ),
        'openedx.core.djangoapps.course_groups.views.cohort_handler',
        name='cohorts',
    ),
    url(
        r'^courses/{}/cohorts/(?P<cohort_id>[0-9]+)$'.format(
            settings.COURSE_KEY_PATTERN,
        ),
stv committed
571
        'openedx.core.djangoapps.course_groups.views.users_in_cohort',
stv committed
572 573 574 575 576 577
        name='list_cohort',
    ),
    url(
        r'^courses/{}/cohorts/(?P<cohort_id>[0-9]+)/add$'.format(
            settings.COURSE_KEY_PATTERN,
        ),
stv committed
578
        'openedx.core.djangoapps.course_groups.views.add_users_to_cohort',
stv committed
579 580 581 582 583 584
        name='add_to_cohort',
    ),
    url(
        r'^courses/{}/cohorts/(?P<cohort_id>[0-9]+)/delete$'.format(
            settings.COURSE_KEY_PATTERN,
        ),
stv committed
585
        'openedx.core.djangoapps.course_groups.views.remove_user_from_cohort',
stv committed
586 587 588 589 590 591
        name='remove_from_cohort',
    ),
    url(
        r'^courses/{}/cohorts/debug$'.format(
            settings.COURSE_KEY_PATTERN,
        ),
stv committed
592
        'openedx.core.djangoapps.course_groups.views.debug_cohort_mgmt',
stv committed
593 594 595 596 597 598
        name='debug_cohort_mgmt',
    ),
    url(
        r'^courses/{}/cohorts/topics$'.format(
            settings.COURSE_KEY_PATTERN,
        ),
stv committed
599
        'openedx.core.djangoapps.course_groups.views.cohort_discussion_topics',
stv committed
600 601
        name='cohort_discussion_topics',
    ),
stv committed
602

stv committed
603 604 605 606 607 608 609 610 611 612 613 614 615
    url(
        r'^courses/{}/notes$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'notes.views.notes',
        name='notes',
    ),
    url(
        r'^courses/{}/notes/'.format(
            settings.COURSE_ID_PATTERN,
        ),
        include('notes.urls')
    ),
stv committed
616 617

    # LTI endpoints listing
stv committed
618 619 620 621 622 623 624
    url(
        r'^courses/{}/lti_rest_endpoints/'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'courseware.views.get_course_lti_endpoints',
        name='lti_rest_endpoints',
    ),
stv committed
625 626

    # Student account
stv committed
627 628 629 630
    url(
        r'^account/',
        include('student_account.urls')
    ),
stv committed
631 632

    # Student profile
stv committed
633 634 635 636 637
    url(
        r'^u/(?P<username>[\w.@+-]+)$',
        'student_profile.views.learner_profile',
        name='learner_profile',
    ),
stv committed
638 639

    # Student Notes
stv committed
640 641 642 643 644 645 646
    url(
        r'^courses/{}/edxnotes'.format(
            settings.COURSE_ID_PATTERN,
        ),
        include('edxnotes.urls'),
        name='edxnotes_endpoints',
    ),
stv committed
647

stv committed
648 649 650 651
    url(
        r'^api/branding/v1/',
        include('branding.api_urls')
    ),
stv committed
652
)
Brian Wilson committed
653

stv committed
654 655 656
if settings.FEATURES["ENABLE_TEAMS"]:
    # Teams endpoints
    urlpatterns += (
stv committed
657 658 659 660 661 662 663 664 665 666 667
        url(
            r'^api/team/',
            include('lms.djangoapps.teams.api_urls')
        ),
        url(
            r'^courses/{}/teams'.format(
                settings.COURSE_ID_PATTERN,
            ),
            include('lms.djangoapps.teams.urls'),
            name='teams_endpoints',
        ),
stv committed
668
    )
Brian Wilson committed
669

stv committed
670 671 672
# allow course staff to change to student view of courseware
if settings.FEATURES.get('ENABLE_MASQUERADE'):
    urlpatterns += (
stv committed
673 674 675 676 677 678 679
        url(
            r'^courses/{}/masquerade$'.format(
                settings.COURSE_KEY_PATTERN,
            ),
            'courseware.masquerade.handle_ajax',
            name='masquerade_update',
        ),
680
    )
681

stv committed
682
urlpatterns += (
stv committed
683 684 685 686 687 688 689
    url(
        r'^courses/{}/generate_user_cert'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'courseware.views.generate_user_cert',
        name='generate_user_cert',
    ),
stv committed
690
)
691

stv committed
692 693
# discussion forums live within courseware, so courseware must be enabled first
if settings.FEATURES.get('ENABLE_DISCUSSION_SERVICE'):
694
    urlpatterns += (
stv committed
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732
        url(
            r'^api/discussion/',
            include('discussion_api.urls')
        ),
        url(
            r'^courses/{}/discussion/'.format(
                settings.COURSE_ID_PATTERN,
            ),
            include('django_comment_client.urls')
        ),
        url(
            r'^notification_prefs/enable/',
            'notification_prefs.views.ajax_enable'
        ),
        url(
            r'^notification_prefs/disable/',
            'notification_prefs.views.ajax_disable'
        ),
        url(
            r'^notification_prefs/status/',
            'notification_prefs.views.ajax_status'
        ),
        url(
            r'^notification_prefs/unsubscribe/(?P<token>[a-zA-Z0-9-_=]+)/',
            'notification_prefs.views.set_subscription',
            {
                'subscribe': False,
            },
            name='unsubscribe_forum_update',
        ),
        url(
            r'^notification_prefs/resubscribe/(?P<token>[a-zA-Z0-9-_=]+)/',
            'notification_prefs.views.set_subscription',
            {
                'subscribe': True,
            },
            name='resubscribe_forum_update',
        ),
733
    )
stv committed
734 735
urlpatterns += (
    # This MUST be the last view in the courseware--it's a catch-all for custom tabs.
stv committed
736 737 738 739 740 741 742
    url(
        r'^courses/{}/(?P<tab_slug>[^/]+)/$'.format(
            settings.COURSE_ID_PATTERN,
        ),
        'courseware.views.static_tab',
        name='static_tab',
    ),
stv committed
743
)
744

stv committed
745
if settings.FEATURES.get('ENABLE_STUDENT_HISTORY_VIEW'):
746
    urlpatterns += (
stv committed
747 748 749 750 751
        url(
            r'^courses/{}/submission_history/(?P<student_username>[^/]*)/(?P<location>.*?)$'.format(
                settings.COURSE_ID_PATTERN
            ),
            'courseware.views.submission_history',
stv committed
752 753
            name='submission_history',
        ),
David Baumgold committed
754
    )
755

756 757
if settings.FEATURES.get('CLASS_DASHBOARD'):
    urlpatterns += (
758
        url(r'^class_dashboard/', include('class_dashboard.urls')),
759 760
    )

761
if settings.DEBUG or settings.FEATURES.get('ENABLE_DJANGO_ADMIN_SITE'):
762
    ## Jasmine and admin
763
    urlpatterns += (url(r'^admin/', include(admin.site.urls)),)
764

765
if settings.FEATURES.get('AUTH_USE_OPENID'):
ichuang committed
766 767
    urlpatterns += (
        url(r'^openid/login/$', 'django_openid_auth.views.login_begin', name='openid-login'),
768
        url(r'^openid/complete/$', 'external_auth.views.openid_login_complete', name='openid-complete'),
ichuang committed
769
        url(r'^openid/logo.gif$', 'django_openid_auth.views.logo', name='openid-logo'),
770 771
    )

772
if settings.FEATURES.get('AUTH_USE_SHIB'):
773 774 775 776
    urlpatterns += (
        url(r'^shib-login/$', 'external_auth.views.shib_login', name='shib-login'),
    )

777
if settings.FEATURES.get('AUTH_USE_CAS'):
778 779 780 781 782
    urlpatterns += (
        url(r'^cas-auth/login/$', 'external_auth.views.cas_login', name="cas-login"),
        url(r'^cas-auth/logout/$', 'django_cas.views.logout', {'next_page': '/'}, name="cas-logout"),
    )

783
if settings.FEATURES.get('RESTRICT_ENROLL_BY_REG_METHOD'):
784
    urlpatterns += (
785
        url(r'^course_specific_login/{}/$'.format(settings.COURSE_ID_PATTERN),
786
            'external_auth.views.course_specific_login', name='course-specific-login'),
787
        url(r'^course_specific_register/{}/$'.format(settings.COURSE_ID_PATTERN),
788 789 790 791
            'external_auth.views.course_specific_register', name='course-specific-register'),

    )

792 793
# Shopping cart
urlpatterns += (
794
    url(r'^shoppingcart/', include('shoppingcart.urls')),
795
    url(r'^commerce/', include('commerce.urls', namespace='commerce')),
796 797
)

798 799
# Embargo
if settings.FEATURES.get('EMBARGO'):
800 801 802 803
    urlpatterns += (
        url(r'^embargo/', include('embargo.urls')),
    )

804 805 806 807
# Survey Djangoapp
urlpatterns += (
    url(r'^survey/', include('survey.urls')),
)
808

809
if settings.FEATURES.get('AUTH_USE_OPENID_PROVIDER'):
810
    urlpatterns += (
811
        url(r'^openid/provider/login/$', 'external_auth.views.provider_login', name='openid-provider-login'),
812 813 814 815 816
        url(
            r'^openid/provider/login/(?:.+)$',
            'external_auth.views.provider_identity',
            name='openid-provider-login-identity'
        ),
817 818
        url(r'^openid/provider/identity/$', 'external_auth.views.provider_identity', name='openid-provider-identity'),
        url(r'^openid/provider/xrds/$', 'external_auth.views.provider_xrds', name='openid-provider-xrds')
819
    )
ichuang committed
820

821 822 823 824 825 826
if settings.FEATURES.get('ENABLE_OAUTH2_PROVIDER'):
    urlpatterns += (
        url(r'^oauth2/', include('oauth2_provider.urls', namespace='oauth2')),
    )


827
if settings.FEATURES.get('ENABLE_LMS_MIGRATION'):
828 829 830
    urlpatterns += (
        url(r'^migrate/modules$', 'lms_migration.migrate.manage_modulestores'),
        url(r'^migrate/reload/(?P<reload_dir>[^/]+)$', 'lms_migration.migrate.manage_modulestores'),
831 832 833 834
        url(
            r'^migrate/reload/(?P<reload_dir>[^/]+)/(?P<commit_id>[^/]+)$',
            'lms_migration.migrate.manage_modulestores'
        ),
835 836
        url(r'^gitreload$', 'lms_migration.migrate.gitreload'),
        url(r'^gitreload/(?P<reload_dir>[^/]+)$', 'lms_migration.migrate.gitreload'),
David Baumgold committed
837
    )
838

839
if settings.FEATURES.get('ENABLE_SQL_TRACKING_LOGS'):
840 841
    urlpatterns += (
        url(r'^event_logs$', 'track.views.view_tracking_log'),
842
        url(r'^event_logs/(?P<args>.+)$', 'track.views.view_tracking_log'),
David Baumgold committed
843
    )
844

845
if settings.FEATURES.get('ENABLE_SERVICE_STATUS'):
846 847 848 849
    urlpatterns += (
        url(r'^status/', include('service_status.urls')),
    )

850
if settings.FEATURES.get('ENABLE_INSTRUCTOR_BACKGROUND_TASKS'):
851
    urlpatterns += (
852 853 854 855 856
        url(
            r'^instructor_task_status/$',
            'instructor_task.views.instructor_task_status',
            name='instructor_task_status'
        ),
857 858
    )

859
if settings.FEATURES.get('RUN_AS_ANALYTICS_SERVER_ENABLED'):
860
    urlpatterns += (
Juho Kim committed
861
        url(r'^edinsights_service/', include('edinsights.core.urls')),
862 863
    )

864
if settings.FEATURES.get('ENABLE_DEBUG_RUN_PYTHON'):
865
    urlpatterns += (
866
        url(r'^debug/run_python$', 'debug.views.run_python'),
867
    )
868

869
urlpatterns += (
870
    url(r'^debug/show_parameters$', 'debug.views.show_parameters'),
871 872
)

873
# enable automatic login
874
if settings.FEATURES.get('AUTOMATIC_AUTH_FOR_TESTING'):
875
    urlpatterns += (
876
        url(r'^auto_auth$', 'student.views.auto_auth'),
877 878
    )

879 880 881 882
# Third-party auth.
if settings.FEATURES.get('ENABLE_THIRD_PARTY_AUTH'):
    urlpatterns += (
        url(r'', include('third_party_auth.urls')),
883
        url(r'api/third_party_auth/', include('third_party_auth.api.urls')),
884 885 886 887 888 889
        # NOTE: The following login_oauth_token endpoint is DEPRECATED.
        # Please use the exchange_access_token endpoint instead.
        url(r'^login_oauth_token/(?P<backend>[^/]+)/$', 'student.views.login_oauth_token'),
    )

# OAuth token exchange
890 891 892 893 894 895 896 897 898
if settings.FEATURES.get('ENABLE_OAUTH2_PROVIDER'):
    if settings.FEATURES.get('ENABLE_THIRD_PARTY_AUTH'):
        urlpatterns += (
            url(
                r'^oauth2/exchange_access_token/(?P<backend>[^/]+)/$',
                auth_exchange.views.AccessTokenExchangeView.as_view(),
                name="exchange_access_token"
            ),
        )
899
    urlpatterns += (
900
        url(
901 902 903
            r'^oauth2/login/$',
            auth_exchange.views.LoginWithAccessTokenView.as_view(),
            name="login_with_access_token"
904
        ),
905 906
    )

907
# Certificates
908
urlpatterns += (
909
    url(r'^certificates/', include('certificates.urls', app_name="certificates", namespace="certificates")),
910

911 912 913 914
    # Backwards compatibility with XQueue, which uses URLs that are not prefixed with /certificates/
    url(r'^update_certificate$', 'certificates.views.update_certificate'),
    url(r'^update_example_certificate$', 'certificates.views.update_example_certificate'),
    url(r'^request_certificate$', 'certificates.views.request_certificate'),
915 916
)

917 918 919 920 921
# XDomain proxy
urlpatterns += (
    url(r'^xdomain_proxy.html$', 'cors_csrf.views.xdomain_proxy', name='xdomain_proxy'),
)

922 923 924 925 926
# Custom courses on edX (CCX) URLs
if settings.FEATURES["CUSTOM_COURSES_EDX"]:
    urlpatterns += (
        url(r'^courses/{}/'.format(settings.COURSE_ID_PATTERN),
            include('ccx.urls')),
927
        url(r'^api/ccx/', include('lms.djangoapps.ccx.api.urls', namespace='ccx_api')),
928 929
    )

930 931 932 933 934
# Access to courseware as an LTI provider
if settings.FEATURES.get("ENABLE_LTI_PROVIDER"):
    urlpatterns += (
        url(r'^lti_provider/', include('lti_provider.urls')),
    )
935

936 937
urlpatterns += (
    url(r'config/self_paced', ConfigurationModelCurrentAPIView.as_view(model=SelfPacedConfiguration)),
938
    url(r'config/programs', ConfigurationModelCurrentAPIView.as_view(model=ProgramsApiConfig)),
939 940
)

941 942
urlpatterns = patterns(*urlpatterns)

943
if settings.DEBUG:
944
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
945
    urlpatterns += static(
946 947
        settings.PROFILE_IMAGE_BACKEND['options']['base_url'],
        document_root=settings.PROFILE_IMAGE_BACKEND['options']['location']
948
    )
949

950 951 952
    # in debug mode, allow any template to be rendered (most useful for UX reference templates)
    urlpatterns += url(r'^template/(?P<template>.+)$', 'debug.views.show_reference_template'),

953
if 'debug_toolbar' in settings.INSTALLED_APPS:
954 955 956 957 958 959
    import debug_toolbar
    urlpatterns += (
        url(r'^__debug__/', include(debug_toolbar.urls)),
    )

# Custom error pages
960 961
handler404 = 'static_template_view.views.render_404'
handler500 = 'static_template_view.views.render_500'
962 963 964

# display error page templates, for testing purposes
urlpatterns += (
965 966
    url(r'^404$', handler404),
    url(r'^500$', handler500),
967
)
968 969 970 971 972

# include into our URL patterns the HTTP REST API that comes with edx-proctoring.
urlpatterns += (
    url(r'^api/', include('edx_proctoring.urls')),
)
973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991

if settings.FEATURES.get('ENABLE_FINANCIAL_ASSISTANCE_FORM'):
    urlpatterns += (
        url(
            r'^financial-assistance/$',
            'courseware.views.financial_assistance',
            name='financial_assistance'
        ),
        url(
            r'^financial-assistance/apply/$',
            'courseware.views.financial_assistance_form',
            name='financial_assistance_form'
        ),
        url(
            r'^financial-assistance/submit/$',
            'courseware.views.financial_assistance_request',
            name='submit_financial_assistance_request'
        )
    )