Skip to content

Commit

Permalink
Merge branch 'dev' into disable-api-robots
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud-D authored Jun 8, 2022
2 parents 0e07bfc + fa390e3 commit 8128879
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 115 deletions.
6 changes: 0 additions & 6 deletions doc/source/back-end-code/utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ Modèles (``models.py``)
.. automodule:: zds.utils.models
:members:

Tutoriels (``tutorials.py``)
============================

.. automodule:: zds.utils.tutorials
:members:

Les processeurs de contexte (``context_processor.py``)
======================================================

Expand Down
10 changes: 5 additions & 5 deletions templates/tutorialv2/includes/exports.part.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
data-exports-id="{{ content.pk }}"
data-exports-api="{% url "api:content:list_exports" content.pk %}"
data-request-export-api="{% url "api:content:generate_export" content.pk %}">
{% trans "Exports du contenu (PDF, ePub, LaTeX…)" %}
{% trans "Exports du contenu" %}
</a>

<div class="modal modal-flex" id="exports-modal" data-modal-close="Fermer">
{% blocktrans %}
<p>
En plus de leur version web, <strong>vos contenus sont exportés
automatiquement en différents formats</strong> (PDF, ePub pour
liseuses, LaTeX, HTML…) par Zeste de Savoir, ce qui permet notamment
de les diffuser plus facilement hors-ligne.
automatiquement en différents formats</strong> par Zeste de
Savoir, ce qui permet notamment de les diffuser plus facilement
hors-ligne.
</p>
{% endblocktrans %}

<section class="exports is-empty"
data-tr-no-exports="{% trans "<strong>Ce contenu n'a jamais été exporté.</strong><br />Cliquez sur le bouton vert ci-dessous pour générer des version PDF, ePub, etc. !" %}"
data-tr-no-exports="{% trans "<strong>Ce contenu n'a jamais été exporté.</strong><br />Cliquez sur le bouton vert ci-dessous pour demander les exports !" %}"
data-tr-error-loading="{% trans "Impossible de charger la liste des exports." %}"
data-tr-formatpdf="{% trans "PDF" %}"
data-tr-formatepub="{% trans "ePub" %}"
Expand Down
2 changes: 1 addition & 1 deletion zds/tutorialv2/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def clean(self):

class EditContentTagsForm(forms.Form):
tags = forms.CharField(
label=_("Tags séparés par des virgules (exemple : python,django,web) :"),
label=_("Tags séparés par des virgules (exemple : python,api,web) :"),
max_length=64,
required=False,
widget=forms.TextInput(
Expand Down
3 changes: 1 addition & 2 deletions zds/tutorialv2/models/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@
from zds.tutorialv2.models import TYPE_CHOICES, STATUS_CHOICES, CONTENT_TYPES_REQUIRING_VALIDATION, PICK_OPERATIONS
from zds.tutorialv2.models.mixins import TemplatableContentModelMixin, OnlineLinkableContentMixin
from zds.tutorialv2.models.versioned import NotAPublicVersion
from zds.tutorialv2.utils import get_content_from_json, BadManifestError
from zds.tutorialv2.utils import get_content_from_json, BadManifestError, get_blob
from zds.utils import get_current_user
from zds.utils.models import SubCategory, Licence, HelpWriting, Comment, Tag
from zds.utils.templatetags.emarkdown import render_markdown_stats
from zds.utils.tutorials import get_blob
from zds.utils.uuslug_wrapper import uuslug

ALLOWED_TYPES = ["pdf", "md", "html", "epub", "zip", "tex"]
Expand Down
2 changes: 1 addition & 1 deletion zds/utils/templatetags/emarkdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def epub_markdown(md_input, image_directory):
replaced_media_url = settings.MEDIA_URL
if replaced_media_url.startswith("/"):
replaced_media_url = replaced_media_url[1:]
return (
return mark_safe(
emarkdown(
md_input,
output_format="epub",
Expand Down
31 changes: 21 additions & 10 deletions zds/utils/tests/tests_emarkdown.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from collections import namedtuple
from textwrap import dedent

from django.test import TestCase
Expand All @@ -8,26 +9,36 @@

class EMarkdownTest(TestCase):
def setUp(self):
content = "# Titre 1\n\n## Titre **2**\n\n### Titre 3\n\n> test"
self.context = Context({"content": content})

def test_emarkdown(self):
# The goal is not to test zmarkdown but test that template tag correctly call it

tr = Template("{% load emarkdown %}{{ content | emarkdown}}").render(self.context)

expected = (
self.content = "# Titre 1\n\n## Titre **2**\n\n### Titre 3\n\n> test"
self.context = Context({"content": self.content})
self.long_expected = (
'<h3 id="titre-1">Titre 1<a aria-hidden="true" tabindex="-1" href="#titre-1">'
'<span class="icon icon-link"></span></a></h3>\n<h4 id="titre-2">'
'Titre <strong>2</strong><a aria-hidden="true" tabindex="-1" href="#titre-2"><span'
' class="icon icon-link"></span></a></h4>\n<h5 id="titre-3">Titre 3'
'<a aria-hidden="true" tabindex="-1" href="#titre-3"><span class="icon icon-link">'
"</span></a></h5>\n<blockquote>\n<p>test</p>\n</blockquote>"
)
self.assertEqual(tr, expected)

def test_emarkdown(self):
# The goal is not to test zmarkdown but test that template tag correctly call it

tr = Template("{% load emarkdown %}{{ content | emarkdown}}").render(self.context)

self.assertEqual(tr, self.long_expected)

# Todo: Find a way to force parsing crash or simulate it.

def test_epub_markdown(self):
DirTuple = namedtuple("DirTuple", ["absolute", "relative"])
image_directory = DirTuple("/some/absolute/path", "../some/relative/path")

tr = Template("{% load emarkdown %}{{ content | epub_markdown:image_directory }}").render(
Context({"content": self.content, "image_directory": image_directory})
)

self.assertEqual(tr, self.long_expected)

def test_emarkdown_inline(self):
# The goal is not to test zmarkdown but test that template tag correctly call it

Expand Down
90 changes: 0 additions & 90 deletions zds/utils/tutorials.py

This file was deleted.

0 comments on commit 8128879

Please sign in to comment.