from django.conf.urls import url
from django.views.generic import RedirectView
from django.contrib.auth.decorators import login_required, permission_required
import minecraft_manager.views as mcm

urlpatterns = [
    url(r'^$', RedirectView.as_view(pattern_name='overview')),

    # Dashboard
    url(r'^overview/$', login_required(mcm.Overview.as_view()), name="overview"),
    url(r'^ban/$', login_required(mcm.Ban.as_view()), name="ban"),

    # Alerts
    url(r'^alert/$', login_required(mcm.Alert.as_view()), name="alert"),
    url(r'^alert/(?P<alert_id>[0-9]{1,5})/$', login_required(mcm.AlertInfo.as_view())),

    # Applications
    url(r'^application/$', login_required(mcm.Application.as_view()), name="application"),
    url(r'^reference/$', login_required(mcm.Reference.as_view()), name="reference"),
    url(r'^application/(?P<application_id>[0-9]{1,5})/$', login_required(mcm.ApplicationInfo.as_view())),

    # Players
    url(r'^player/$', login_required(mcm.Player.as_view()), name="player"),
    url(r'^player/(?P<player_id>[0-9]{1,5})/$', login_required(mcm.PlayerInfo.as_view())),

    # Tickets
    url(r'^ticket/$', login_required(mcm.Ticket.as_view()), name="ticket"),
    url(r'^ticket/(?P<ticket_id>[0-9]{1,5})/$', login_required(mcm.TicketInfo.as_view())),

    # Notes
    url(r'^note/$', login_required(mcm.Note.as_view()), name="note"),
    url(r'^note/(?P<note_id>[0-9]{1,5})/$', login_required(mcm.NoteInfo.as_view()), name='note_info'),
    url(r'^note/add$', login_required(mcm.NoteAdd.as_view()), name="note_add"),

    # Attachments
    url(r'^attachment/(?P<attachment_id>[0-9]{1,5})/$', login_required(mcm.Attachment.as_view()), name="attachment"),
    url(r'attachment/(?P<ref_model>[A-Za-z])/(?P<ref_id>[0-9]{1,5})/$', login_required(mcm.AddAttachment.as_view()), name='attachment_add'),

    # IP
    url(r'^ip/(?P<ip_id>[0-9]{1,5})/$', login_required(mcm.IP.as_view()), name="ip"),

    # Report
    url(r'^report/$', login_required(mcm.Report.as_view()), name="report"),

    # Chat
    url(r'^chat/$', permission_required('minecraft_manager.chat')(mcm.Chat.as_view()), name="chat"),
]
