from django.conf.urls import patterns, include, url
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.views.generic import TemplateView
from django.views.i18n import set_language

from core.views import HomepageView, AboutView
from core.ajax_views import generic_quick_search, SearchResultView

urlpatterns = patterns('',

                       url(regex=r'^$',
                           view=HomepageView.as_view(),
                           name='homepage'),

                       url(r'^clients/',
                           include('clients.urls')),
                       url(r'^panelists/',
                           include('panelists.urls')),
                       url(r'^referencegas/',
                           include('referencegases.urls')),
                       url(r'^history/',
                           include('history.urls')),
                       url(r'^bag/',
                           include('bags.urls')),
                       url(r'^projects/',
                           include('projects.urls')),
                       url(r'^samples/',
                           include('samples.urls')),
                       url(r'^users/',
                           include('users.urls')),

                       url(r'^measurement/',
                           include('measurements.urls')),

                       url(r'^devices/',
                           include('devices.urls')),

                       url(r'^rst/',
                           include('rest.urls')),

                       url(r'^templates/',
                           include('report_template.urls')),

                       # url(r'^performance/',
                       #     include('panelhistory.urls')),

                       url(regex=r'^generic_search_ajax/$',
                           view=generic_quick_search,
                           name='generic search ajax'),
                       url(regex=r'^search_results/$',
                           view=SearchResultView.as_view(),
                           name='search_results'),

                       url(regex=r'^about/',
                           view=AboutView.as_view(),
                           name='about_page'),

                       url(regex=r'^broken/$',
                           view=TemplateView.as_view(template_name='error_page.html'),
                           name='error_page'),

                       url(regex=r'^lang/$',
                           view=set_language,
                           name='set_language'),
)

# handler500 = TemplateView.as_view(template_name='error_page.html')
urlpatterns += staticfiles_urlpatterns()

from django.conf import settings
from django.conf.urls.static import static

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)