Exemple #1
0
    def render_description(self, save=False):
        """
        Render the content. Save the model only if ``save`` is True.
        """

        # Render HTML
        content_html, content_text, _ = render_document(self.description,
                                                        allow_text_formating=True,
                                                        allow_text_extra=True,
                                                        allow_text_alignments=True,
                                                        allow_text_directions=True,
                                                        allow_text_modifiers=True,
                                                        allow_text_colors=True,
                                                        allow_spoilers=True,
                                                        allow_lists=True,
                                                        allow_definition_lists=True,
                                                        allow_acronyms=True,
                                                        allow_links=True,
                                                        allow_cdm_extra=True,
                                                        force_nofollow=False,
                                                        render_text_version=True)
        self.description_html = content_html
        self.description_text = content_text

        # Save if required
        if save:
            # Avoid infinite loop by calling directly super.save
            super(Forum, self).save(update_fields=('description_html', 'description_text'))
Exemple #2
0
    def render_text(self, save=False):
        """
        Render the content. Save the model only if ``save`` is True.
        """

        # Render HTML
        allow_titles_in_post = self.author.has_perm('forum.allow_titles_in_post')
        allow_alerts_box_in_post = self.author.has_perm('forum.allow_alerts_box_in_post')
        allow_text_colors_in_post = self.author.has_perm('forum.allow_text_colors_in_post')
        allow_cdm_extra_in_post = self.author.has_perm('forum.allow_cdm_extra_in_post')
        force_nofollow_in_post = not self.author.has_perm('forum.allow_raw_link_in_post')
        content_html, content_text, extra_dict = render_document(self.content,
                                                                 allow_titles=allow_titles_in_post,
                                                                 allow_code_blocks=True,
                                                                 allow_alerts_box=allow_alerts_box_in_post,
                                                                 allow_text_formating=True,
                                                                 allow_text_extra=True,
                                                                 allow_text_alignments=True,
                                                                 allow_text_directions=True,
                                                                 allow_text_modifiers=True,
                                                                 allow_text_colors=allow_text_colors_in_post,
                                                                 allow_spoilers=True,
                                                                 allow_figures=True,
                                                                 allow_lists=True,
                                                                 allow_todo_lists=True,
                                                                 allow_definition_lists=True,
                                                                 allow_tables=True,
                                                                 allow_quotes=True,
                                                                 allow_footnotes=True,
                                                                 allow_acronyms=True,
                                                                 allow_links=True,
                                                                 allow_medias=True,
                                                                 allow_cdm_extra=allow_cdm_extra_in_post,
                                                                 force_nofollow=force_nofollow_in_post,
                                                                 render_text_version=True,
                                                                 render_extra_dict=True,
                                                                 merge_footnotes_text=True)
        self.content_html = content_html
        self.content_text = content_text
        self.summary_html = extra_dict['summary_html'] if allow_titles_in_post else ''
        self.footnotes_html = extra_dict['footnotes_html']

        # Save if required
        if save:
            # Avoid infinite loop by calling directly super.save
            super(ForumThreadPost, self).save(update_fields=('content_html', 'content_text',
                                                             'summary_html', 'footnotes_html'))
Exemple #3
0
    def render_body(self, save=False):
        """
        Render the comment body. Save the model only if ``save`` is True.
        """

        # Render HTML
        allow_titles_in_comment = self.author.has_perm('bugtracker.allow_titles_in_comment')
        allow_alerts_box_in_comment = self.author.has_perm('bugtracker.allow_alerts_box_in_comment')
        allow_text_colors_in_comment = self.author.has_perm('bugtracker.allow_text_colors_in_comment')
        allow_cdm_extra_in_comment = self.author.has_perm('bugtracker.allow_cdm_extra_in_comment')
        force_nofollow_in_comment = not self.author.has_perm('bugtracker.allow_raw_link_in_comment')
        content_html, content_text, _ = render_document(self.body,
                                                        allow_titles=allow_titles_in_comment,
                                                        allow_code_blocks=True,
                                                        allow_alerts_box=allow_alerts_box_in_comment,
                                                        allow_text_formating=True,
                                                        allow_text_extra=True,
                                                        allow_text_alignments=True,
                                                        allow_text_directions=True,
                                                        allow_text_modifiers=True,
                                                        allow_text_colors=allow_text_colors_in_comment,
                                                        allow_spoilers=True,
                                                        allow_figures=True,
                                                        allow_lists=True,
                                                        allow_todo_lists=True,
                                                        allow_definition_lists=True,
                                                        allow_tables=True,
                                                        allow_quotes=True,
                                                        allow_footnotes=True,
                                                        allow_acronyms=True,
                                                        allow_links=True,
                                                        allow_medias=True,
                                                        allow_cdm_extra=allow_cdm_extra_in_comment,
                                                        force_nofollow=force_nofollow_in_comment,
                                                        render_text_version=True,
                                                        merge_footnotes_html=True,
                                                        merge_footnotes_text=True)
        self.body_html = content_html
        self.body_text = content_text

        # Save if required
        if save:
            # Avoid infinite loop by calling directly super.save
            super(IssueComment, self).save(update_fields=('body_html', 'body_text'))
Exemple #4
0
    def render_body(self, save=False):
        """
        Render the content. Save the model only if ``save`` is True.
        :param save: Set to True to save the model after the rendering.
        """

        # Render HTML
        allow_cdm_extra = self.sender.has_perm('accounts.allow_cdm_extra')
        content_html, content_text, _ = render_document(self.body,
                                                        allow_titles=True,
                                                        allow_code_blocks=True,
                                                        allow_alerts_box=True,
                                                        allow_text_formating=True,
                                                        allow_text_extra=True,
                                                        allow_text_alignments=True,
                                                        allow_text_directions=True,
                                                        allow_text_modifiers=True,
                                                        allow_text_colors=True,
                                                        allow_spoilers=True,
                                                        allow_figures=True,
                                                        allow_lists=True,
                                                        allow_todo_lists=True,
                                                        allow_definition_lists=True,
                                                        allow_tables=True,
                                                        allow_quotes=True,
                                                        allow_footnotes=True,
                                                        allow_acronyms=True,
                                                        allow_links=True,
                                                        allow_medias=True,
                                                        allow_cdm_extra=allow_cdm_extra,
                                                        render_text_version=True,
                                                        merge_footnotes_html=True,
                                                        merge_footnotes_text=True)
        self.body_html = content_html
        self.body_text = content_text

        # Save if required
        if save:
            # Avoid infinite loop by calling directly super.save
            super(PrivateMessage, self).save(update_fields=('body_html', 'body_text'))
Exemple #5
0
    def render_text(self, save=False):
        """
        Render the content.
        :param save: Save the model field ``content_html`` if ``True``.
        """

        # Render HTML
        content_html, content_text, _ = render_document(self.content,
                                                        allow_titles=True,
                                                        allow_code_blocks=True,
                                                        allow_text_formating=True,
                                                        allow_text_extra=True,
                                                        allow_text_alignments=True,
                                                        allow_text_directions=True,
                                                        allow_text_modifiers=True,
                                                        allow_text_colors=True,
                                                        allow_spoilers=True,
                                                        allow_figures=True,
                                                        allow_lists=True,
                                                        allow_todo_lists=True,
                                                        allow_definition_lists=True,
                                                        allow_tables=True,
                                                        allow_quotes=True,
                                                        allow_footnotes=True,
                                                        allow_acronyms=True,
                                                        allow_links=True,
                                                        allow_medias=True,
                                                        allow_cdm_extra=True,
                                                        force_nofollow=False,
                                                        render_text_version=True,
                                                        merge_footnotes_html=True,
                                                        merge_footnotes_text=True)
        self.content_html = content_html
        self.content_text = content_text

        # Save if required
        if save:
            self.save_no_rendering(update_fields=('content_html', 'content_text'))
Exemple #6
0
    def render_text(self, save=False):
        """
        Render the biography and signature HTML versions from the source text.
        Save the model (in fact, save only the ``biography_html`` and ``signature_html`` fields) if ``save`` is True.
        :param save: Set to True to save the model after text rendering (default is False).
        """

        # Render HTML
        allow_titles_in_biography = self.user.has_perm('accounts.allow_titles_in_biography')
        allow_alerts_box_in_biography = self.user.has_perm('accounts.allow_alerts_box_in_biography')
        allow_text_colors_in_biography = self.user.has_perm('accounts.allow_text_colors_in_biography')
        allow_cdm_extra_in_biography = self.user.has_perm('accounts.allow_cdm_extra_in_biography')
        force_nofollow_in_biography = not self.user.has_perm('accounts.allow_raw_link_in_biography')
        content_html, content_text, _ = render_document(self.biography,
                                                        allow_titles=allow_titles_in_biography,
                                                        allow_code_blocks=True,
                                                        allow_alerts_box=allow_alerts_box_in_biography,
                                                        allow_text_formating=True,
                                                        allow_text_extra=True,
                                                        allow_text_alignments=True,
                                                        allow_text_directions=True,
                                                        allow_text_modifiers=True,
                                                        allow_text_colors=allow_text_colors_in_biography,
                                                        allow_spoilers=True,
                                                        allow_figures=True,
                                                        allow_lists=True,
                                                        allow_todo_lists=True,
                                                        allow_definition_lists=True,
                                                        allow_tables=True,
                                                        allow_quotes=True,
                                                        allow_footnotes=True,
                                                        allow_acronyms=True,
                                                        allow_links=True,
                                                        allow_medias=True,
                                                        allow_cdm_extra=allow_cdm_extra_in_biography,
                                                        force_nofollow=force_nofollow_in_biography,
                                                        render_text_version=True,
                                                        merge_footnotes_html=True,
                                                        merge_footnotes_text=True)
        self.biography_html = content_html
        self.biography_text = content_text

        allow_code_blocks_in_signature = self.user.has_perm('accounts.allow_code_blocks_in_signature')
        allow_text_colors_in_signature = self.user.has_perm('accounts.allow_text_colors_in_signature')
        allow_lists_in_signature = self.user.has_perm('accounts.allow_lists_in_signature')
        allow_tables_in_signature = self.user.has_perm('accounts.allow_tables_in_signature')
        allow_quotes_in_signature = self.user.has_perm('accounts.allow_quotes_in_signature')
        allow_medias_in_signature = self.user.has_perm('accounts.allow_medias_in_signature')
        allow_cdm_extra_in_signature = self.user.has_perm('accounts.allow_cdm_extra_in_signature')
        force_nofollow_in_signature = not self.user.has_perm('accounts.allow_raw_link_in_signature')
        content_html, content_text, _ = render_document(self.signature,
                                                        allow_code_blocks=allow_code_blocks_in_signature,
                                                        allow_text_formating=True,
                                                        allow_text_extra=True,
                                                        allow_text_alignments=True,
                                                        allow_text_directions=True,
                                                        allow_text_modifiers=True,
                                                        allow_text_colors=allow_text_colors_in_signature,
                                                        allow_lists=allow_lists_in_signature,
                                                        allow_todo_lists=allow_lists_in_signature,
                                                        allow_definition_lists=allow_lists_in_signature,
                                                        allow_tables=allow_tables_in_signature,
                                                        allow_quotes=allow_quotes_in_signature,
                                                        allow_acronyms=True,
                                                        allow_links=True,
                                                        allow_medias=allow_medias_in_signature,
                                                        allow_cdm_extra=allow_cdm_extra_in_signature,
                                                        force_nofollow=force_nofollow_in_signature,
                                                        render_text_version=True,
                                                        make_auto_paragraphs=False)
        self.signature_html = content_html
        self.signature_text = content_text

        # Save if required
        if save:
            self.save_no_rendering(update_fields=('biography_html', 'biography_text',
                                                  'signature_html', 'signature_text'))