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.
 
 
 
 
 
 

29 lines
933 B

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