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

from django.conf.urls import patterns, include, url
from django.conf import settings
from django.contrib.auth import views as auth_views
from registration.views import register
from app import views as app
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
	# Administrador 
    url(r'^admin/', include(admin.site.urls)),

    # Media 
    (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),

   # Registration
    url(r'^login/$', auth_views.login, {'template_name': 'registration/login.html'}, name='auth_login'),
    url(r'^accounts/login/$', auth_views.login, {'template_name': 'registration/login.html'}, name='auth_login'),

    url(r'^logout/$', auth_views.logout, {'template_name': 'registration/logout.html', 'next_page': '/'}, name='auth_logout'),
    url(r'^password/change/$', auth_views.password_change, {'template_name': 'registration/password_change.html'},name='auth_change_password'),
    url(r'^password/done/$', auth_views.password_change_done, {'template_name': 'registration/password_change_done.html'},name='auth_password_change_done'),

    # url(r'^signup/$', register, {'backend': 'registration.backends.simple.SimpleBackend'}, name='registration_register'),

    url(r'^perfil/$',app.perfil, name="perfil"),

    # Asignaturas
    #(r'', include('main.urls')),
    url(r'^(?P<slug>[-\w]+)/$',app.ver_asignatura , name="ver_asignatura"),
    url(r'^(?P<slug>[-\w]+)/add/alumno/$',app.aniadir_alumno_asignatura , name="aniadir_alumno_asignatura"),
    url(r'^(?P<slug>[-\w]+)/add/alumnos/$',app.aniadir_alumnos_asignatura , name="aniadir_alumnos_asignatura"),
    url(r'^(?P<slug>[-\w]+)/actividad/(?P<actividad>[-\d]+)$','tarea.views.ver_actividades_alumnos' , name="ver_actividades_alumnos"),
    url(r'^(?P<slug>[-\w]+)/evaluacion/(?P<actividad>[-\d]+)$','cuestionario.views.ver_evaluaciones_alumnos' , name="ver_evaluaciones_alumnos"),
    url(r'^(?P<slug>[-\w]+)/eliminar/todos$',app.eliminar_alumnos_asignatura , name="eliminar_alumnos_asignatura"),
    url(r'^(?P<slug>[-\w]+)/eliminar/(?P<alumno>[-\w]+)$',app.eliminar_alumno_asignatura , name="eliminar_alumno_asignatura"),
    
    # Indice
    url(r'^$', app.ver_indice, name="indice"),

    # Cuestionarios
    url(r'^(?P<slug>[-\w]+)/cuestionarios/', include('cuestionario.urls')),

    # Tareas
    url(r'^(?P<slug>[-\w]+)/tareas/', include('tarea.urls')),

    # FormWizard
    url(r'^(?P<slug>[-\w]+)/perfil$', app.perfil, name="ver_perfil"),
    url(r'^(?P<slug>[-\w]+)/alumno/(?P<alumno>[-\w]+)/$', app.ver_alumno_asignatura, name="ver_alumno_asignatura"),

    url(r'^', include('formwizard.urls')),

)

urlpatterns += patterns('',
    url(r'^%s/(?P<path>.*)$' % settings.MEDIA_URL[1:-1], 
            'django.views.static.serve',
            {'document_root': settings.MEDIA_ROOT}),)
