from django.conf.urls.defaults import *
import settings
import os
from os.path import join
from django.views.generic.simple import direct_to_template
# from django.auth.views import login, logout, register,
from itfprofiles.forms import ItfRegistrationForm

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

#from api import actions
#actions.autodiscover()

urlpatterns = patterns('',
    # Example:
    # (r'^bhangar/', include('bhangar.foo.urls')),
    #(r'^search/', include('solango.urls')),
    (r'^$', "frontpage.views.index"),
#    (r'^t/$', "frontpage.views.index"),
    (r'm/', include('insidepages.urls')),
    (r'^page/(?P<slug>[a-zA-Z].*?)/', 'pages.views.render_page'),
    (r'^contact/$', 'frontpage.views.contact'), 
    (r'^emailer/issue/(?P<issue_no>\d+)/$', 'emailer.views.show_emailer'),
    # ('m/(?P<module_slug>.*)', 'insidepages.views.main'),
    (r'^comments/', include('django.contrib.comments.urls')),
#    (r'^ckeditor/', include('ckeditor.urls')),
    (r'^robots.txt$', direct_to_template, {'template': 'robots.txt', 'mimetype': 'text/plain'}),
#    (r'^erang/', include('erang_organised.urls')),
#    (r'api/', 'api.views.api'),
#    (r'jsdoc/', 'api.views.jsdoc'),
#    (r'site.json', 'app.views.site_json'),
    (r'^itf/(?P<old_url>.*)', 'festival.views.redirect'),
#    (r'^accounts/register/', 'registration.views.register', {'form_class': ItfRegistrationForm }),
    # registration accounts disabled for allauth
    #(r'^accounts/', include('registration.urls')),
    (r'^accounts/', include('allauth.urls')),                       
    (r'^admin/', include(admin.site.urls)),
#    ('^getLanguages', 'itfcore.views.getLanguages'),
    # Uncomment the admin/doc line below and add 'django.contrib.admindocs' 
    # to INSTALLED_APPS to enable admin documentation:
    #Test views:
    (r'test_profile', 'itfprofiles.views.person_form'),
    (r'edit_profile', 'itfprofiles.views.edit_profile'),
    (r'^autocomplete/(?P<ctype_id>\d+)', 'app.views.autocomplete'),
    (r'^popup_form/(?P<ctype_id>\d+)', 'app.views.popup_form'),
#    (r'^autocompletes/itfprofiles/$', 'itfprofiles.views.autocomplete'),
    (r'^popup/person', 'itfprofiles.views.personpopup'),    (r'^popup/theatregroup', 'itfprofiles.views.grouppopup'),
#    (r'i/', include('itfcore.urls')),
    (r'^admin/doc/', include('django.contrib.admindocs.urls')),
    (r'^search/', include('haystack.urls')),    
    (r'^markitup/', include('markitup.urls')),
    (r'googlehostedservice.html', 'itfcore.views.googlehosted'),
   
    (r'emailsignuplist', 'festival.views.email_signups'),
    (r'^favicon.ico$', 'django.views.generic.simple.redirect_to', {'url': '/static/images/favicon.ico'}),

#    (r'^ajax_filtered_fields/', include('ajax_filtered_fields.urls')),
    # Uncomment the next line to enable the admin:
#    (r'^test$', 'app.views.index'),  
#    (r'^$', 'festival.views.home')
)

if settings.LOCAL_DEVELOPMENT:
#
  urlpatterns += patterns('',
#
  (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': join(settings.PROJECT_ROOT, "static")}),
#
)
#

