def add_view(self, request, form_url='', extra_context=None): extra_context = extra_context or {} if settings.CMS_MODERATOR and 'target' in request.GET and 'position' in request.GET: moderation_required = will_require_moderation(request.GET['target'], request.GET['position']) extra_context.update({ 'moderation_required': moderation_required, 'moderation_level': _('higher'), 'show_save_and_continue':True, }) return super(PageAdmin, self).add_view(request, form_url, extra_context)
def add_view(self, request, form_url="", extra_context=None): extra_context = extra_context or {} if settings.CMS_MODERATOR and "target" in request.GET and "position" in request.GET: moderation_required = will_require_moderation(request.GET["target"], request.GET["position"]) extra_context.update( { "moderation_required": moderation_required, "moderation_level": _("higher"), "show_save_and_continue": True, } ) language = get_language_from_request(request) extra_context.update({"language": language}) return super(PageAdmin, self).add_view(request, form_url, extra_context)
def add_view(self, request, form_url='', extra_context=None): extra_context = extra_context or {} if settings.CMS_MODERATOR and 'target' in request.GET and 'position' in request.GET: moderation_required = will_require_moderation( request.GET['target'], request.GET['position']) extra_context.update({ 'moderation_required': moderation_required, 'moderation_level': _('higher'), 'show_save_and_continue': True, }) language = get_language_from_request(request) extra_context.update({ 'language': language, }) return super(PageAdmin, self).add_view(request, form_url, extra_context)
def save_model(self, request, obj, form, change): """ Move the page in the tree if neccesary and save every placeholder Content object. """ target = request.GET.get('target', None) position = request.GET.get('position', None) if 'recover' in request.path: pk = obj.pk if obj.parent_id: parent = Page.objects.get(pk=obj.parent_id) else: parent = None obj.lft = 0 obj.rght = 0 obj.tree_id = 0 obj.level = 0 obj.pk = None obj.insert_at(parent, commit=False) obj.pk = pk obj.save(no_signals=True) obj.save() else: if 'revert' in request.path: old_obj = Page.objects.get(pk=obj.pk) obj.level = old_obj.level obj.parent_id = old_obj.parent_id obj.rght = old_obj.rght obj.lft = old_obj.lft obj.tree_id = old_obj.tree_id force_with_moderation = target is not None and position is not None and \ will_require_moderation(target, position) obj.save(force_with_moderation=force_with_moderation) language = form.cleaned_data['language'] if target is not None and position is not None: try: target = self.model.objects.get(pk=target) except self.model.DoesNotExist: pass else: obj.move_to(target, position) Title.objects.set_or_create( obj, language, slug=form.cleaned_data['slug'], title=form.cleaned_data['title'], application_urls=form.cleaned_data.get('application_urls', None), overwrite_url=form.cleaned_data.get('overwrite_url', None), redirect=form.cleaned_data.get('redirect', None), meta_description=form.cleaned_data.get('meta_description', None), meta_keywords=form.cleaned_data.get('meta_keywords', None), page_title=form.cleaned_data.get('page_title', None), menu_title=form.cleaned_data.get('menu_title', None), ) # is there any moderation message? save/update state if settings.CMS_MODERATOR and 'moderator_message' in form.cleaned_data and \ form.cleaned_data['moderator_message']: update_moderation_message(obj, form.cleaned_data['moderator_message'])