Skip to content

Commit

Permalink
Merge branch 'dev' into feature/page-accessibilite
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbelval authored Oct 30, 2024
2 parents bbb44cc + 34e2307 commit 60d1f66
Show file tree
Hide file tree
Showing 24 changed files with 203 additions and 59 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
env:
NODE_VERSION: "18" # needs to be also updated in .nvmrc
PYTHON_VERSION: "3.11"
PIP_VERSION: "24.2" # stick to it while https://github.com/pypa/pip/issues/13046 is not fixed, needs to be also updated in scripts/define_variable.sh
MARIADB_VERSION: "10.4.10"
COVERALLS_VERSION: "3.3.1" # check if Coverage needs to be also updated in requirements-ci.txt
TYPESENSE_VERSION: "27.0" # needs to be also updated in scripts/define_variable.sh
Expand Down Expand Up @@ -59,7 +60,7 @@ jobs:
python-version: "${{ env.PYTHON_VERSION }}"

- name: Upgrade pip
run: pip install --upgrade pip
run: pip install pip==${{ env.PIP_VERSION }}

- name: Retrieve pip cache directory
id: pip-cache
Expand Down Expand Up @@ -188,8 +189,7 @@ jobs:
python-version: "${{ env.PYTHON_VERSION }}"

- name: Upgrade pip
run: |
pip install --upgrade pip
run: pip install pip==${{ env.PIP_VERSION }}

- name: Retrieve pip cache directory
id: pip-cache
Expand Down
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
4 changes: 4 additions & 0 deletions scripts/define_variable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ if [[ $ZDS_VENV_VERSION == "" ]]; then
ZDS_VENV_VERSION="20.24.5"
fi

if [[ $ZDS_PIP_VERSION == "" ]]; then
ZDS_PIP_VERSION="24.2" # stick to it while https://github.com/pypa/pip/issues/13046 is not fixed, needs to be also updated in .github/workflows/ci.yml
fi

ZDS_NODE_VERSION=$(cat $ZDSSITE_DIR/.nvmrc)

if [[ $ZDS_NVM_VERSION == "" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion scripts/install_zds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ if ! $(_in "--force-skip-activating" $@) && [[ ( $VIRTUAL_ENV == "" || $(realpat

# Some dependencies (like rust ones) require a recent pip:
print_info "* upgrading pip"
pip install --upgrade pip; exVal=$?
pip install pip==$ZDS_PIP_VERSION; exVal=$?

if [[ $exVal != 0 ]]; then
print_error "!! Failed to upgrade pip"
Expand Down
4 changes: 2 additions & 2 deletions templates/base_content_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@


{% block content_out %}
<article class="content-wrapper" {% block article_schema %}{% endblock %}>
<article class="content-wrapper" itemscope itemtype="http://schema.org/Article">
<header>
{% block headline %}{% endblock %}
</header>
{% block content_page %}
<section class="article-content" {% block article_centent_schema %}{% endblock %}>
<section class="article-content">
{% block content %}{% endblock %}
</section>
{% endblock %}
Expand Down
12 changes: 10 additions & 2 deletions templates/pages/alerts.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ <h1>{% trans "Liste des alertes en cours" %}</h1>
{% elif alert.scope == 'PROFILE' %}
<a href="{{ alert.profile.get_absolute_url }}">{{ alert.text }}</a>
{% else %}
{# This is an alert about a comment on something (any kind of content or forum post) #}
<a href="{{ alert.get_comment_subclass.get_absolute_url }}">{{ alert.text }}</a>
{% endif %}
</td>
Expand Down Expand Up @@ -94,9 +95,16 @@ <h1>{% trans "Liste des alertes récemment résolues" %}</h1>
{% elif alert.scope == 'PROFILE' %}
<a href="{{ alert.profile.get_absolute_url }}">{{ alert.text }}</a>
{% else %}
{# This is an alert about a comment on something (any kind of content or forum post) #}

{% url "member-detail" alert.comment.author.username as url_member_detail %}
<a href="{{ alert.get_comment_subclass.get_absolute_url }}">{{ alert.text }}</a> par
<a href="{{ url_member_detail }}">{{ alert.comment.author.username }}</a>

{% if alert.is_on_comment_on_unpublished_content %}
<em>{{ alert.text }}</em>
{% else %}
<a href="{{ alert.get_comment_subclass.get_absolute_url }}">{{ alert.text }}</a>
{% endif %}
par <a href="{{ url_member_detail }}">{{ alert.comment.author.username }}</a>
{% endif %}
</td>
<td>
Expand Down
6 changes: 0 additions & 6 deletions templates/tutorialv2/base_online.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,3 @@
</a>
</li>
{% endblock %}



{% block article_schema %}
itemscope itemtype="http://schema.org/Article"
{% endblock %}
2 changes: 1 addition & 1 deletion templates/tutorialv2/includes/headline/licence.part.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@

{% crispy form %}
{% elif licence %}
<span class="license">{{ licence }}</span>
<span class="license" itemprop="license">{{ licence }}</span>
{% endif %}
4 changes: 2 additions & 2 deletions templates/tutorialv2/includes/headline/title.part.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<div class="content-title-and-subtitle-group">
<div class="content-title-group">
{% spaceless %}
<h1 class="title">{{ title }}</h1>
<h1 class="title" itemprop="name">{{ title }}</h1>
{% if show_form %}
<a href="#edit-title" class="open-modal edit-button" title="{% trans "Modifier le titre" %}">
<span class="visuallyhidden">{% trans "Modifier le titre" %}</span>
Expand All @@ -48,7 +48,7 @@ <h1 class="title">{{ title }}</h1>
{% endif %}
{% crispy form_subtitle %}
{% else %}
<p class="subtitle">{{ subtitle }}</p>
<h2 class="subtitle" itemprop="description">{{ subtitle }}</h2>
{% endif %}
{% endspaceless %}
</div>
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 @@ -192,7 +192,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
1 change: 1 addition & 0 deletions zds/tutorialv2/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ class Meta:

ip_address = "192.168.3.1"
text = "Bonjour, je me présente, je m'appelle l'homme au texte bidonné"
position = 1

@classmethod
def _generate(cls, create, attrs):
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
62 changes: 59 additions & 3 deletions zds/tutorialv2/tests/tests_views/tests_published.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from zds.mp.models import PrivateTopic, is_privatetopic_unread
from zds.notification.models import ContentReactionAnswerSubscription, Notification
from zds.tutorialv2.tests.factories import (
ContentReactionFactory,
PublishableContentFactory,
ContainerFactory,
ExtractFactory,
Expand All @@ -41,7 +42,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 +52,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 Expand Up @@ -2090,3 +2089,60 @@ def test_save_no_redirect(self):
result = loads(resp.content.decode("utf-8"))
self.assertEqual("ok", result.get("result", None))
self.assertEqual(extract.compute_hash(), result.get("last_hash", None))

def test_remove_unpublished_opinion_with_alerted_comments(self):
"""Test the page showing alerts with an alerted comment on a removed opinion"""

alert_page_url = reverse("pages-alerts")

# 1. Publish opinion
opinion = PublishedContentFactory(type="OPINION", author_list=[self.user_author])

# 2. Comment the opinion
random_user = ProfileFactory().user
comment = ContentReactionFactory(related_content=opinion, author=random_user)

# 3. Create an alert for the comment
self.client.force_login(self.user_staff)
result = self.client.post(
reverse("content:alert-reaction", args=[comment.pk]),
{"signal_text": "No. Try not. Do... or do not. There is no try."},
follow=False,
)
self.assertEqual(result.status_code, 302)

# 4. Display the page listing alerts
resp = self.client.get(alert_page_url)
self.assertEqual(200, resp.status_code)
self.assertContains(resp, comment.get_absolute_url()) # We have a link to the alerted comment
self.assertEqual(len(resp.context["alerts"]), 1)
self.assertEqual(len(resp.context["solved"]), 0)

# 5. Unpublish the opinion
result = self.client.post(
reverse("validation:ignore-opinion", kwargs={"pk": opinion.pk, "slug": opinion.slug}),
{
"operation": "REMOVE_PUB",
},
follow=False,
)
self.assertEqual(result.status_code, 200)

# 6. Display the page listing alerts
resp = self.client.get(alert_page_url)
self.assertEqual(200, resp.status_code)
self.assertNotContains(resp, 'href="?page=1#p') # We don't have wrong links
self.assertEqual(len(resp.context["alerts"]), 0)
self.assertEqual(len(resp.context["solved"]), 1)

# 7. Remove the opinion
self.client.force_login(self.user_author)
result = self.client.post(reverse("content:delete", args=[opinion.pk, opinion.slug]), follow=False)
self.assertEqual(result.status_code, 302)

# 8. Display the page listing alerts
self.client.force_login(self.user_staff)
resp = self.client.get(alert_page_url)
self.assertEqual(200, resp.status_code)
self.assertEqual(len(resp.context["alerts"]), 0)
self.assertEqual(len(resp.context["solved"]), 0)
4 changes: 2 additions & 2 deletions zds/utils/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def parent_category(self, obj):


class AlertAdmin(admin.ModelAdmin):
list_display = ("author", "text", "solved")
list_display = ("author", "scope", "text", "pubdate", "solved", "solved_date")
list_filter = ("scope", "solved")
raw_id_fields = ("author", "comment", "moderator", "privatetopic")
raw_id_fields = ("author", "comment", "moderator", "privatetopic", "profile", "content")
ordering = ("-pubdate",)
search_fields = ("author__username", "text")

Expand Down
Loading

0 comments on commit 60d1f66

Please sign in to comment.