Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supprime le paramètre build_pdf_when_published et désactive plus d'exports dans les tests #6670

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion doc/source/back-end/contents.rst
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,6 @@ Ces paramètres sont à surcharger dans le dictionnaire ``ZDS_APP['content']``:
- ``user_page_number``: Nombre de contenus de chaque type qu'on affiche sur le profil d'un utilisateur, 5 par défaut,
- ``default_image``: chemin vers l'image utilisée par défaut dans les icônes de contenu,
- ``import_image_prefix``: préfixe mnémonique permettant d'indiquer que l'image se trouve dans l'archive jointe lors de l'import de contenu
- ``build_pdf_when_published``: indique que la publication générera un PDF (quelque soit la politique, si ``False``, les PDF ne seront pas générés, sauf à appeler la commande adéquate),
- ``maximum_slug_size``: taille maximale du slug d'un contenu

Paramètres propres aux tribunes libres
Expand Down
1 change: 0 additions & 1 deletion zds/settings/abstract_base/zds.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@
"user_page_number": 5,
"default_image": BASE_DIR / "fixtures" / "noir_black.png",
"import_image_prefix": "archive",
"build_pdf_when_published": True,
"maximum_slug_size": 150,
"characters_per_minute": 1500,
"editorial_line_link": "https://zestedesavoir.com/articles/3978/la-ligne-editoriale-officielle-de-zeste-de-savoir-2/",
Expand Down
1 change: 0 additions & 1 deletion zds/settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def _get_version():
ZDS_APP["site"]["association"]["email"] = "[email protected]"

# content
# ZDS_APP['content']['build_pdf_when_published'] = False
ZDS_APP["article"]["repo_path"] = "/opt/zds/data/articles-data"
ZDS_APP["content"]["repo_private_path"] = "/opt/zds/data/contents-private"
ZDS_APP["content"]["repo_public_path"] = "/opt/zds/data/contents-public"
Expand Down
8 changes: 1 addition & 7 deletions zds/tutorialv2/publication_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,22 +174,16 @@ def write_md_file(md_file_path, parsed_with_local_images, versioned):
)


def generate_external_content(
base_name, extra_contents_path, md_file_path, overload_settings=False, excluded=None, **kwargs
):
def generate_external_content(base_name, extra_contents_path, md_file_path, excluded=None, **kwargs):
"""
generate all static file that allow offline access to content
:param base_name: base nae of file (without extension)
:param extra_contents_path: internal directory where all files will be pushed
:param md_file_path: bundled markdown file path
:param overload_settings: this option force the function to generate all registered formats even when settings \
ask for PDF not to be published
:param excluded: list of excluded format, None if no exclusion
"""
excluded = excluded or ["watchdog"]
if not settings.ZDS_APP["content"]["build_pdf_when_published"] and not overload_settings:
excluded.append("pdf")
for publicator_name, publicator in PublicatorRegistry.get_all_registered(excluded):
try:
publicator.publish(
Expand Down
1 change: 0 additions & 1 deletion zds/tutorialv2/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
overridden_zds_app["content"]["repo_private_path"] = settings.BASE_DIR / "contents-private-test"
overridden_zds_app["content"]["repo_public_path"] = settings.BASE_DIR / "contents-public-test"
overridden_zds_app["content"]["extra_content_generation_policy"] = "SYNC"
overridden_zds_app["content"]["build_pdf_when_published"] = False


class override_for_contents(override_settings):
Expand Down
7 changes: 1 addition & 6 deletions zds/tutorialv2/tests/tests_feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@
overridden_zds_app = deepcopy(settings.ZDS_APP)
overridden_zds_app["content"]["repo_private_path"] = settings.BASE_DIR / "contents-private-test"
overridden_zds_app["content"]["repo_public_path"] = settings.BASE_DIR / "contents-public-test"
overridden_zds_app["content"]["extra_content_generation_policy"] = "NOTHING"


@override_settings(MEDIA_ROOT=settings.BASE_DIR / "media-test")
@override_settings(ZDS_APP=overridden_zds_app)
class LastTutorialsFeedsTest(TutorialTestMixin, TestCase):
def setUp(self):
self.overridden_zds_app = overridden_zds_app
# don't build PDF to speed up the tests
overridden_zds_app["content"]["build_pdf_when_published"] = False

self.licence = LicenceFactory()
self.subcategory = SubCategoryFactory()
Expand Down Expand Up @@ -225,8 +224,6 @@ def test_content_control_chars(self):
class LastArticlesFeedsTest(TutorialTestMixin, TestCase):
def setUp(self):
self.overridden_zds_app = overridden_zds_app
# don't build PDF to speed up the tests
overridden_zds_app["content"]["build_pdf_when_published"] = False

self.licence = LicenceFactory()
self.subcategory = SubCategoryFactory()
Expand Down Expand Up @@ -411,8 +408,6 @@ def test_content_control_chars(self):
class LastOpinionsFeedsTest(TutorialTestMixin, TestCase):
def setUp(self):
self.overridden_zds_app = overridden_zds_app
# don't build PDF to speed up the tests
overridden_zds_app["content"]["build_pdf_when_published"] = False

self.subcategory = SubCategoryFactory()
self.tag = TagFactory()
Expand Down
3 changes: 1 addition & 2 deletions zds/tutorialv2/tests/tests_front.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
overridden_zds_app = deepcopy(settings.ZDS_APP)
overridden_zds_app["content"]["repo_private_path"] = settings.BASE_DIR / "contents-private-test"
overridden_zds_app["content"]["repo_public_path"] = settings.BASE_DIR / "contents-public-test"
overridden_zds_app["content"]["extra_content_generation_policy"] = "NOTHING"


@override_settings(MEDIA_ROOT=settings.BASE_DIR / "media-test")
Expand All @@ -52,8 +53,6 @@ def tearDown(self):

def setUp(self):
self.overridden_zds_app = overridden_zds_app
# don't build PDF to speed up the tests
overridden_zds_app["content"]["build_pdf_when_published"] = False

self.staff = StaffProfileFactory().user

Expand Down
6 changes: 0 additions & 6 deletions zds/tutorialv2/tests/tests_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,6 @@ def test_generate_markdown(self):
def test_generate_pdf(self):
"""ensure the behavior of the `python manage.py generate_pdf` commmand"""

self.overridden_zds_app["content"]["build_pdf_when_published"] = True # this test need PDF build, if any

tuto = PublishedContentFactory(type="TUTORIAL") # generate and publish a tutorial
published = PublishedContent.objects.get(content_pk=tuto.pk)

Expand Down Expand Up @@ -596,9 +594,6 @@ def setUp(self):
self.user_author = ProfileFactory().user

self.old_registry = {key: value for key, value in PublicatorRegistry.get_all_registered()}
self.old_build_pdf_when_published = self.overridden_zds_app["content"]["build_pdf_when_published"]

self.overridden_zds_app["content"]["build_pdf_when_published"] = True

def get_latex_file_path(self, published: PublishedContent):
"""
Expand Down Expand Up @@ -856,4 +851,3 @@ def check(path):
def tearDown(self):
super().tearDown()
PublicatorRegistry.registry = self.old_registry
self.overridden_zds_app["content"]["build_pdf_when_published"] = self.old_build_pdf_when_published
2 changes: 0 additions & 2 deletions zds/tutorialv2/tests/tests_views/tests_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -2732,8 +2732,6 @@ def test_publication_make_extra_contents(self):
NOTE: this test will take time !"""
PublicatorRegistry.registry["pdf"] = ZMarkdownRebberLatexPublicator(".pdf")
PublicatorRegistry.registry["epub"] = ZMarkdownEpubPublicator()
# obviously, PDF builds have to be enabled
self.overridden_zds_app["content"]["build_pdf_when_published"] = True

title = "C'est pas le plus important ici !"

Expand Down
4 changes: 1 addition & 3 deletions zds/tutorialv2/tests/tests_views/tests_published.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
overridden_zds_app = deepcopy(settings.ZDS_APP)
overridden_zds_app["content"]["repo_private_path"] = settings.BASE_DIR / "contents-private-test"
overridden_zds_app["content"]["repo_public_path"] = settings.BASE_DIR / "contents-public-test"
overridden_zds_app["content"]["extra_content_generation_policy"] = "SYNC"
overridden_zds_app["content"]["extra_content_generation_policy"] = "NOTHING"


@override_settings(MEDIA_ROOT=settings.BASE_DIR / "media-test")
Expand All @@ -51,8 +51,6 @@ class PublishedContentTests(TutorialTestMixin, TestCase):
def setUp(self):
self.overridden_zds_app = overridden_zds_app
overridden_zds_app["content"]["default_licence_pk"] = LicenceFactory().pk
# don't build PDF to speed up the tests
overridden_zds_app["content"]["build_pdf_when_published"] = False

self.staff = StaffProfileFactory().user

Expand Down
11 changes: 6 additions & 5 deletions zds/utils/api/tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from copy import deepcopy
import shutil
import os
from django.conf import settings
from django.test.utils import override_settings
from django.urls import reverse
from rest_framework import status
from rest_framework.test import APITestCase
Expand All @@ -12,13 +14,15 @@
from zds.tutorialv2.tests.factories import PublishableContentFactory
from zds.tutorialv2.publication_utils import publish_content

overridden_zds_app = deepcopy(settings.ZDS_APP)
overridden_zds_app["content"]["extra_content_generation_policy"] = "NOTHING"


@override_settings(ZDS_APP=overridden_zds_app)
class TagListAPITest(APITestCase):
def setUp(self):
self.client = APIClient()
caches[extensions_api_settings.DEFAULT_USE_CACHE].clear()
# don't build PDF to speed up the tests
settings.ZDS_APP["content"]["build_pdf_when_published"] = False

def test_list_of_tags_empty(self):
"""
Expand Down Expand Up @@ -159,6 +163,3 @@ def tearDown(self):
shutil.rmtree(settings.ZDS_APP["content"]["repo_public_path"])
if os.path.isdir(settings.MEDIA_ROOT):
shutil.rmtree(settings.MEDIA_ROOT)

# re-activate PDF build
settings.ZDS_APP["content"]["build_pdf_when_published"] = True