From 774e9e7379bcce791a6606207f59be33e7cc7939 Mon Sep 17 00:00:00 2001 From: Jaap Joris Vens Date: Sat, 14 Mar 2020 12:35:15 +0100 Subject: [PATCH] Remove SectionFormSetView. If you need formsets, just add them to your custom form! --- cms/views.py | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/cms/views.py b/cms/views.py index eca783b..657f7e4 100644 --- a/cms/views.py +++ b/cms/views.py @@ -40,31 +40,6 @@ class SectionFormView(edit.FormMixin, SectionView): return HttpResponseRedirect(self.get_success_url()) return form -class SectionFormSetView(SectionView): - '''Generic section with associated formset''' - - formset_class = None - - def post(self, request): - '''Process form''' - formset = self.get_formset() - if formset.is_valid(): - formset.save(request) - return HttpResponseRedirect(self.get_success_url()) - return formset - - def get_formset(self): - # todo: handle initials! - return self.formset_class() - - def get_context_data(self, **kwargs): - if 'formset' not in kwargs: - kwargs['formset'] = self.get_formset() - return super().get_context_data(**kwargs) - -def get_view(section): - return section.__class__.view_class() - class PageView(detail.DetailView): '''View of a page with heterogeneous (polymorphic) sections''' model = Page @@ -75,7 +50,7 @@ class PageView(detail.DetailView): super().setup(*args, slug=slug, **kwargs) def initialize_section(self, section): - section.view = get_view(section) + section.view = section.__class__.view_class() section.view.setup(self.request, section) section.context = section.view.get_context_data( request = self.request,