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

from importlib import import_module

from django.conf import settings

from macrosurl import url

from . import views


urlpatterns = [
    # User related urls
    url(
        r'^users/$',
        views.UserListView.as_view(),
        name='user-list'
    ),
    url(
        r'^users/create/$',
        views.UserCreateView.as_view(),
        name='user-create'
    ),
    url(
        r'^users/import/$',
        views.users_import,
        name='user-import'
    ),
    url(
        r'^users/import/:session_uuid/$',
        views.users_import,
        name='user-import'),
    url(
        r'^user/:user_uuid/$',
        views.UserUpdateView.as_view(),
        name='user-update'
    ),
    url(
        r'^user/:user_uuid/delete/$',
        views.UserDeleteView.as_view(),
        name='user-delete'
    ),
    url(
        r'^user/:user_uuid/welcome/$',
        views.UserWelcomeView.as_view(),
        name='user-welcome'
    ),
    url(
        r'^password-update/$',
        views.password_change,
        name='password_change'
    ),
    # Group related urls
    url(
        r'^groups/$',
        views.GroupListView.as_view(),
        name='group-list'
    ),
    url(
        r'^groups/create/$',
        views.GroupCreateView.as_view(),
        name='group-create'
    ),
    url(
        r'^groups/:group_uuid/update/$',
        views.GroupUpdateView.as_view(),
        name='group-update'
    ),
    url(
        r'^groups/:group_uuid/delete/$',
        views.GroupDeleteView.as_view(),
        name='group-delete'
    ),
]

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

