예제 #1
0
    def page_link_list(self):
        formats = ("creole", "html", "plugin")
        format = self.request.GET.get('format')
        if not format in formats:
            format = formats[0]
        
        page_list = flat_tree_list()

        context = {
            "page_list": page_list,
            "prefix": settings.PERMALINK_URL_PREFIX,
            "plugin_prefix": self.URLs.commandLink("permalink", "build"),
            "add_data_tag": mark_safe(settings.ADD_DATA_TAG),
            
            "formats": formats,
            "format": format,
        }
        content = self._get_rendered_template("page_link_list", context)
        # insert CSS data from the internal page into the rendered page:
        content = replace_add_data(self.context, content)
        return HttpResponse(content)
예제 #2
0
    def select_edit_page(self):
        """
        A html select box for editing a cms page.
        If the form was sended, return a redirect to the edit_page method.
        """
        if self.request.method == 'POST':
            form = SelectEditPageForm(self.request.POST)
            if form.is_valid():
                form_data = form.cleaned_data
                page_id = form_data["page_id"]
                new_url = self.URLs.commandLink(
                    "page_admin", "edit_page", page_id
                )
#                self.page_msg(new_url)
                return HttpResponseRedirect(new_url)

        page_list = flat_tree_list()

        context = {
            "page_list": page_list,
        }
        self._render_template("select_edit_page", context)
예제 #3
0
    def _get_pages(self):
        current_page = self.context["PAGE"]
        current_page_id = current_page.id

        tree_list = flat_tree_list(generate_level_names=False)

        backward_data = None
        forward_data = None
        for idx, page in enumerate(tree_list):
            if page["id"] == current_page_id:
                try:
                    backward_data = tree_list[idx-1]
                except IndexError:
                    # No previous page exists
                    pass
                try:
                    forward_data = tree_list[idx+1]
                except IndexError:
                    # No next page exists
                    pass

        def get_page_obj(page_data):
            """ Returns the model object, if available """
            if not page_data:
                # No back/forth page available
                return None
            page_id = page_data["id"]
            page = Page.objects.get(id__exact=page_id)
            if page.template == current_page.template:
                # The Links should only navigate inside a presentation and
                # not to a other page content (with a other template/style)
                return page
            else:
                return None

        forward_page = get_page_obj(forward_data)
        backward_page = get_page_obj(backward_data)

        return backward_page, current_page, forward_page