from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.contrib.auth import urls as auth_url, views as auth_views
from django.contrib.admin.views.decorators import staff_member_required
from .views import AddOrUpdateFolder, Folders, SearchDatasheet, DeleteFolder


urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'hdabo.views.home', name='home'),
    # url(r'^hdabo/', include('hdabo.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^accounts/', include(auth_url)),
    url(r'^accounts/password/reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$', auth_views.password_reset_confirm, name='auth_password_reset_confirm'),
    url(r'^accounts/', include('registration.backends.default.urls')),
    url(r'^logout/', 'django.contrib.auth.views.logout_then_login'),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^search/', include('haystack.urls')),
    url(r'^$', 'hdabo.views.home', name='hdabo_home'),
    url(r'^list/$', 'hdabo.views.orga_list', name='orga_list'),
    url(r'^list/(?P<orga_id>[\w-]+)$', 'hdabo.views.list_for_orga', name='list_for_orga'),
    url(r'^list/(?P<orga_id>[\w-]+)/(?P<valid>[\w-]+)/$', 'hdabo.views.list_for_orga', name='list_for_orga'),
    url(r'^list/(?P<orga_id>[\w-]+)/(?P<valid>[\w-]+)/(?P<start_index>[\w-]+)/$', 'hdabo.views.list_for_orga', name='list_for_orga'),
    url(r'^list/(?P<orga_id>[\w-]+)/(?P<valid>[\w-]+)/(?P<start_index>[\w-]+)/(?P<length>[\w-]+)/$', 'hdabo.views.list_for_orga', name='list_for_orga'),
    url(r'^data$', 'hdabo.views.display_datasheet', name='display_datasheet'),
    url(r'^data/(?P<ds_id>[\w-]+)$', 'hdabo.views.display_datasheet', name='display_datasheet'),
    url(r'^tagupdown$', 'hdabo.views.tag_up_down'),
    url(r'^removetagfromlist$', 'hdabo.views.remove_tag_from_list'),
    url(r'^modifytag$', 'hdabo.views.modify_tag'),
    url(r'^modifytagds$', 'hdabo.views.modify_tag_datasheet'),
    url(r'^resetwpinfo$', 'hdabo.views.reset_wikipedia_info'),
    url(r'^addtag$', 'hdabo.views.add_tag'),
    url(r'^removewplink$', 'hdabo.views.remove_wp_link'),
    url(r'^alltags/?$', 'hdabo.views.all_tags'),
    url(r'^alltags/(?P<num_page>[\w-]+)/?$', 'hdabo.views.all_tags'),
    url(r'^alltags/(?P<num_page>[\w-]+)/(?P<nb_by_page>[\w-]+)/?$', 'hdabo.views.all_tags'),
    url(r'^alltags/(?P<num_page>[\w-]+)/(?P<nb_by_page>[\w-]+)/(?P<sort>[+-][\w]+)/?$', 'hdabo.views.all_tags'),
    url(r'^alltags/(?P<num_page>[\w-]+)/(?P<nb_by_page>[\w-]+)/(?P<sort>[+-][\w]+)/(?P<searched>.*)/?$', 'hdabo.views.all_tags'),
    url(r'^validatedatasheet$', 'hdabo.views.validate_datasheet'),
    url(r'^validatedatasheet/(?P<ds_id>[\w-]+)$', 'hdabo.views.validate_datasheet'),
    url(r'^validatedatasheet/(?P<ds_id>[\w-]+)/(?P<valid>[\w-]+)/$', 'hdabo.views.validate_datasheet'),
    url(r'^updatetagalias$', 'hdabo.views.update_tag_alias'),
    url(r'^updatetagcategory$', 'hdabo.views.update_tag_category'),
    url(r'^ordertagsdatasheet$', 'hdabo.views.reorder_tag_datasheet'),
    url(r'^folders/$', staff_member_required(Folders.as_view()), name='folders'),
    url(r'^folder/$', staff_member_required(AddOrUpdateFolder.as_view()), name='add_or_update_folder'),
    url(r'^folder/(?P<folder_pk>[\w-]+)$', staff_member_required(AddOrUpdateFolder.as_view()), name='add_or_update_folder'),
    url(r'^searchajax/$', SearchDatasheet(), name='searchajax'),
    url(r'^deletefolder/(?P<folder_pk>[\w-]+)$', staff_member_required(DeleteFolder.as_view()), name='delete_folder'),
)
