# -*- coding: utf-8 -*-
from django.conf.urls import url
from django.contrib.auth.decorators import login_required
from django.core.urlresolvers import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.views.generic import TemplateView
from django.contrib.auth import views as auth_views

from portal.forms import LoginForm
from portal.views import ProfileEditView, OverviewView, AnnouncementDetailView, InformationDetailView

urlpatterns = [
    url(_(r'^login/$'), auth_views.login, {'authentication_form': LoginForm}, name='login'),

    url(_(r'^logout/$'), auth_views.logout, {'next_page': reverse_lazy('portal:overview')}, name='logout'),

    url(_(r'^account/change/password/$'), auth_views.password_change, {
        'template_name': 'portal/edit_form.html',
        'post_change_redirect': reverse_lazy('portal:change_password_success')
    }, name='change_password'),

    url(_(r'^account/change/password/success/$'), login_required(TemplateView.as_view(
        template_name='portal/edit_success.html'
    ), login_url=reverse_lazy('portal:login')), name='change_password_success'),

    url(_(r'^account/edit/profile/$'), login_required(ProfileEditView.as_view(
    ), login_url=reverse_lazy('portal:login')), name='edit_profile'),

    url(_(r'^account/edit/profile/success/$'), login_required(TemplateView.as_view(
        template_name='portal/edit_success.html'
    ), login_url=reverse_lazy('portal:login')), name='edit_profile_success'),

    url(_(r'^announcement/(?P<pk>\d+)/$'),
        login_required(AnnouncementDetailView.as_view(), login_url=reverse_lazy('portal:login')), name='announcement'),

    url(_(r'^information/(?P<pk>\d+)/$'),
        login_required(InformationDetailView.as_view(), login_url=reverse_lazy('portal:login')),
        kwargs={'information': True}, name='information'),

    url(_(r'^$'), login_required(OverviewView.as_view(), login_url=reverse_lazy('portal:login')), name='overview'),
]
