from django.conf.urls.defaults import *
from django.contrib.auth.decorators import login_required
import settings
import authentic2.idp.views

urlpatterns = patterns('',
    (r'^', include('authentic2.auth2_auth.urls')),
    url(r'^logout$', 'authentic2.idp.views.logout', name='auth_logout'),
    (r'^idp/', include('authentic2.idp.urls')),
    (r'^users-admin/', include('users_admin.urls')),
    (r'^$', login_required(authentic2.idp.views.homepage), {}, 'index'),
)

if settings.STATIC_SERVE:
    urlpatterns += patterns('',
        url(
            regex = r'^media/(?P<path>.*)$',
            view = 'django.views.static.serve',
            kwargs = {'document_root': settings.MEDIA_ROOT}),
    )

if settings.DEBUG:
    from django.contrib import admin
    admin.autodiscover()
    urlpatterns += patterns('',
        (r'^admin/', include(admin.site.urls)),
    )

# fallback : go to index page
#urlpatterns += patterns('',
#    url(
#        regex = r'^.*$',
#        view = 'django.views.generic.simple.redirect_to',
#        kwargs = {'url': '/'})
#    )

