#-*- coding:utf-8 -*-

from django.conf import settings
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template

from common.util import url 

from semantics.sem_urls import SEMANTIC_PATTERNS

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
  url(r'^accounts/settings/$', 'accounts.views.settings', name='settings'),
  (r'^accounts/', include('registration.urls')),
  url(r'^ajax/sort_rules/$', 'dictionary.ajax_jqgrid.sort_rules',
      name='sort_rules'),
      
  # downloadowanie slownikow
  (r'^slowniki/(.+)/$', 'dictionary.ajax_vocabulary_management.download_vocabulary'),
  
  # downloadowanie realizacji argumentow
  (r'^rozwiniecia_typow_fraz/(.+)/$', 'dictionary.ajax_argument_realizations.download_realizations'),
  
  (r'^robots\.txt$', direct_to_template, {'template': 'robots.txt', 'mimetype': 'text/plain'}),

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

  # Uncomment the next line to enable the admin:
  (r'^admin/', include(admin.site.urls)),

  url(r'^%s(?P<path>.*)$' % settings.MEDIA_URL.lstrip('/'),
      'django.views.static.serve',
      kwargs={'document_root': settings.MEDIA_ROOT}),
)

urlpatterns += patterns('dictionary.ajax_lemma_view',
                        
# lemma view
  url(r'^ajax/lemmas/$', 'get_lemmas'),
  url(r'^ajax/old_frames/$', 'get_old_frames'),
  url(r'^ajax/new_frames/$', 'get_new_frames'),
  
  url(r'^ajax/change_ctrl/$', 'get_change_ctrl'),
  url(r'^ajax/lemma_examples/$', 'get_lemma_examples'),
  url(r'^ajax/lemma_notes/$', 'get_lemma_notes'), 
  url(r'^ajax/lemma_preview/$', 'get_lemma_preview'),
  url(r'^ajax/get_frame_filter_options/$', 'get_frame_filter_options'),
  url(r'^ajax/get_lemma_desc/$', 'get_lemma_desc'),
  url(r'^ajax/lemma_notes_form_submit/$', 'lemma_notes_form_submit'),
  url(r'^ajax/send_miss_frames_msg/$', 'send_miss_frames_msg'),
  url(r'^ajax/position_form/$', 'position_form'),
  
  url(r'^ajax/create_position_form/$', 'create_position_form'),
  
  url(r'^ajax/save_new_frames/$', 'save_new_frames'),
  url(r'^ajax/restore_lemma/$', 'restore_lemma'),
  url(r'^ajax/position_lookup/$', 'position_lookup'),
  url(r'^ajax/argument_lookup/$', 'argument_lookup'),
  url(r'^ajax/get_ctrl_preview/$', 'get_ctrl_preview'),
  url(r'^ajax/add_position/$', 'add_position'),
  url(r'^ajax/create_position_form_submit/$', 'create_position_form_submit'),
  url(r'^ajax/frame_form/$', 'frame_form'),
  url(r'^ajax/aspect_rel_missing_frames/$', 'aspect_rel_missing_frames'),
  url(r'^ajax/add_new_frames/$', 'add_new_frames'),
  url(r'^ajax/show_skladnica_examples/$', 'show_skladnica_examples'),
  url(r'^ajax/show_frame_realizations/$', 'show_frame_realizations'),
  url(r'^ajax/frame_form_submit/$', 'frame_form_submit'),
  url(r'^ajax/pos_cat_form/$', 'pos_cat_form'),
  url(r'^ajax/can_add_position_category/$', 'can_add_position_category'),
  url(r'^ajax/pos_cat_form_submit/$', 'pos_cat_form_submit'),
  url(r'^ajax/skladnica_example_propositions/$', 'skladnica_example_propositions'),  
  url(r'^ajax/xcp_example_propositions/$', 'xcp_example_propositions'),
  url(r'^ajax/get_skladnica_example/$', 'get_skladnica_example'),  
  url(r'^ajax/get_xcp_example/$', 'get_xcp_example'),
  url(r'^ajax/get_frame_chars/$', 'get_frame_chars'), 
  url(r'^ajax/example_opinion_form/$', 'example_opinion_form'),
  url(r'^ajax/example_opinion_form_submit/$', 'example_opinion_form_submit'), 
  url(r'^ajax/nkjp_example_form_submit/$', 'nkjp_example_form_submit'),
  url(r'^ajax/semantic_example_form_submit/$', 'semantic_example_form_submit'),
  url(r'^ajax/remove_example_from_lemma/$', 'remove_example_from_lemma'),
  url(r'^ajax/can_confirm_example/$', 'can_confirm_example'),
  url(r'^ajax/confirm_nkjp_example/$', 'confirm_nkjp_example'),
  url(r'^ajax/location/$', 'get_location'),  
  url(r'^ajax/remove_lemma_note/$', 'remove_lemma_note'),
  url(r'^ajax/lemma_note_form/$', 'lemma_note_form'),
  url(r'^ajax/get_lemma_note/$', 'get_lemma_note'),
  url(r'^ajax/lemma_notes_modify/$', 'lemma_notes_modify'),
  url(r'^ajax/frame_conversion_form/$', 'frame_conversion_form'),
  url(r'^ajax/frame_conversion_form_submit/$', 'frame_conversion_form_submit'),
  url(r'^ajax/need_conversion/$', 'need_conversion'),
  url(r'^ajax/get_compatible_schema_chars/$', 'get_compatible_schema_chars'),
  
  url(r'^ajax/get_actual_lemma_id/$', 'get_actual_lemma_id'),
  url(r'^ajax/user_is_authenticated/$', 'user_is_authenticated'),
  
  url(r'^ajax/deselect_preview_tab/$', 'deselect_preview_tab'),
  url(r'^ajax/get_schemata/$', 'get_schemata'),
  url(r'^ajax/get_examples/$', 'get_examples'),
  url(r'^ajax/get_schemata_and_examples/$', 'get_schemata_and_examples'),
  
 # powiazywanie hasel (nieczasownikowe)
  url(r'^ajax/relate_entries/$', 'relate_entries'),
  url(r'^ajax/disrelate_entries/$', 'disrelate_entries'),
  url(r'^ajax/are_new_preview_entries_related/$', 'are_new_preview_entries_related'),
  
  # sortowanie, filtrowanie, ukrywanie kolumn tabeli
  url(r'^ajax/sort_form/$', 'sort_form'),
  url(r'^ajax/filter_form/$', 'filter_form'),
  url(r'^ajax/sort_form_submit/$', 'sort_form_submit'),
  url(r'^ajax/filter_form_submit/$', 'filter_form_submit'),
  url(r'^ajax/sort_column/$', 'sort_column'),
  url(r'^ajax/save_columns/$', 'save_columns'),
  url(r'^ajax/get_sort_order/$', 'get_sort_order'),
  
  # czasowniki podobne
  url(r'^ajax/similar_lemmas_old_form_submit/$', 'similar_lemmas_old_form_submit'),
  url(r'^ajax/similar_lemmas_new_form_submit/$', 'similar_lemmas_new_form_submit'),
  url(r'^ajax/similar_lemmas_show_synonyms/$', 'similar_lemmas_show_synonyms'),
  url(r'^ajax/related_lemmas_show/$', 'related_lemmas_show'),
  url(r'^ajax/similar_lemmas_reset/$', 'similar_lemmas_reset'),
  
  url(r'^ajax/preview_select/$', 'preview_select'),
  #walidacja
  url(r'^ajax/validate_new_frames/$', 'validate_new_frames'),
  # modyfikacja przykladow nkjp
  url(r'^ajax/get_nkjp_dict_ids/$', 'get_nkjp_dict_ids'),
  
# user notes
  url(r'^ajax/note_session_get/$', 'note_session_get'),
  
# zarzadzanie kontami
  url(r'^ajax/new_account_form_submit/$', 'new_account_form_submit'),
  url(r'^ajax/change_user_fun_form/$', 'change_user_fun_form'),
  url(r'^ajax/change_user_fun_form_submit/$', 'change_user_fun_form_submit'),
  url(r'^ajax/delete_user/$', 'delete_user'),
  
# uprawnienia
  url(r'^ajax/user_has_perm/$', 'user_has_perm'),
  
 # frazeologia
  url(r'^ajax/phraseologic_propositions_exists/$', 'phraseologic_propositions_exists'),
  #url(r'^ajax/has_lexicalized_args/$', 'has_lexicalized_args'),
  url(r'^ajax/arg_can_be_lexicalized/$', 'arg_can_be_lexicalized'),
  url(r'^ajax/assign_phraseologic_frame_form/$', 'assign_phraseologic_frame_form'),
  url(r'^ajax/assign_phraseologic_frame/$', 'assign_phraseologic_frame'),
  url(r'^ajax/entry_lookup/$', 'entry_lookup'),
  
 # inne
  url(r'^ajax/get_arg_id/$', 'get_arg_id'),
)

urlpatterns += patterns('dictionary.ajax_argument_form',
  url(r'^ajax/argument_form/$', 'argument_form'),
  url(r'^ajax/argument_form_submit/$', 'argument_form_submit'),
)

urlpatterns += patterns('dictionary.ajax_lemma_status',
  url(r'^ajax/lemma_status/$', 'get_lemma_status'),
  url(r'^ajax/status_need_validation/$', 'status_need_validation'),
  url(r'^ajax/lemma_status_change/$', 'lemma_status_change'),
)

urlpatterns += patterns('dictionary.ajax_argument_realizations',
  url(r'^ajax/realization_arg_form/$', 'realization_arg_form'),
  url(r'^ajax/show_realizations/$', 'show_realizations'),
  url(r'^ajax/remove_realization/$', 'remove_realization'),
  url(r'^ajax/add_arg_realization/$', 'add_arg_realization'),
  url(r'^ajax/add_positions_extension/$', 'add_positions_extension'),
  url(r'^ajax/create_realizations/$', 'create_realizations'),
  url(r'^ajax/positions_extension_form/$', 'positions_extension_form'),
)

urlpatterns += patterns('dictionary.ajax_argument_stats',
  url(r'^ajax/gen_list/$', 'gen_list'),   
  url(r'^ajax/prepare_graph_data/$', 'prepare_graph_data'),                                        
)

# statystyki uzytkownikow
urlpatterns += patterns('dictionary.ajax_user_stats',
  url(r'^ajax/get_user_stats/$', 'get_user_stats'),                                       
)

urlpatterns += patterns('dictionary.views',
  url(r'^$', 'lemma_view'),
  url(r'^notatki/$', 'user_notes'),  
  url(r'^slowniki/$', 'manage_vocabulary'),
  url(r'^statystyki/$', 'user_statistics'),
  url(r'^wszystkie_statystyki/$', 'all_statistics'),
  url(r'^zarzadzanie_kontami/$', 'manage_users'),
  url(r'^rozwiniecia_typow_fraz/$', 'manage_arg_realizations'),
  url(r'^pobieranie_slownika/(?P<format>.+)/$', 'download_dict'),
)

# notatki
urlpatterns += patterns('dictionary.ajax_user_notes',
  url(r'^ajax/get_note_text/$', 'get_note_text'),
  url(r'^ajax/remove_note/$', 'remove_note'),
  url(r'^ajax/get_lemma_from_note/$', 'get_lemma_from_note'),
  url(r'^ajax/note_session_clear/$', 'note_session_clear'),  
  url(r'^ajax/notes_page/$', 'notes_page'),                                 
)

# slowniki
urlpatterns += patterns('dictionary.ajax_vocabulary_management',
  url(r'^ajax/create_vocabulary/$', 'create_vocabulary'),
  url(r'^ajax/vocab_perm_manage_form/$', 'vocab_perm_manage_form'),  
  url(r'^ajax/vocab_perm_manage_form_submit/$', 'vocab_perm_manage_form_submit'),    
  url(r'^ajax/get_vocabulary_stats/$', 'get_vocabulary_stats'),
  url(r'^ajax/get_other_stats/$', 'get_other_stats'),                  
)

urlpatterns += SEMANTIC_PATTERNS
