diff --git a/templates/tutorialv2/includes/tags_authors.part.html b/templates/tutorialv2/includes/tags_authors.part.html
index 887b1fd0d0..ce34108968 100644
--- a/templates/tutorialv2/includes/tags_authors.part.html
+++ b/templates/tutorialv2/includes/tags_authors.part.html
@@ -39,8 +39,8 @@
{% with count_contributions=contributions|length %}
{% if count_contributions > 0 %}
- {% trans "Ce contenu a bénéficié des apports de" %}
- {{ count_contributions }} {% trans "contributeur" %}{{ count_contributions|pluralize }}
+ {% trans "Cette publication a bénéficié des apports de" %}
+ {{ count_contributions }} {% trans "contributeur" %}{{ count_contributions|pluralize }}.
diff --git a/templates/tutorialv2/messages/add_contribution_pm.md b/templates/tutorialv2/messages/add_contribution_pm.md
index 01099e3747..3bd75581c2 100644
--- a/templates/tutorialv2/messages/add_contribution_pm.md
+++ b/templates/tutorialv2/messages/add_contribution_pm.md
@@ -1,9 +1,9 @@
{% load i18n %}
-{% blocktrans with title=content.title|safe type=type|safe user=user|safe %}
+{% blocktrans with title=content.title|safe user=user|safe %}
Bonjour {{ user }},
-Vous avez été ajouté à la liste des contributeurs {{type}} « {{ title }} », en tant que {{role}}.
+Vous avez été ajouté à la liste des contributeurs de la publication « {{ title }} », en tant que {{ role }}.
Merci pour votre participation !
{% endblocktrans %}
diff --git a/templates/tutorialv2/view/content.html b/templates/tutorialv2/view/content.html
index 25e133d74a..e8b271ba03 100644
--- a/templates/tutorialv2/view/content.html
+++ b/templates/tutorialv2/view/content.html
@@ -349,12 +349,12 @@
{% endif %}
{# END AUTHORS #}
{# CONTRIBUTORS #}
- {% if can_add_something and formAddReviewer %}
+ {% if can_add_something %}
{% trans "Ajouter un contributeur" %}
- {% crispy formAddReviewer %}
+ {% crispy form_add_contributor %}
diff --git a/zds/tutorialv2/tests/tests_views/tests_addcontributor.py b/zds/tutorialv2/tests/tests_views/tests_addcontributor.py
index 944e90334f..bc15128d3f 100644
--- a/zds/tutorialv2/tests/tests_views/tests_addcontributor.py
+++ b/zds/tutorialv2/tests/tests_views/tests_addcontributor.py
@@ -61,26 +61,14 @@ def test_authenticated_author(self):
response = self.client.post(self.form_url, self.form_data)
self.assertRedirects(response, self.content_url)
- def test_authenticated_staff_tutorial(self):
+ def test_authenticated_staff(self):
self.client.force_login(self.staff)
- self.content.type = "TUTORIAL"
- self.content.save()
- response = self.client.post(self.form_url, self.form_data)
- self.assertRedirects(response, self.content_url)
-
- def test_authenticated_staff_article(self):
- self.client.force_login(self.staff)
- self.content.type = "ARTICLE"
- self.content.save()
- response = self.client.post(self.form_url, self.form_data)
- self.assertRedirects(response, self.content_url)
-
- def test_authenticated_staff_opinion(self):
- self.client.force_login(self.staff)
- self.content.type = "OPINION"
- self.content.save()
- response = self.client.post(self.form_url, self.form_data)
- self.assertEqual(response.status_code, 403)
+ types = ["TUTORIAL", "ARTICLE", "OPINION"]
+ for type in types:
+ self.content.type = type
+ self.content.save()
+ response = self.client.post(self.form_url, self.form_data)
+ self.assertRedirects(response, self.content_url)
class AddContributorWorkflowTests(TutorialTestMixin, TestCase):
diff --git a/zds/tutorialv2/tests/tests_views/tests_removecontributor.py b/zds/tutorialv2/tests/tests_views/tests_removecontributor.py
index 700775af12..02b7421695 100644
--- a/zds/tutorialv2/tests/tests_views/tests_removecontributor.py
+++ b/zds/tutorialv2/tests/tests_views/tests_removecontributor.py
@@ -61,25 +61,20 @@ def test_authenticated_author(self):
self.assertRedirects(response, self.content_url)
def test_authenticated_staff_tutorial(self):
- self.client.force_login(self.staff)
- self.content.type = "TUTORIAL"
- self.content.save()
- response = self.client.post(self.form_url, self.form_data)
- self.assertRedirects(response, self.content_url)
+ self.perform_test_authenticated_staff("TUTORIAL")
def test_authenticated_staff_article(self):
- self.client.force_login(self.staff)
- self.content.type = "ARTICLE"
- self.content.save()
- response = self.client.post(self.form_url, self.form_data)
- self.assertRedirects(response, self.content_url)
+ self.perform_test_authenticated_staff("ARTICLE")
def test_authenticated_staff_opinion(self):
+ self.perform_test_authenticated_staff("OPINION")
+
+ def perform_test_authenticated_staff(self, type):
self.client.force_login(self.staff)
- self.content.type = "OPINION"
+ self.content.type = type
self.content.save()
response = self.client.post(self.form_url, self.form_data)
- self.assertEqual(response.status_code, 403)
+ self.assertRedirects(response, self.content_url)
class RemoveContributorWorkflowTests(TutorialTestMixin, TestCase):
diff --git a/zds/tutorialv2/views/contents.py b/zds/tutorialv2/views/contents.py
index 87fc9b17b3..f5aefdf37a 100644
--- a/zds/tutorialv2/views/contents.py
+++ b/zds/tutorialv2/views/contents.py
@@ -203,11 +203,11 @@ def get_context_data(self, **kwargs):
context["gallery"] = self.object.gallery
context["public_content_object"] = self.public_content_object
+ context["form_add_contributor"] = ContributionForm(content=self.object)
+ context["contributions"] = ContentContribution.objects.filter(content=self.object).order_by(
+ "contribution_role__position"
+ )
if self.object.type.lower() != "opinion":
- context["formAddReviewer"] = ContributionForm(content=self.object)
- context["contributions"] = ContentContribution.objects.filter(content=self.object).order_by(
- "contribution_role__position"
- )
context["content_suggestions"] = ContentSuggestion.objects.filter(publication=self.object)
excluded_for_search = [str(x.suggestion.pk) for x in context["content_suggestions"]]
excluded_for_search.append(str(self.object.pk))
diff --git a/zds/tutorialv2/views/contributors.py b/zds/tutorialv2/views/contributors.py
index b57579f708..6cfb43bc38 100644
--- a/zds/tutorialv2/views/contributors.py
+++ b/zds/tutorialv2/views/contributors.py
@@ -40,19 +40,11 @@ def get(self, request, *args, **kwargs):
return redirect(url, self.request.user)
def form_valid(self, form):
-
- _type = _("à l'article")
-
- if self.object.is_tutorial:
- _type = _("au tutoriel")
- elif self.object.is_opinion:
- raise PermissionDenied
-
bot = get_bot_account()
all_authors_pk = [author.pk for author in self.object.authors.all()]
user = form.cleaned_data["user"]
if user.pk in all_authors_pk:
- messages.error(self.request, _("Un auteur ne peut pas être désigné comme contributeur"))
+ messages.error(self.request, _("Un auteur ne peut pas être désigné comme contributeur."))
return redirect(self.object.get_absolute_url())
else:
contribution_role = form.cleaned_data.get("contribution_role")
@@ -64,7 +56,7 @@ def form_valid(self, form):
self.request,
_(
"Ce membre fait déjà partie des "
- 'contributeurs {} avec pour rôle "{}"'.format(_type, contribution_role.title)
+ 'contributeurs à la publication avec pour rôle "{}"'.format(contribution_role.title)
),
)
return redirect(self.object.get_absolute_url())
@@ -77,13 +69,12 @@ def form_valid(self, form):
send_mp(
bot,
[user],
- format_lazy("{} {}", _("Contribution"), _type),
+ _("Contribution à la publication"),
self.versioned_object.title,
render_to_string(
"tutorialv2/messages/add_contribution_pm.md",
{
"content": self.object,
- "type": _type,
"url": self.object.get_absolute_url(),
"index": url_index,
"user": user.username,
@@ -114,12 +105,6 @@ class RemoveContributorFromContent(LoggedWithReadWriteHability, SingleContentFor
authorized_for_staff = True
def form_valid(self, form):
- _type = _("cet article")
- if self.object.is_tutorial:
- _type = _("ce tutoriel")
- elif self.object.is_opinion:
- raise PermissionDenied
-
contribution = get_object_or_404(ContentContribution, pk=form.cleaned_data["pk_contribution"])
user = contribution.user
contribution.delete()
@@ -127,7 +112,8 @@ def form_valid(self, form):
sender=self.__class__, content=self.object, performer=self.request.user, contributor=user, action="remove"
)
messages.success(
- self.request, _("Vous avez enlevé {} de la liste des contributeurs de {}.").format(user.username, _type)
+ self.request,
+ _("Vous avez enlevé {} de la liste des contributeurs de cette publication.").format(user.username),
)
self.success_url = self.object.get_absolute_url()