from django.views.generic import TemplateView, ListView, CreateView, FormView, DeleteView, UpdateView from core.mixins.auth import AdminMixin from core.views.generic import RedirectView class BackendViewMixin(AdminMixin): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) try: context["title"] = self.title except AttributeError: pass return context class BackendTemplateView(BackendViewMixin, TemplateView): pass class BackendListView(BackendViewMixin, ListView): pass class BackendCreateView(BackendViewMixin, CreateView): pass class BackendFormView(BackendViewMixin, FormView): pass class BackendDeleteView(BackendViewMixin, DeleteView): pass class BackendUpdateView(BackendViewMixin, UpdateView): pass class BackendRedirectView(AdminMixin, RedirectView): pass