Skip to content

Commit

Permalink
Ajoute l'inscription dans le journal d'événement
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud-D committed Sep 8, 2024
1 parent 66d18c2 commit 6d760c4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
3 changes: 3 additions & 0 deletions templates/tutorialv2/events/descriptions.part.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
{% endif %}


{% elif event.type == "thumbnail_management" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a modifié la miniature du contenu.

{% elif event.type == "tags_management" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a modifié les tags du contenu.

Expand Down
11 changes: 11 additions & 0 deletions zds/tutorialv2/models/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from zds.tutorialv2.views.goals import EditGoals
from zds.tutorialv2.views.labels import EditLabels
from zds.tutorialv2.views.help import ChangeHelp
from zds.tutorialv2.views.thumbnail import EditThumbnailView
from zds.tutorialv2.views.validations_contents import (
ReserveValidation,
AskValidationForContent,
Expand Down Expand Up @@ -48,6 +49,7 @@
signals.contributors_management: "contributors_management",
signals.beta_management: "beta_management",
signals.validation_management: "validation_management",
signals.thumbnail_management: "thumbnail_management",
signals.tags_management: "tags_management",
signals.canonical_link_management: "canonical_link_management",
signals.goals_management: "goals_management",
Expand Down Expand Up @@ -135,6 +137,15 @@ def record_event_validation_management(sender, performer, signal, content, versi
).save()


@receiver(signals.thumbnail_management, sender=EditThumbnailView)
def record_event_thumbnail_management(sender, performer, signal, content, **_):
Event.objects.create(
performer=performer,
type=types[signal],
content=content,
)


@receiver(signals.tags_management, sender=EditTags)
def record_event_tags_management(sender, performer, signal, content, **_):
Event(
Expand Down
4 changes: 4 additions & 0 deletions zds/tutorialv2/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
# Action is either "request", "cancel", "accept", "reject", "revoke", "reserve" or "unreserve".
validation_management = Signal()

# Thumbnail management
# For the signal below, the arguments "performer" and "content" shall be provided.
thumbnail_management = Signal()

# Tags management
# For the signal below, the arguments "performer" and "content" shall be provided.
tags_management = Signal()
Expand Down
5 changes: 4 additions & 1 deletion zds/tutorialv2/tests/tests_views/tests_editthumbnailview.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from datetime import datetime
from unittest.mock import patch

from django.conf import settings
from django.test import TestCase
Expand Down Expand Up @@ -109,7 +110,8 @@ def setUp(self):

self.client.force_login(self.author.user)

def test_normal(self):
@patch("zds.tutorialv2.signals.thumbnail_management")
def test_normal(self, thumbnail_management):
self.assertEqual(self.content.title, self.content.gallery.title)
start_date = datetime.now()
self.assertTrue(self.content.update_date < start_date)
Expand All @@ -121,3 +123,4 @@ def test_normal(self):

self.assertIsNotNone(self.content.image)
self.assertEqual(self.content.gallery.get_images().count(), 1)
self.assertEqual(thumbnail_management.send.call_count, 1)
4 changes: 4 additions & 0 deletions zds/tutorialv2/views/thumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@

from zds.gallery.mixins import ImageCreateMixin, NotAnImage
from zds.gallery.models import Gallery
from zds.tutorialv2 import signals
from zds.tutorialv2.mixins import SingleContentFormViewMixin
from zds.tutorialv2.models.database import PublishableContent
from zds.utils import get_current_user
from zds.utils.uuslug_wrapper import slugify

from zds.utils.validators import with_svg_validator
Expand Down Expand Up @@ -99,4 +101,6 @@ def form_valid(self, form):

messages.success(self.request, self.success_message)

signals.thumbnail_management.send(sender=self.__class__, performer=get_current_user(), content=publishable)

return redirect(form.previous_page_url)

0 comments on commit 6d760c4

Please sign in to comment.