from django.shortcuts import render
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView, DeleteView
from django.urls import reverse_lazy

from django.contrib.auth.views import LoginView

from .models import Task

# Create your views here.

class CustomLoginView(LoginView):
    template_name='base/login.html'
    fiels='__all__'
    redirect_auhenticated_user = True

    def get_success_url(self):
        return reverse_lazy('tasks')

class TaskList(ListView):
    model = Task
    context_object_name = 'tasks'

class TaskDetail(DetailView):
    model = Task
    context_object_name = 'task'

class TaskCreate(CreateView):
    model = Task
    fields = '__all__'
    success_url = reverse_lazy('tasks')

class TaskUpdate(UpdateView):
    model = Task
    fields = '__all__'
    success_url = reverse_lazy('tasks')

class TaskDelete(DeleteView):
    model = Task
    context_object_name='Task'
    success_url = reverse_lazy('tasks')


[(32, 'django.urls.reverse_lazy', 'reverse_lazy', False, 'from django.urls import reverse_lazy\n'), (37, 'django.urls.reverse_lazy', 'reverse_lazy', False, 'from django.urls import reverse_lazy\n'), (42, 'django.urls.reverse_lazy', 'reverse_lazy', False, 'from django.urls import reverse_lazy\n'), (19, 'django.urls.reverse_lazy', 'reverse_lazy', False, 'from django.urls import reverse_lazy\n')]