<commit_before>"""
URLs for LMS
"""

from config_models.views import ConfigurationModelCurrentAPIView
from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib.admin import autodiscover as django_autodiscover
from django.utils.translation import ugettext_lazy as _
from django.views.generic.base import RedirectView
from edx_api_doc_tools import make_docs_urls
from ratelimitbackend import admin

from branding import views as branding_views
from debug import views as debug_views
from lms.djangoapps.certificates import views as certificates_views
from lms.djangoapps.courseware.masquerade import MasqueradeView
from lms.djangoapps.courseware.module_render import (
    handle_xblock_callback,
    handle_xblock_callback_noauth,
    xblock_view,
    xqueue_callback
)
from lms.djangoapps.courseware.views import views as courseware_views
from lms.djangoapps.courseware.views.index import CoursewareIndex
from lms.djangoapps.courseware.views.views import CourseTabView, EnrollStaffView, StaticCourseTabView
from lms.djangoapps.discussion import views as discussion_views
from lms.djangoapps.discussion.notification_prefs import views as notification_prefs_views
from lms.djangoapps.instructor.views import coupons as instructor_coupons_views
from lms.djangoapps.instructor.views import instructor_dashboard as instructor_dashboard_views
from lms.djangoapps.instructor.views import registration_codes as instructor_registration_codes_views
from lms.djangoapps.instructor_task import views as instructor_task_views
from openedx.core.apidocs import api_info
from openedx.core.djangoapps.auth_exchange.views import LoginWithAccessTokenView
from openedx.core.djangoapps.catalog.models import CatalogIntegration
from openedx.core.djangoapps.common_views.xblock import xblock_resource
from openedx.core.djangoapps.cors_csrf import views as cors_csrf_views
from openedx.core.djangoapps.course_groups import views as course_groups_views
from openedx.core.djangoapps.debug import views as openedx_debug_views
from openedx.core.djangoapps.django_comment_common.models import ForumsConfig
from openedx.core.djangoapps.lang_pref import views as lang_pref_views
from openedx.core.djangoapps.password_policy import compliance as password_policy_compliance
from openedx.core.djangoapps.password_policy.forms import PasswordPolicyAwareAdminAuthForm
from openedx.core.djangoapps.plugins import constants as plugin_constants
from openedx.core.djangoapps.plugins import plugin_urls
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 openedx.core.djangoapps.user_authn.views.login import redirect_to_lms_login
from openedx.core.djangoapps.verified_track_content import views as verified_track_content_views
from openedx.features.enterprise_support.api import enterprise_enabled
from static_template_view import views as static_template_view_views
from staticbook import views as staticbook_views
from student import views as student_views
from util import views as util_views

RESET_COURSE_DEADLINES_NAME = 'reset_course_deadlines'
RENDER_XBLOCK_NAME = 'render_xblock'
COURSE_DATES_NAME = 'dates'

if settings.DEBUG or settings.FEATURES.get('ENABLE_DJANGO_ADMIN_SITE'):
    django_autodiscover()
    admin.site.site_header = _('LMS Administration')
    admin.site.site_title = admin.site.site_header

    if password_policy_compliance.should_enforce_compliance_on_login():
        admin.site.login_form = PasswordPolicyAwareAdminAuthForm

# Custom error pages
# These are used by Django to render these error codes. Do not remove.
# pylint: disable=invalid-name
handler404 = static_template_view_views.render_404
handler500 = static_template_view_views.render_500

notification_prefs_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>[<KEY>',
        notification_prefs_views.set_subscription,
        {'subscribe': False},
        name='unsubscribe_forum_update',
    ),
    url(
        r'^notification_prefs/resubscribe/(?P<token>[<KEY>',
        notification_prefs_views.set_subscription,
        {'subscribe': True},
        name='resubscribe_forum_update',
    ),
]


urlpatterns = [
    url(r'^$', branding_views.index, name='root'),  # Main marketing page, or redirect to courseware

    url(r'', include('student.urls')),
    # TODO: Move lms specific student views out of common code
    url(r'^dashboard/?$', student_views.student_dashboard, name='dashboard'),
    url(r'^change_enrollment$', student_views.change_enrollment, name='change_enrollment'),

    # Event tracking endpoints
    url(r'', include('track.urls')),

    # Static template view endpoints like blog, faq, etc.
    url(r'', include('static_template_view.urls')),

    url(r'^heartbeat', include('openedx.core.djangoapps.heartbeat.urls')),

    url(r'^notifier_api/', include('lms.djangoapps.discussion.notifier_api.urls')),
    url(r'^/api/notifier/', include('lms.djangoapps.discussion.notifier_api.urls')),

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

    # Enrollment API RESTful endpoints
    url(r'^api/enrollment/v1/', include('openedx.core.djangoapps.enrollments.urls')),

    # Entitlement API RESTful endpoints
    url(r'^api/entitlements/', include(('entitlements.api.urls', 'common.djangoapps.entitlements'),
                                       namespace='entitlements_api')),

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

    # Course API
    url(r'^api/courses/', include('course_api.urls')),

    # User API endpoints
    url(r'^api/user/', include('openedx.core.djangoapps.user_api.urls')),
    # Note: these are older versions of the User API that will eventually be
    # subsumed by api/user listed above.
    url(r'', include('openedx.core.djangoapps.user_api.legacy_urls')),

    # Profile Images API endpoints
    url(r'^api/profile_images/', include('openedx.core.djangoapps.profile_images.urls')),

    # 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')),

    url(r'^api/commerce/', include(('commerce.api.urls', 'lms.djangoapps.commerce'), namespace='commerce_api')),
    url(r'^api/credit/', include('openedx.core.djangoapps.credit.urls')),
    url(r'^rss_proxy/', include('rss_proxy.urls')),
    url(r'^api/organizations/', include('organizations.urls', namespace='organizations')),

    url(r'^catalog/', include(('openedx.core.djangoapps.catalog.urls', 'openedx.core.djangoapps.catalog'),
                              namespace='catalog')),

    # Update session view
    url(r'^lang_pref/session_language', lang_pref_views.update_session_language, name='session_language'),

    # Multiple course modes and identity verification
    url(r'^course_modes/', include('course_modes.urls')),
    url(r'^api/course_modes/', include(('course_modes.api.urls', 'common.djangoapps.course_mods'),
                                       namespace='course_modes_api')),
    url(r'^verify_student/', include('verify_student.urls')),

    # URLs for managing dark launches of languages
    url(r'^update_lang/', include(('openedx.core.djangoapps.dark_lang.urls', 'openedx.core.djangoapps.dark_lang'),
                                  namespace='dark_lang')),

    # For redirecting to help pages.
    url(r'^help_token/', include('help_tokens.urls')),

    # URLs for API access management
    url(r'^api-admin/', include(('openedx.core.djangoapps.api_admin.urls', 'openedx.core.djangoapps.api_admin'),
                                namespace='api_admin')),

    url(r'^dashboard/', include('learner_dashboard.urls')),
    url(r'^api/experiments/', include(('experiments.urls', 'lms.djangoapps.experiments'), namespace='api_experiments')),
    url(r'^api/discounts/', include(('openedx.features.discounts.urls', 'openedx.features.discounts'),
                                    namespace='api_discounts')),
]

if settings.FEATURES.get('ENABLE_MOBILE_REST_API'):
    urlpatterns += [
        url(r'^api/mobile/(?P<api_version>v(1|0.5))/', include('mobile_api.urls')),
    ]

# EDX SOLUTIONS API
if settings.FEATURES.get('EDX_SOLUTIONS_API'):
    urlpatterns += [
        url(r'^api/server/', include('edx_solutions_api_integration.urls')),
        url(r'^api/completion/v0/', include('completion_aggregator.api.v0.urls'))
    ]

# COMPLETION

urlpatterns += [
    url(r'^api/completion/', include('completion.api.urls', namespace='completion_api')),
    url(r'^api/completion-aggregator/', include('completion_aggregator.urls')),
]

if settings.FEATURES.get('ENABLE_OPENBADGES'):
    urlpatterns += [
        url(r'^api/badges/v1/', include('badges.api.urls', app_name='badges', namespace='badges_api')),
    ]

urlpatterns += [
    url(r'^openassessment/fileupload/', include('openassessment.fileupload.urls')),
]

# sysadmin dashboard, to see what courses are loaded, to delete & load courses
if settings.FEATURES.get('ENABLE_SYSADMIN_DASHBOARD'):
    urlpatterns += [
        url(r'^sysadmin/', include('dashboard.sysadmin_urls')),
    ]

urlpatterns += [
    url(r'^support/', include('support.urls')),
]

# Favicon<commit_msg>fix unit tests for lms badges app (#1954)<commit_after>"""
URLs for LMS
"""

from config_models.views import ConfigurationModelCurrentAPIView
from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib.admin import autodiscover as django_autodiscover
from django.utils.translation import ugettext_lazy as _
from django.views.generic.base import RedirectView
from edx_api_doc_tools import make_docs_urls
from ratelimitbackend import admin

from branding import views as branding_views
from debug import views as debug_views
from lms.djangoapps.certificates import views as certificates_views
from lms.djangoapps.courseware.masquerade import MasqueradeView
from lms.djangoapps.courseware.module_render import (
    handle_xblock_callback,
    handle_xblock_callback_noauth,
    xblock_view,
    xqueue_callback
)
from lms.djangoapps.courseware.views import views as courseware_views
from lms.djangoapps.courseware.views.index import CoursewareIndex
from lms.djangoapps.courseware.views.views import CourseTabView, EnrollStaffView, StaticCourseTabView
from lms.djangoapps.discussion import views as discussion_views
from lms.djangoapps.discussion.notification_prefs import views as notification_prefs_views
from lms.djangoapps.instructor.views import coupons as instructor_coupons_views
from lms.djangoapps.instructor.views import instructor_dashboard as instructor_dashboard_views
from lms.djangoapps.instructor.views import registration_codes as instructor_registration_codes_views
from lms.djangoapps.instructor_task import views as instructor_task_views
from openedx.core.apidocs import api_info
from openedx.core.djangoapps.auth_exchange.views import LoginWithAccessTokenView
from openedx.core.djangoapps.catalog.models import CatalogIntegration
from openedx.core.djangoapps.common_views.xblock import xblock_resource
from openedx.core.djangoapps.cors_csrf import views as cors_csrf_views
from openedx.core.djangoapps.course_groups import views as course_groups_views
from openedx.core.djangoapps.debug import views as openedx_debug_views
from openedx.core.djangoapps.django_comment_common.models import ForumsConfig
from openedx.core.djangoapps.lang_pref import views as lang_pref_views
from openedx.core.djangoapps.password_policy import compliance as password_policy_compliance
from openedx.core.djangoapps.password_policy.forms import PasswordPolicyAwareAdminAuthForm
from openedx.core.djangoapps.plugins import constants as plugin_constants
from openedx.core.djangoapps.plugins import plugin_urls
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 openedx.core.djangoapps.user_authn.views.login import redirect_to_lms_login
from openedx.core.djangoapps.verified_track_content import views as verified_track_content_views
from openedx.features.enterprise_support.api import enterprise_enabled
from static_template_view import views as static_template_view_views
from staticbook import views as staticbook_views
from student import views as student_views
from util import views as util_views

RESET_COURSE_DEADLINES_NAME = 'reset_course_deadlines'
RENDER_XBLOCK_NAME = 'render_xblock'
COURSE_DATES_NAME = 'dates'

if settings.DEBUG or settings.FEATURES.get('ENABLE_DJANGO_ADMIN_SITE'):
    django_autodiscover()
    admin.site.site_header = _('LMS Administration')
    admin.site.site_title = admin.site.site_header

    if password_policy_compliance.should_enforce_compliance_on_login():
        admin.site.login_form = PasswordPolicyAwareAdminAuthForm

# Custom error pages
# These are used by Django to render these error codes. Do not remove.
# pylint: disable=invalid-name
handler404 = static_template_view_views.render_404
handler500 = static_template_view_views.render_500

notification_prefs_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-<KEY>]+)/',
        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',
    ),
]


urlpatterns = [
    url(r'^$', branding_views.index, name='root'),  # Main marketing page, or redirect to courseware

    url(r'', include('student.urls')),
    # TODO: Move lms specific student views out of common code
    url(r'^dashboard/?$', student_views.student_dashboard, name='dashboard'),
    url(r'^change_enrollment$', student_views.change_enrollment, name='change_enrollment'),

    # Event tracking endpoints
    url(r'', include('track.urls')),

    # Static template view endpoints like blog, faq, etc.
    url(r'', include('static_template_view.urls')),

    url(r'^heartbeat', include('openedx.core.djangoapps.heartbeat.urls')),

    url(r'^notifier_api/', include('lms.djangoapps.discussion.notifier_api.urls')),
    url(r'^/api/notifier/', include('lms.djangoapps.discussion.notifier_api.urls')),

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

    # Enrollment API RESTful endpoints
    url(r'^api/enrollment/v1/', include('openedx.core.djangoapps.enrollments.urls')),

    # Entitlement API RESTful endpoints
    url(r'^api/entitlements/', include(('entitlements.api.urls', 'common.djangoapps.entitlements'),
                                       namespace='entitlements_api')),

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

    # Course API
    url(r'^api/courses/', include('course_api.urls')),

    # User API endpoints
    url(r'^api/user/', include('openedx.core.djangoapps.user_api.urls')),
    # Note: these are older versions of the User API that will eventually be
    # subsumed by api/user listed above.
    url(r'', include('openedx.core.djangoapps.user_api.legacy_urls')),

    # Profile Images API endpoints
    url(r'^api/profile_images/', include('openedx.core.djangoapps.profile_images.urls')),

    # 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')),

    url(r'^api/commerce/', include(('commerce.api.urls', 'lms.djangoapps.commerce'), namespace='commerce_api')),
    url(r'^api/credit/', include('openedx.core.djangoapps.credit.urls')),
    url(r'^rss_proxy/', include('rss_proxy.urls')),
    url(r'^api/organizations/', include('organizations.urls', namespace='organizations')),

    url(r'^catalog/', include(('openedx.core.djangoapps.catalog.urls', 'openedx.core.djangoapps.catalog'),
                              namespace='catalog')),

    # Update session view
    url(r'^lang_pref/session_language', lang_pref_views.update_session_language, name='session_language'),

    # Multiple course modes and identity verification
    url(r'^course_modes/', include('course_modes.urls')),
    url(r'^api/course_modes/', include(('course_modes.api.urls', 'common.djangoapps.course_mods'),
                                       namespace='course_modes_api')),
    url(r'^verify_student/', include('verify_student.urls')),

    # URLs for managing dark launches of languages
    url(r'^update_lang/', include(('openedx.core.djangoapps.dark_lang.urls', 'openedx.core.djangoapps.dark_lang'),
                                  namespace='dark_lang')),

    # For redirecting to help pages.
    url(r'^help_token/', include('help_tokens.urls')),

    # URLs for API access management
    url(r'^api-admin/', include(('openedx.core.djangoapps.api_admin.urls', 'openedx.core.djangoapps.api_admin'),
                                namespace='api_admin')),

    url(r'^dashboard/', include('learner_dashboard.urls')),
    url(r'^api/experiments/', include(('experiments.urls', 'lms.djangoapps.experiments'), namespace='api_experiments')),
    url(r'^api/discounts/', include(('openedx.features.discounts.urls', 'openedx.features.discounts'),
                                    namespace='api_discounts')),
]

if settings.FEATURES.get('ENABLE_MOBILE_REST_API'):
    urlpatterns += [
        url(r'^api/mobile/(?P<api_version>v(1|0.5))/', include('mobile_api.urls')),
    ]

# EDX SOLUTIONS API
if settings.FEATURES.get('EDX_SOLUTIONS_API'):
    urlpatterns += [
        url(r'^api/server/', include('edx_solutions_api_integration.urls')),
        url(r'^api/completion/v0/', include('completion_aggregator.api.v0.urls'))
    ]

# COMPLETION

urlpatterns += [
    url(r'^api/completion/', include('completion.api.urls', namespace='completion_api')),
    url(r'^api/completion-aggregator/', include('completion_aggregator.urls')),
]

if settings.FEATURES.get('ENABLE_OPENBADGES'):
    urlpatterns += [
        url(r'^api/badges/v1/', include(('badges.api.urls', 'badges'), namespace='badges_api')),
    ]

urlpatterns += [
    url(r'^openassessment/fileupload/', include('openassessment.fileupload.urls')),
]

# sysadmin dashboard, to see what courses are loaded, to delete & load courses
if settings.FEATURES.get('ENABLE_SYSADMIN_DASHBOARD'):
    urlpatterns += [
        url(r'^sysadmin/', include('dashboard.sysadmin_urls')),
    ]

urlpatterns += [
    url(r'^support/', include('support.urls')),
]

# Favicon
{'fraction_non_alphanumeric': 0.11476259589467136, 'fraction_numerical': 0.002799087704748082, 'mean_word_length': 4.898196270253745, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1293775', 'n_tokens_mistral': 6099, 'n_tokens_neox': 5880, 'n_words': 1108}