Commit 1d482920 authored by Борис Ким's avatar Борис Ким

Добавил во все вьюхи Login mixin для аутентифициорованных пользователей

parent f217ed60
from django.conf import settings
from django.shortcuts import redirect
from django.urls.base import reverse_lazy from django.urls.base import reverse_lazy
from django.views.generic import ListView, CreateView, DetailView, DeleteView from django.views.generic import ListView, CreateView, DetailView, DeleteView
from django.views.generic import UpdateView from django.views.generic import UpdateView
from django.contrib.auth.mixins import LoginRequiredMixin
from webapp.models import Course from webapp.models import Course
from webapp.forms import CourseForm from webapp.forms import CourseForm
class CourseCreateView(CreateView): class CourseCreateView(LoginRequiredMixin, CreateView):
template_name = 'courses/create.html' template_name = 'courses/create.html'
form_class = CourseForm form_class = CourseForm
model = Course model = Course
...@@ -25,19 +27,19 @@ class CoursesListView(ListView): ...@@ -25,19 +27,19 @@ class CoursesListView(ListView):
paginate_by = 6 paginate_by = 6
class CourseDetailView(DetailView): class CourseDetailView(LoginRequiredMixin, DetailView):
model = Course model = Course
template_name = 'courses/detail.html' template_name = 'courses/detail.html'
pk_url_kwarg = 'course_pk' pk_url_kwarg = 'course_pk'
class CourseDeleteView(DeleteView): class CourseDeleteView(LoginRequiredMixin, DeleteView):
model = Course model = Course
template_name = 'courses/delete.html' template_name = 'courses/delete.html'
success_url = reverse_lazy('webapp:courses_list') success_url = reverse_lazy('webapp:courses_list')
class CourseEditView(UpdateView): class CourseEditView(LoginRequiredMixin, UpdateView):
model = Course model = Course
fields = ['title', 'description', 'start_date'] fields = ['title', 'description', 'start_date']
template_name = 'courses/edit.html' template_name = 'courses/edit.html'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment