Beispiel #1
0
from interface.forum.models import Forum, Category
from interface.forum.forms import CategoryForm, ForumForm


class ForumIndexView(ListView):
    model = Forum
    context_object_name = 'forums'
    template_name = 'forum/cpanel/index.html'

    def get_context_data(self, **kwargs):
        context = super(ForumIndexView, self).get_context_data(**kwargs)
        context['categories'] = Category.objects.all()
        return context


forum = staff_required(ForumIndexView.as_view())


class AddForumView(CreateView):
    form_class = ForumForm
    success_url = reverse_lazy('forum')
    template_name = 'forum/cpanel/add_forum.html'


add_forum = permission_required('config.change_setting')(
    AddForumView.as_view())


class EditForumView(UpdateView):
    model = Forum
    form_class = ForumForm
Beispiel #2
0
from django.core.urlresolvers import reverse_lazy
from django.views.generic import ListView, CreateView, UpdateView, DeleteView

from core.decorators import staff_required
from interface.apps.files.forms import FileForm, CategoryForm
from interface.apps.files.models import File, FileCategory


class FilesView(ListView):
    model = File
    paginate_by = 20
    context_object_name = 'files'
    template_name = 'files/cpanel/list_files.html'


files = staff_required(FilesView.as_view())


class AddFileView(CreateView):
    form_class = FileForm
    success_url = reverse_lazy('files')
    template_name = 'files/cpanel/add_file.html'


add_file = permission_required('config.change_setting')(
    AddFileView.as_view())


class EditFileView(UpdateView):
    model = File
    form_class = FileForm
Beispiel #3
0
from games.quiz.models import Quiz


class LessonsView(ListView):
    model = Lesson
    paginate_by = 20
    context_object_name = 'lessons'
    template_name = 'lesson/cpanel/list_lessons.html'

    def get_context_data(self, **kwargs):
        context = super(LessonsView, self).get_context_data(**kwargs)
        context['categories'] = LessonCategory.objects.all()
        return context


lessons = staff_required(LessonsView.as_view())


class AddLessonView(FormView):
    form_class = AddLessonForm
    template_name = 'lesson/cpanel/add_lesson.html'

    def get_form_kwargs(self):
        return dict(data=self.request.POST)

    def form_valid(self, form):
        form.save()
        return redirect('lessons')

    def get_context_data(self, **kwargs):
        context = super(AddLessonView, self).get_context_data(**kwargs)
Beispiel #4
0
from games.quiz.models import Quiz


class LessonsView(ListView):
    model = Lesson
    paginate_by = 20
    context_object_name = 'lessons'
    template_name = 'lesson/cpanel/list_lessons.html'

    def get_context_data(self, **kwargs):
        context = super(LessonsView, self).get_context_data(**kwargs)
        context['categories'] = LessonCategory.objects.all()
        return context


lessons = staff_required(LessonsView.as_view())


class AddLessonView(FormView):
    form_class = AddLessonForm
    template_name = 'lesson/cpanel/add_lesson.html'

    def get_form_kwargs(self):
        return dict(data=self.request.POST)

    def form_valid(self, form):
        form.save()
        return redirect('lessons')

    def get_context_data(self, **kwargs):
        context = super(AddLessonView, self).get_context_data(**kwargs)