from django.urls import path, re_path
from django.conf import settings
from django.conf.urls.static import static
#from django.contrib.auth import views as auth_views

from . import views

urlpatterns = [
    #url(r'^simple.png$', views.simple),
    #url(r'^test/$', views.test, name='test'),
    path('login/', views.login_view, {'template_name':'events/registration/login.html'}, name='login'),
    path('logout/', views.logout_view, {'next_page':'/'}, name='logout'),
    path('password/', views.change_password, name='change_password'),
    re_path('event/(?P<event_name>[\w-]+)', views.show_event, name='show_event'),
    re_path('download_lc/(?P<event_name>[\w-]+)', views.download_lc, name='download_lc'),
    re_path('event_by_id/(?P<event_id>[0-9]+)', views.show_event_by_id, name='show_event_by_id'),
    re_path('download_lc_by_id/(?P<event_id>[0-9]+)', views.download_lc_by_id, name='download_lc_by_id'),
    re_path('obs_log/(?P<date>[0-9]+)', views.obs_log, name='obs_log'),
    path('obs_requests24/', views.obs_requests24, name='obs_requests24'),
    path('active_obs_requests/', views.active_obs_requests, name='active_obs_requests'),
    path('obs_monitor/', views.display_obs_monitor, name='obs_monitor'),
    re_path('obs_details/(?P<event_name>[\w-]+)', views.event_obs_details, name='event_obs_details'),
    re_path('image_search/image_name=(?P<image_name>[a-z0-9-_]+.[a-z]+)/', views.image_search, name='image_search'),
    path('query_obs_requests/', views.query_obs_requests, name='query_obs_requests'),
    re_path('query_obs_by_date/timestamp=(?P<timestamp>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})&time_expire=(?P<time_expire>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})&request_status=(?P<request_status>[A-Z][A-Z])/', views.query_obs_by_date, name='query_obs_by_date'),
    path('query_event_in_survey/', views.query_event_in_survey, name='query_event_in_survey'),
    re_path('query_event_in_survey/ra=(?P<ra>[0-9.]+)&dec=(?P<dec>[-0-9.]+)/', views.query_event_in_survey, name='query_event_in_survey'),
    path('record_obs_request/', views.record_obs_request, name='record_obs_requests'),
    re_path('record_sub_obs_request/sr_id=(?P<sr_id>[0-9]+)&grp_id=(?P<grp_id>[A-Za-z0-9]+.[0-9]+)&track_id=(?P<track_id>[0-9]+)&window_start=(?P<window_start>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})&window_end=(?P<window_end>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})&status=(?P<status>[A-Z_]+)/', views.record_sub_obs_request, name='record_sub_obs_request'),
    re_path('record_sub_obs_request/sr_id=(?P<sr_id>[0-9]+)&grp_id=(?P<grp_id>[A-Za-z0-9]+.[0-9]+)&track_id=(?P<track_id>[0-9]+)&window_start=(?P<window_start>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})&window_end=(?P<window_end>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})&status=(?P<status>[A-Z_]+)&time_executed=(?P<time_executed>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})/', views.record_sub_obs_request, name='record_sub_obs_request'),
    path('record_data_file/', views.record_data_file, name='record_data_file'),
    re_path('record_image/field_name=(?P<field_name>[A-Z0-9-]+)&image_name=(?P<image_name>[a-z0-9-_]+.[a-z]+)&date_obs=(?P<date_obs>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})&timestamp=(?P<timestamp>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})&tel=(?P<tel>[a-zA-Z0-9- ]+)&inst=(?P<inst>[a-z0-9]+)&filt=(?P<filt>[A-Za-z-]+)&grp_id=(?P<grp_id>[A-Z0-9.]+)&track_id=(?P<track_id>[0-9]+)&req_id=(?P<req_id>[0-9]+)&airmass=(?P<airmass>[0-9.0-9]+)&avg_fwhm=(?P<avg_fwhm>[0-9.0-9]+)&avg_sky=(?P<avg_sky>[0-9.0-9]+)&avg_sigsky=(?P<avg_sigsky>[0-9.0-9]+)&moon_sep=(?P<moon_sep>[0-9.0-9]+)&moon_phase=(?P<moon_phase>[0-9.0-9]+)&moon_up=(?P<moon_up>[A-Za-z]+)&elongation=(?P<elongation>[0-9.0-9]+)&nstars=(?P<nstars>[0-9]+)&ztemp=(?P<ztemp>[-0-9.0-9]+)&shift_x=(?P<shift_x>[-0-9]+)&shift_y=(?P<shift_y>[-0-9]+)&quality=(?P<quality>[A-Za-z !;]+)/', views.record_image, name='record_image'),
    path('add_operator/', views.add_operator, name='add_operator'),
    path('add_telescope/', views.add_telescope, name='add_telescope'),
    path('add_event/', views.add_event, name='add_event'),
    path('add_eventname/', views.add_eventname, name='add_eventname'),
    path('add_singlemodel/', views.add_singlemodel, name='add_singlemodel'),
    path('add_binarymodel/', views.add_binarymodel, name='add_binarymodel'),
    path('add_eventreduction/', views.add_eventreduction, name='add_eventreduction'),
    path('add_tap/', views.add_tap, name='add_tap'),
    path('add_taplima/', views.add_taplima, name='add_taplima'),
    path('add_datafile/', views.add_datafile, name='add_datafile'),
    path('add_image/', views.add_image, name='add_image'),
    path('tap/', views.tap, name='tap'),
    path('set_tap_status/', views.set_tap_status, name='set_tap_status'),
    path('set_event_status/', views.set_event_status, name='set_event_status'),
#    url(r'^set_event_status_api/event_name=(?P<event_name>[A-Za-z0-9-]+)&status=(?P<status>[A-Z]+)/$', views.set_event_status_api, name='set_event_status_api'),
    path('request_obs/', views.request_obs, name='request_obs'),
    re_path('list_year/(?P<year>[0-9]+)', views.list_year, name='list_year'),
    path('list_anomalies/', views.list_anomalies, name='list_anomalies'),
    path('list_all/', views.list_all, name='list_all'),
    re_path('list_all/(?P<display_year>[A-Za-z0-9]+)/', views.list_all, name='list_all'),
    path('display_fields/', views.display_fields, name='display_fields'),
    path('search_events/', views.search_events, {'search_type':'name'}, name='search_events'),
    path('search_events/search_event_name/', views.search_events, {'search_type':'name'}, name='search_event_name'),
    path('search_events/search_event_position/', views.search_events, {'search_type':'position'}, name='search_event_position'),
    path('search_events/search_event_params/', views.search_events, {'search_type':'params'}, name='search_event_params'),
    path('trigger_rea_hi_obs/', views.trigger_rea_hi_obs, name='trigger_rea_hi_obs'),
    path('', views.dashboard, name='dashboard'),
    path('quality_control/', views.data_quality_control, name='data_quality_control'),
    path('test_token/',views.test_token, name='test_token'),
]
