"""sikweb 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:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Add an import:  from blog import urls as blog_urls
    2. Import the include() function: from django.conf.urls import url, include
    3. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import url
from django.contrib import admin
from django.views.generic.base import RedirectView
from django.conf.urls import include
from django.conf.urls.static import static
from django.conf import settings
from django.contrib.staticfiles import views as static_views

# main
from webapp.views import main_index
from webapp.views import admin_index
# login
from webapp.views import login_view
from webapp.views import logout_view
# members
from members.views import member_list
from members.views import add_member
from members.views import add_many_members
from members.views import edit_member
from members.views import members as mems
from members.views import member as mem
from members.views import handle_mem_request
from members.views import csv_import as mem_csv_import
from members.views import new_member_request
from members.views import member_requests
from members.views import export_csv as mem_csv_export
from members.views import tommy_blooper
#infoscreen
from infoscreen.views import index as infoindex
from infoscreen.views import default as infodefault
from infoscreen.views import rotation
from infoscreen.views import rotations
from infoscreen.views import info_items
from infoscreen.views import info_types
from infoscreen.views import delete_info_item
from infoscreen.views import createInstance as createInfoInstance
from infoscreen.views import deleteInstance as deleteInfoInstance
from infoscreen.views import createExternalImageInfoItem
from infoscreen.views import create_image_item
from infoscreen.views import createABBItem
from infoscreen.views import createSossoItem
from infoscreen.views import createHslItem
from infoscreen.views import createCoffeeItem
from infoscreen.views import create_rotation
from infoscreen.views import delete_rotation
from infoscreen.views import CurrentHSLView
from infoscreen.views import admin as infoscreen_admin
from infoscreen.views import hsl_timetable_settings
#application
from members.views import application_index
from members.views import list_applications
from members.views import edit_application
from members.views import application_success_index

favicon_view = RedirectView.as_view(url='static/img/favicon.ico', permanent=True)

urlpatterns = [
        # main
        url(r'^$', main_index),
        url(r'^sikadmin$', admin_index),
        # admin
        url(r'^admin/', admin.site.urls),
        # login stuff
        url(r'^login$', login_view),
        url(r'^logout$', logout_view),
        # members
        url(r'^members/$', member_list),
        url(r'^members/list$', member_list),
        url(r'^members/add$', add_member),
        url(r'^members/add_many$', add_many_members),
        url(r'^members/edit/(?P<index>\d+)$', edit_member),
        url(r'^members/applications$', list_applications),
        url(r'^members/edit_application/(?P<index>\d+)$', edit_application),
        url(r'^members/api/members$', mems),
        url(r'^members/api/member/(?P<idx>\d+)$', mem),
        url(r'^members/api/member/$', mem),
        url(r'^members/api/csvimport$', mem_csv_import),
        url(r'^members/api/requests$', member_requests),
        url(r'^members/api/request$', new_member_request),
        url(r'^members/api/request/(?P<idx>\d+)$', handle_mem_request),
        url(r'^members/api/getCSV$', mem_csv_export),
        url(r'^members/tommy$', tommy_blooper),
        #infoscreen
        url(r'^infoscreen/$', infodefault),
        url(r'^infoscreen/(?P<idx>\d+)$', infoindex),
        url(r'^infoscreen/items$', info_items),
        url(r'^infoscreen/rotation/(?P<idx>\d+)$', rotation),
        url(r'^infoscreen/rotations$', rotations),
        url(r'^infoscreen/instance$', createInfoInstance),
        url(r'^infoscreen/instance/(?P<idx>\d+)$', deleteInfoInstance),
        url(r'^infoscreen/types$', info_types),
        url(r'^infoscreen/delete_item/(?P<type_id>\d+)/(?P<idx>\d+)$', delete_info_item),
        url(r'^infoscreen/create_external_image$', createExternalImageInfoItem),
        url(r'^infoscreen/create_image$', create_image_item),
        url(r'^infoscreen/create_abbitem$', createABBItem),
        url(r'^infoscreen/create_sossoitem$', createSossoItem),
        url(r'^infoscreen/create_hslitem$', createHslItem),
        url(r'^infoscreen/create_coffeeitem$', createCoffeeItem),
        url(r'^infoscreen/admin$', infoscreen_admin),
        url(r'^infoscreen/create_rotation$', create_rotation),
        url(r'^infoscreen/delete_rotation/(?P<id>\d+)$', delete_rotation),
        url(r'^infoscreen/hsl_data$', CurrentHSLView),
        url(r'^infoscreen/hsl_data/settings$', hsl_timetable_settings),
        #application
        url(r'^application/$', application_index),
        url(r'^application/success$', application_success_index),
        url(r'^favicon\.ico$', favicon_view),

        # i18n default view for changing the active language
        url(r'^i18n/', include('django.conf.urls.i18n')),

        # staticfiles default view for static files in development
        url(r'^static/(?P<path>.*)$', static_views.serve),
        url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),


] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
