You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

36 lines
1.1 KiB

from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404
from django.utils.decorators import method_decorator
from django.views.generic import ListView, UpdateView, TemplateView
from .models import LiveLesson
class LiveLessonsView(ListView):
model = LiveLesson
template_name = 'school/livelessons_list.html'
def get(self, request, pk=None):
if request.user.role not in [User.ADMIN_ROLE, User.TEACHER_ROLE]:
raise Http404
return super().get(request)
@method_decorator(login_required, name='dispatch')
class LiveLessonEditView(TemplateView):
template_name = 'course/course_edit.html'
def get(self, request, pk=None):
if request.user.role not in [User.ADMIN_ROLE, User.TEACHER_ROLE]:
raise Http404
if pk:
self.object = get_object_or_404(LiveLesson, pk=pk)
else:
self.object = LiveLesson.objects.create()
return super().get(request)
def get_context_data(self):
context = super().get_context_data()
context['object'] = self.object
context['live'] = 'true'
return context