"""rowsandall_app URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.9/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  re_path(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  re_path(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  re_path(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url,include
from django.urls import path, re_path
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.views.generic import TemplateView
from rowsandall_app.views import rootview, landingview
from django.contrib.auth import views as auth_views
from rowers import views as rowersviews
from survey import views as surveyviews

import django


import django.views.i18n


urlpatterns = [
    re_path('^', include('django.contrib.auth.urls')),
    re_path(r'^password_change_done/$',auth_views.PasswordChangeDoneView.as_view(),name='password_change_done'),
    re_path(r'^password_change/$',auth_views.PasswordChangeView.as_view(),name='password_change'),
    re_path(r'^password_reset/$',
        auth_views.PasswordResetView.as_view(),
        {'template_name': 'rowers/templates/registration/password_reset.html'},
        name='password_reset'),
    re_path(r'^password_reset/done/$',
        auth_views.PasswordResetDoneView.as_view(),
        name='password_reset_done'),
    re_path(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$',
        auth_views.PasswordResetConfirmView.as_view(),
        name='password_reset_confirm'),
    re_path(r'^reset/done/$',
        auth_views.PasswordResetCompleteView.as_view(),
        name='password_reset_complete'),
    ]

urlpatterns += [
    re_path(r'^robots\.txt$', TemplateView.as_view(template_name='robots.txt',
                                               content_type='text/plain')),
    re_path(r'^admin/', admin.site.urls),
    re_path(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework2')),
    re_path(r'^$',landingview),
    re_path(r'^landing/$',landingview),
    re_path(r'^getblogs/$',rowersviews.get_blog_posts),
    re_path(r'^login/',
#            auth_views.LoginView,
            auth_views.LoginView.as_view(),
            name='login'),
    re_path(r'^logout/$',
        auth_views.LogoutView.as_view(),
        {'next_page': '/'},
        name='logout',),
    re_path(r'^rowers/',include('rowers.urls')),
#    re_path(r'^survey/',include('survey.urls')),
#    re_path(r'^cvkbrno/',include('cvkbrno.urls')),
#    re_path(r'^admin/rq/',include('django_rq_dashboard.urls')),
    re_path(r'^call\_back',rowersviews.rower_process_callback),
    re_path(r'^stravacall\_back',rowersviews.rower_process_stravacallback),
    re_path(r'^sporttracks\_callback',rowersviews.rower_process_sporttrackscallback),
    re_path(r'^underarmour\_callback',rowersviews.rower_process_underarmourcallback),
    re_path(r'^polarflowcallback',rowersviews.rower_process_polarcallback),
    re_path(r'^runkeeper\_callback',rowersviews.rower_process_runkeepercallback),
    re_path(r'^tp\_callback',rowersviews.rower_process_tpcallback),
    re_path(r'^twitter\_callback',rowersviews.rower_process_twittercallback),
    re_path(r'^i18n/', include('django.conf.urls.i18n')),
    re_path(r'^tz_detect/', include('tz_detect.urls')),
    path('django-rq/', include('django_rq.urls')),
#    path('500/', rowersviews.error500_view),
#    re_path(r'^jsi18n/', django.views.i18n.javascript_catalog,name='jsi18n'),
    ]

js_info_dict = {
    'packages': ('recurrence', ),
}

# jsi18n can be anything you like here
urlpatterns += [
    path('jsi18n/', django.views.i18n.JavaScriptCatalog.as_view(), name="javascript-catalog"),
]
# monkey patch workaround for bug in recurrence library
django.views.i18n.javascript_catalog = None

if settings.DEBUG:
    import debug_toolbar
    import django
    urlpatterns += [
        re_path(r'^static/plots/(?P<path>.*)$',
                django.views.static.serve,
                kwargs={'document_root': settings.STATIC_ROOT+'plots/'})
    ]
    urlpatterns += [
#        re_path(r'^__debug__/','debug_toolbar.urls'),
        re_path(r'^static/(?P<path>.*)$',
            django.views.static.serve,
            kwargs={'document_root': settings.STATIC_ROOT,
                    'show_indexes': True}
        )
    ]
