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

Journal des événements sur un contenu #5940

Merged
merged 23 commits into from
Jun 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c5e71e8
Ajoute un journal d'événements aux contenus
Arnaud-D Oct 4, 2020
a32d027
Ajoute les tests pour le signal author_management
Arnaud-D Oct 3, 2021
328b451
Ajoute les tests pour le signal beta_management
Arnaud-D Oct 3, 2021
8e1a42f
Ajoute les tests pour le signal tags_management
Arnaud-D Oct 3, 2021
7b4fcd4
Modifie les tests de AddContributor pour vérifier l'émission du signa…
Arnaud-D Feb 13, 2022
564a5c7
Modifie les tests de RemoveContributor pour vérifier l'émission du si…
Arnaud-D Feb 13, 2022
11f7cc8
Modifie les tests de ActivateJSFiddleInContent pour vérifier l'émissi…
Arnaud-D Feb 13, 2022
3da60ec
Modifie les tests de PublishOpinion et UnpublishOpinion pour vérifier…
Arnaud-D Feb 13, 2022
38bfd69
Modifie les tests pour vérifier le signal validation_management
Arnaud-D Feb 13, 2022
ca5c42e
Corrige l'orthographe dans des commmentaires
Arnaud-D Feb 13, 2022
c8fb9f3
Corrige un commentaire
Arnaud-D Feb 13, 2022
eb34f6c
Ajoute des tests pour la vue EventsList
Arnaud-D Feb 13, 2022
de184a2
Ajoute un test basique pour la description des événements
Arnaud-D Feb 13, 2022
b65862f
Modifie la gestion de l'affichage pour le faire dans le template
Arnaud-D Feb 13, 2022
7289abe
Modifie les tests pour vérifier le signal contributions_management da…
Arnaud-D Feb 18, 2022
27cfdda
Fix imports factories
Arnaud-D Mar 8, 2022
d674b6e
Fix imports patch
Arnaud-D Mar 8, 2022
6032b23
Ajoute le test des signaux pour RemoveSuggestion
Arnaud-D Mar 9, 2022
5a89081
Fix "desactivate" -> "deactivate"
Arnaud-D Jun 2, 2022
12bbf7e
Ajoute la description brute pour les événements ou actions inconnues.
Arnaud-D Jun 2, 2022
6a0124e
Enlève @receiver en double
Arnaud-D Jun 2, 2022
fdaa207
Fix un oubli dans un test
Arnaud-D Jun 2, 2022
2e640f9
Merge branch 'dev' into historique_événements
Arnaud-D Jun 19, 2022
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
100 changes: 100 additions & 0 deletions templates/tutorialv2/events/descriptions.part.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{% load captureas %}

{% captureas performer_href %}{% url "member-detail" event.performer.username %}{% endcaptureas %}


{% if event.type == "authors_management" %}
{% captureas author_href %}{% url "member-detail" event.author.username %}{% endcaptureas %}
{% if event.action == "add" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a ajouté <a href="{{ author_href }}">{{ event.author }}</a> à la liste des auteurs.
{% elif event.action == "remove" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a supprimé <a href="{{ author_href }}">{{ event.author }}</a> de la liste des auteurs.
{% else %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a effectué une action de type « {{ event.action }} » sur la liste des auteurs.
{% endif %}


{% elif event.type == "contributors_management" %}
{% captureas contributor_href %}{% url "member-detail" event.contributor.username %}{% endcaptureas %}
{% if event.action == "add" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a ajouté <a href="{{ contributor_href }}">{{ event.contributor }}</a> à la liste des contributeurs.
{% elif event.action == "remove" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a supprimé <a href="{{ contributor_href }}">{{ event.contributor }}</a> de la liste des contributeurs.
{% else %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a effectué une action de type « {{ event.action }} » sur la liste des contributeurs.
{% endif %}


{% elif event.type == "beta_management" %}
{% captureas version_href %}{% url "content:view" event.content.pk event.content.slug %}?version={{ event.version }}{% endcaptureas %}
{% if event.action == "activate" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a mis une <a href="{{ version_href }}">version du contenu</a> en bêta.
{% elif event.action == "deactivate" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a désactivé la bêta.
{% else %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a effectué une action de type « {{ event.action }} » sur la bêta.
{% endif %}


{% elif event.type == "validation_management" %}
{% captureas version_href %}{% url "content:view" event.content.pk event.content.slug %}?version={{ event.version }}{% endcaptureas %}
{% if event.action == "request" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a demandé la validation d'une <a href="{{ version_href }}">version du contenu</a>.
{% elif event.action == "cancel" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a annulé la demande de validation du contenu.
{% elif event.action == "accept" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a accepté le contenu pour publication.
{% elif event.action == "reject" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a refusé le contenu pour publication.
{% elif event.action == "revoke" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a dépublié le contenu.
{% elif event.action == "reserve" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a réservé le contenu pour validation.
{% elif event.action == "unreserve" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a annulé la réservation du contenu pour validation.
{% else %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a effectué une action de validation de type « {{ event.action }} ».
{% endif %}


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


{% elif event.type == "suggestions_management" %}
{% if event.action == "add" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a ajouté une suggestion de contenu.
{% elif event.action == "remove" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a supprimé une suggestion de contenu.
{% else %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a effectué une action de type « {{ event.action }} » sur les suggestions de contenu.
{% endif %}


{% elif event.type == "help_management" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a modifié les demandes d'aide.


{% elif event.type == "jsfiddle_management" %}
{% if event.action == "activate" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a activé JSFiddle.
{% elif event.action == "deactivate" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a désactivé JSFiddle.
{% else %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a effectué une action de type « {{ event.action }} » sur la gestion de JS Fiddle.
{% endif %}


{% elif event.type == "opinions_management" %}
{% if event.action == "publish" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a publié le billet.
{% elif event.action == "unpublish" %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a dépublié le billet.
{% else %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a effectué une action de type « {{ event.action }} » sur le billet.
{% endif %}


{% else %}
<a href="{{ performer_href }}">{{ event.performer }}</a> a déclenché un événement de type « {{ event.type }} ».
{% endif %}
74 changes: 74 additions & 0 deletions templates/tutorialv2/events/list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{% extends "tutorialv2/base.html" %}
{% load profile %}
{% load thumbnail %}
{% load date %}
{% load i18n %}


{% block title %}
{% blocktrans with title=content.title %}
Journal des événements de "{{ title }}"
{% endblocktrans %}
{% endblock %}



{% block breadcrumb %}
<li><a href="{{ content.get_absolute_url }}">{{ content.title }}</a></li>
<li>{% trans "Journal des événements" %}</li>
{% endblock %}



{% block headline %}
{% if content.licence %}
<p class="license">
{{ content.licence }}
</p>
{% endif %}

<h1 {% if content.image %}class="illu"{% endif %}>
{% if content.image %}
<img src="{{ content.image.physical.tutorial_illu.url }}" alt="">
{% endif %}
{% blocktrans with title=content.title %}
Journal des événements de "{{ title }}"
{% endblocktrans %}
</h1>

{% if content.description %}
<h2 class="subtitle">
{{ content.description }}
</h2>
{% endif %}

{% include 'tutorialv2/includes/tags_authors.part.html' with content=content online=False %}
{% endblock %}



{% block content %}
{% if events %}
{% include "misc/paginator.html" with position="top" %}

<table class="fullwidth commits-list">
<thead>
<tr>
<th width="20%">{% trans "Date" %}</th>
<th>{% trans "Description" %}</th>
</tr>
</thead>
<tbody>
{% for e in events %}
<tr>
<td>{{ e.date | format_date:True }}</td>
<td>{% include 'tutorialv2/events/descriptions.part.html' with event=e %}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% include "misc/paginator.html" with position="bottom" %}
{% else %}
<p>{% trans "Aucun événement n'a été enregistré pour ce contenu." %}</p>
{% endif %}
{% endblock %}
8 changes: 8 additions & 0 deletions templates/tutorialv2/view/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,14 @@ <h2>
</li>
{# END HISTORY #}

{# EVENTS #}
<li>
<a href="{% url "content:events" content.pk %}" class="ico-after history blue">
{% trans "Journal des événements" %}
</a>
</li>
{# END EVENTS #}

{# VALIDATION OR PUBLICATION (NO VALIDATION BEFORE) #}
{% if content.requires_validation %}
{# Validation (require validation before publication) #}
Expand Down
1 change: 1 addition & 0 deletions zds/notification/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default_app_config = "zds.notification.apps.NotificationConfig"
8 changes: 8 additions & 0 deletions zds/notification/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.apps import AppConfig


class NotificationConfig(AppConfig):
name = "zds.notification"

def ready(self):
from . import receivers # noqa
5 changes: 0 additions & 5 deletions zds/notification/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,3 @@ class Meta:

def __str__(self):
return f'<Sujet "{self.topic.title}" suivi par {self.user.username}>'


# used to fix Django 1.9 Warning
# https://github.com/zestedesavoir/zds-site/issues/3451
from . import receivers # noqa
2 changes: 2 additions & 0 deletions zds/tutorialv2/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
PublicationEvent,
ContentContributionRole,
)
from zds.tutorialv2.models.events import Event


class PublishableContentAdmin(admin.ModelAdmin):
Expand Down Expand Up @@ -118,3 +119,4 @@ class ContentReviewTypeAdmin(admin.ModelAdmin):
admin.site.register(ContentRead, ContentReadAdmin)
admin.site.register(PublicationEvent, PublicationEventAdmin)
admin.site.register(ContentContributionRole, ContentReviewTypeAdmin)
admin.site.register(Event)
58 changes: 58 additions & 0 deletions zds/tutorialv2/migrations/0032_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Generated by Django 2.2.24 on 2021-10-03 17:48

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("tutorialv2", "0031_source_is_url"),
]

operations = [
migrations.CreateModel(
name="Event",
fields=[
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("date", models.DateTimeField(auto_now_add=True)),
("type", models.CharField(max_length=100)),
("action", models.CharField(max_length=100)),
("version", models.CharField(max_length=80, null=True)),
(
"author",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="event_author",
to=settings.AUTH_USER_MODEL,
),
),
(
"content",
models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="tutorialv2.PublishableContent"),
),
(
"contributor",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="event_contributor",
to=settings.AUTH_USER_MODEL,
),
),
(
"performer",
models.ForeignKey(
null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
),
),
],
options={
"verbose_name": "Événement sur un contenu",
"verbose_name_plural": "Événements sur un contenu",
},
),
]
Loading