예제 #1
0
 def __call__(self, request, url):
     """
     Delegate to the appropriate method, based on the URL.
     """
     if url is None:
         return self.list_pages(request)
     elif url.endswith('add-plugin'):
         return add_plugin(request)
     elif 'edit-plugin' in url:
         plugin_id = url.split("/")[-1]
         return edit_plugin(request, plugin_id, self.admin_site)
     elif 'remove-plugin' in url:
         return remove_plugin(request)
     elif 'move-plugin' in url:
         return move_plugin(request)
     elif url.endswith('/move-page'):
         return self.move_page(request, unquote(url[:-10]))
     elif url.endswith('/copy-page'):
         return self.copy_page(request, unquote(url[:-10]))
     elif url.endswith('/change-status'):
         return change_status(request, unquote(url[:-14]))
     elif url.endswith('/change-navigation'):
         return change_innavigation(request, unquote(url[:-18]))
     elif url.endswith('jsi18n') or url.endswith('jsi18n/'):
         return HttpResponseRedirect("../../../jsi18n/")
     elif ('history' in url or 'recover' in url) and request.method == "POST":
         resp = super(PageAdmin, self).__call__(request, url)
         if resp.status_code == 302:
             version = int(url.split("/")[-1])
             revert_plugins(request, version)
             return resp
     if len(url.split("/?")):# strange bug in 1.0.2 if post and get variables in the same request
         url = url.split("/?")[0]
     return super(PageAdmin, self).__call__(request, url)
예제 #2
0
    def render_revision_form(self, request, obj, version, context, revert=False, recover=False):
        # reset parent to null if parent is not found
        if version.field_dict['parent']: 
            try:
                Page.objects.get(pk=version.field_dict['parent'])
            except:
                if revert and obj.parent_id != int(version.field_dict['parent']):
                    version.field_dict['parent'] = obj.parent_id
                if recover:
                    obj.parent = None
                    obj.parent_id = None
                    version.field_dict['parent'] = None

        response = super(PageAdmin, self).render_revision_form(request, obj, version, context, revert, recover)
        if request.method == "POST" \
            and ('history' in request.path or 'recover' in request.path) \
            and response.status_code == 302:
            obj.pagemoderatorstate_set.all().delete()
            if settings.CMS_MODERATOR:
                from cms.utils.moderator import page_changed
                page_changed(obj, force_moderation_action=PageModeratorState.ACTION_CHANGED)
                
            # revert plugins
            revert_plugins(request, version.pk, obj)
        return response
예제 #3
0
    def render_revision_form(self,
                             request,
                             obj,
                             version,
                             context,
                             revert=False,
                             recover=False):
        # reset parent to null if parent is not found
        if version.field_dict['parent']:
            try:
                Page.objects.get(pk=version.field_dict['parent'])
            except:
                if revert and obj.parent_id != int(
                        version.field_dict['parent']):
                    version.field_dict['parent'] = obj.parent_id
                if recover:
                    obj.parent = None
                    obj.parent_id = None
                    version.field_dict['parent'] = None

        response = super(PageAdmin,
                         self).render_revision_form(request, obj, version,
                                                    context, revert, recover)
        if request.method == "POST" \
            and ('history' in request.path or 'recover' in request.path) \
            and response.status_code == 302:
            obj.pagemoderatorstate_set.all().delete()
            if settings.CMS_MODERATOR:
                from cms.utils.moderator import page_changed
                page_changed(
                    obj,
                    force_moderation_action=PageModeratorState.ACTION_CHANGED)

            # revert plugins
            revert_plugins(request, version.pk, obj)
        return response