"""This module holds the urls for the ``surveys`` app

The following views are defined:

- / : named "pools", currently a redirect to /pools/
- /pools/ : named "pools-list", used to display a list of pools for the currently logged in user
- /pools/add/ : named "pools-create", used to create a pool
- /pools/:uuid/ : named "pools-update", used to update a pool
- /pools/:uuid/delete/ : named "pools-delete", used to delete a pool, with a confirmation step

Notes
-----
We use ``django-macros-url`` to ease the use of parameters in urls, for example UUIDs:
``:uuid`` is more readable than
``(?P<uuid>[a-fA-F0-9]{8}-?[a-fA-F0-9]{4}-?[a-fA-F0-9]{4}-?[a-fA-F0-9]{4}-?[a-fA-F0-9]{12})``

"""

from django.views.generic import RedirectView

from macrosurl import url

from . import views

urlpatterns = [
    url(
        r'^$',
        RedirectView.as_view(pattern_name='surveys:pools-list'),
        name='home'
    ),
    url(
        r'^pools/$',
        views.PoolsList.as_view(),
        name='pools-list'
    ),
    url(
        r'^pools/sort/$',
        views.PoolsSort.as_view(),
        name='pools-sort'
    ),
    url(
        r'^pools/add/$',
        views.PoolCreate.as_view(),
        name='pool-create'
    ),
    url(
        r'^pools/:pool_uuid/$',
        views.PoolUpdate.as_view(),
        name='pool-update'
    ),
    url(
        r'^pools/:pool_uuid/delete/$',
        views.PoolDelete.as_view(),
        name='pool-delete'
    ),
    url(
        r'^pools/:pool_uuid/questions/$',
        views.QuestionsList.as_view(),
        name='questions-list'
    ),
    url(
        r'^pools/:pool_uuid/questions/sort/$',
        views.QuestionsSort.as_view(),
        name='questions-sort'
    ),
    url(
        r'^pools/:pool_uuid/question/add/$',
        views.QuestionCreate.as_view(),
        name='question-create'
    ),
    url(
        r'^pools/:pool_uuid/question/:question_uuid/$',
        views.QuestionUpdate.as_view(),
        name='question-update'
    ),
    url(
        r'^pools/:pool_uuid/question/:question_uuid/delete/$',
        views.QuestionDelete.as_view(),
        name='question-delete'
    ),
    # Export translatable file
    url(
        r'^translation/:language_code_slug$',
        views.SurveyExportTranslationView.as_view(),
        name='export-translation'
    ),

    # Import translation file
    url(
        r'^import_translation/:language_code_slug$',
        views.SurveyImportTranslationView.as_view(),
        name='import-translation'
    ),
]
