def save_model(self, request, page, form, change): """Move the page in the tree if necessary and save every placeholder :class:`Content <pages.models.Content>`. """ language = form.cleaned_data["language"] target = form.data.get("target", None) position = form.data.get("position", None) page.save() # if True, we need to move the page if target and position: try: target = self.model.objects.get(pk=target) except self.model.DoesNotExist: pass else: target.invalidate() page.move_to(target, position) for name in self.mandatory_placeholders: data = form.cleaned_data[name] placeholder = PlaceholderNode(name) placeholder.save(page, language, data, change) for placeholder in get_placeholders(page.get_template()): if placeholder.name in form.cleaned_data and placeholder.name not in self.mandatory_placeholders: data = form.cleaned_data[placeholder.name] placeholder.save(page, language, data, change) page.invalidate()
def save_model(self, request, page, form, change): """Move the page in the tree if necessary and save every placeholder :class:`Content <pages.models.Content>`. """ language = form.cleaned_data['language'] target = form.data.get('target', None) position = form.data.get('position', None) page.save() # if True, we need to move the page if target and position: try: target = self.model.objects.get(pk=target) except self.model.DoesNotExist: pass else: target.invalidate() page.move_to(target, position) for name in self.mandatory_placeholders: data = form.cleaned_data[name] placeholder = PlaceholderNode(name) extra_data = placeholder.get_extra_data(form.data) placeholder.save(page, language, data, change, extra_data=extra_data) for placeholder in get_placeholders(page.get_template()): if(placeholder.ctype in form.cleaned_data and placeholder.ctype not in self.mandatory_placeholders): data = form.cleaned_data[placeholder.ctype] extra_data = placeholder.get_extra_data(form.data) placeholder.save(page, language, data, change, extra_data=extra_data) page.invalidate()
def save_model(self, request, page, form, change): """Move the page in the tree if necessary and save every placeholder :class:`Content <pages.models.Content>`. """ language = form.cleaned_data['language'] target = form.data.get('target', None) position = form.data.get('position', None) page.save() # if True, we need to move the page if target and position: try: target = self.model.objects.get(pk=target) except self.model.DoesNotExist: pass else: target.invalidate() page.move_to(target, position) for name in self.mandatory_placeholders: data = form.cleaned_data[name] placeholder = PlaceholderNode(name) extra_data = placeholder.get_extra_data(form.data) placeholder.save(page, language, data, change, extra_data=extra_data) for placeholder in get_placeholders(page.get_template()): if(placeholder.name in form.cleaned_data and placeholder.name not in self.mandatory_placeholders): data = form.cleaned_data[placeholder.name] extra_data = placeholder.get_extra_data(form.data) placeholder.save(page, language, data, change, extra_data=extra_data) for placeholder in self.metadata_fields: data = form.cleaned_data[placeholder['name']] Content.objects.set_or_create_content( page, language, placeholder['name'], data ) page.invalidate()