"""This module holds the urls for the ``assessments`` app."""

from importlib import import_module

from django.conf import settings

from macrosurl import url

from . import views


urlpatterns = [

    # Competency-related URLs
    url(
        r'^$',
        views.CompetencyListView.as_view(),
        name='competency-list'
    ),
    url(
        r'^:jobprofile_uuid$',
        views.CompetencyListView.as_view(),
        name='competency-list'
    ),
    url(
        r'^:jobprofile_uuid/competency-tree/duplicate$',
        views.CompetencyTreeDuplicateView.as_view(),
        name='competency-tree-duplicate'
    ),
    url(
        r'^:jobprofile_uuid/competency/create$',
        views.CompetencyCreateView.as_view(),
        name='competency-create'
    ),
    url(
        r'^:jobprofile_uuid/competency/sort$',
        views.CompetencySortView.as_view(),
        name='competency-sort'
    ),
    url(
        r'^:jobprofile_uuid/competency/:competency_uuid/edit$',
        views.CompetencyUpdateView.as_view(),
        name='competency-edit'
    ),
    url(
        r'^:jobprofile_uuid/competency/:competency_uuid/delete$',
        views.CompetencyDeleteView.as_view(),
        name='competency-delete'
    ),
    url(
        r'^competency/:competency_uuid/dimension/create$',
        views.DimensionCreateView.as_view(),
        name='dimension-create'
    ),
    url(
        r'^competency/:competency_uuid/dimension/sort$',
        views.DimensionSortView.as_view(),
        name='dimension-sort'
    ),
    url(
        r'^competency/:competency_uuid/dimension/:dimension_uuid/update$',
        views.DimensionUpdateView.as_view(),
        name='dimension-edit'
    ),
    url(
        r'^competency/:competency_uuid/dimension/:dimension_uuid/delete$',
        views.DimensionDeleteView.as_view(),
        name='dimension-delete'
    ),

    # Competencies import/export
    url(
        r'^import_xls$',
        views.XLSCompetenciesImportView.as_view(),
        name='import_xls'
    ),
    url(
        r'^:competencytree_uuid/export_xls$',
        views.XLSCompetenciesExportView.as_view(),
        name='export_xls'
    ),

    # Certification-related URL
    url(
        r'^:jobprofile_uuid/certification_program$',
        views.CertificationProgramView.as_view(),
        name='certification-program'
    ),

    url(
        r'^:jobprofile_uuid/certification_program/status/create$',
        views.CertificationStatusCreateView.as_view(),
        name='certification-status-create'
    ),
    url(
        r'^:jobprofile_uuid/certification_status/:certificationstatus_uuid/update$',
        views.CertificationStatusUpdateView.as_view(),
        name='certification-status-edit'
    ),
    url(
        r'^:jobprofile_uuid/certification_status/:certificationstatus_uuid/delete$',
        views.CertificationStatusDeleteView.as_view(),
        name='certification-status-delete'
    ),
    url(
        r'^:jobprofile_uuid/certification_status/:certificationstatus_uuid/reference$',
        views.CertificationStatusReferenceView.as_view(),
        name='certification-status-reference'
    ),

    url(
        r'^certification_results$',
        views.CertificationResultsListView.as_view(),
        name='certification-results-list'
    ),
    url(
        r'^:jobprofile_uuid/certification_results$',
        views.CertificationResultsListView.as_view(),
        name='certification-results-list'
    ),
    url(
        r'^:jobprofile_uuid/certification_results/:certificationprogramuserstatus_uuid$',
        views.CertificationResultsDetailView.as_view(),
        name='certification-result-detail'
    ),
    url(
        r'^:jobprofile_uuid/certification_results/:certificationprogramuserstatus_uuid/pdf$',
        views.CertificationResultsPDFView.as_view(),
        name='certification-result-pdf'
    ),
    url(
        r'^:jobprofile_uuid/certification_results/:certificationprogramuserstatus_uuid/update$',
        views.CertificationResultsUpdateView.as_view(),
        name='certification-result-update'
    ),
    url(
        r'^:jobprofile_uuid/certification_results/:certificationprogramuserstatus_uuid/validate',
        views.CertificationResultsValidateView.as_view(),
        name='certification-result-validate'
    ),

    # Recommendation-related URLs
    url(
        r'^:jobprofile_uuid/curriculum$',
        views.CurriculumView.as_view(),
        name='curriculum'
    ),

    url(
        r'^curriculum/:curriculum_uuid/topic/create$',
        views.TopicCreateView.as_view(),
        name='topic-create'
    ),
    url(
        r'^curriculum/:curriculum_uuid/topic/:topic_uuid/edit$',
        views.TopicUpdateView.as_view(),
        name='topic-edit'
    ),
    url(
        r'^curriculum/:curriculum_uuid/topic/:topic_uuid/delete$',
        views.TopicDeleteView.as_view(),
        name='topic-delete'
    ),

    url(
        r'^topic/:topic_uuid/lesson/create$',
        views.LessonCreateView.as_view(),
        name='lesson-create'
    ),
    url(
        r'^lesson/:lesson_uuid/update$',
        views.LessonUpdateView.as_view(),
        name='lesson-edit'
    ),
    url(
        r'^lesson/:lesson_uuid/delete$',
        views.LessonDeleteView.as_view(),
        name='lesson-delete'
    ),

    url(
        r'^lesson/:lesson_uuid/dw/create$',
        views.LessonDimensionWeightCreateView.as_view(),
        name='lesson-dimension-weight-create'
    ),
    url(
        r'^lesson/:lesson_uuid/dw/:lessondimensionweight_uuid/update$',
        views.LessonDimensionWeightUpdateView.as_view(),
        name='lesson-dimension-weight-edit'
    ),
    url(
        r'^lesson/:lesson_uuid/dw/:lessondimensionweight_uuid/delete$',
        views.LessonDimensionWeightDeleteView.as_view(),
        name='lesson-dimension-weight-delete'
    ),

    url(
        r'^lesson/:lesson_uuid/rl/create$',
        views.LessonRecommendationLevelCreateView.as_view(),
        name='lesson-recommendation-level-create'
    ),
    url(
        r'^lesson/:lesson_uuid/rl/:lessonrecommendationthreshold_uuid/update$',
        views.LessonRecommendationLevelUpdateView.as_view(),
        name='lesson-recommendation-level-edit'
    ),
    url(
        r'^lesson/:lesson_uuid/rl/:lessonrecommendationthreshold_uuid/delete$',
        views.LessonRecommendationLevelDeleteView.as_view(),
        name='lesson-recommendation-level-delete'
    ),

    # Session scores URL
    url(
        r'^sessions_scores$',
        views.SessionScoresView.as_view(),
        name='export_sessions_scores'
    ),

    # Export translatable fields
    url(
        r'^:jobprofile_uuid/export_translation/$',
        views.CompetencyTreeExportTranslationView.as_view(),
        name='export-translation'
    ),

    # Import translation fields
    url(
        r'^:jobprofile_uuid/import_translation/$',
        views.CompetencyTreeImportTranslationView.as_view(),
        name='import-translation'
    )
]

# Allow client-specific URL patterns
custom_module_path = 'mtp.custom.%s.apps.assessments.urls' % settings.INSTANCE_NAME
try:
    custom_module = import_module(custom_module_path)
    urlpatterns += custom_module.extend_urlpatterns()
except ImportError:
    pass
