Skip to content

Commit

Permalink
Merge pull request #3301 from GerardPaligot/new_zep_24
Browse files Browse the repository at this point in the history
ZEP-24 : Centre de notifications
  • Loading branch information
Laville Augustin committed Mar 5, 2016
2 parents 2e8399a + 0161572 commit 9326809
Show file tree
Hide file tree
Showing 58 changed files with 2,110 additions and 528 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -10,7 +10,7 @@ env:
global:
- secure: "azmDZZQZzf88zpbkYpLpxI66vpEVyv+kniW0QdWAt4qlys8P5OcO3VJBR5YT85vlvnjN9b6raWQAL1ymee0WmVdTmzXed8XjZv7t9QXVw7pfezxMKlEftVp/4Cu4wtvbew0ViZXNWV2hNXHzEqlhgnoIOq94i0UzZ7grMrI0xm0="
matrix:
- TEST_APP="-e back_mysql -- zds.member zds.mp zds.utils zds.forum zds.gallery zds.pages zds.search zds.featured"
- TEST_APP="-e back_mysql -- zds.member zds.mp zds.utils zds.forum zds.gallery zds.pages zds.search zds.featured zds.notification"
- TEST_APP="-e back_mysql -- zds.tutorialv2"
- TEST_APP="-e front"

Expand Down
4 changes: 1 addition & 3 deletions doc/source/back-end/forum.rst
Expand Up @@ -86,7 +86,7 @@ Nous permettons à nos membres de "suivre" un sujet directement sur le site. "Su
Dès lors vous pourrez par un simple clic vous rendre au dernier message non lu.

Pour repérer qu'un message est lu ou pas, nous utilisons côté backend la classe ``zds.forum.models.TopicRead`` qui retient la date de dernière lecture du topic.
De la même manière nous utilisons la classe ``zds.forum.models.TopicFollowed`` pour retenir le fait que vous suivez ou non un sujet.
De la même manière nous utilisons la classe ``zds.notification.models.TopicAnswerSubscription`` pour retenir le fait que vous suivez ou non un sujet.

Pour suivre un sujet, deux méthodes sont envisageables :

Expand All @@ -97,5 +97,3 @@ Pour cesser de suivre un sujet, et ne plus être notifier de son activité, vous

- Vous rendre sur le topic et cliquer sur "Ne plus suivre" en haut de la sidebar.
- Vous rendre sur n'importe quelle page du forum, survoler le titre du sujet et cliquer sur la croix qui apparaît alors.

En effectuant ces actions vous cessez de suivre le sujet, l'instance de TopicFollowed qui était associée à votre suivi est supprimée définitivement. Cela a pour effet que vous pourrez à nouveau suivre le sujet dans le futur si vous le désirez.
2 changes: 1 addition & 1 deletion doc/source/front-end/template-tags.rst
Expand Up @@ -233,7 +233,7 @@ où ``period`` est un nombre au format attendu par ``humane_delta`` (entre 1 et
``interventions_topics``
------------------------

Ce filtre récupère la liste des messages du forum ainsi que des commentaires de tutoriels et articles qui sont non-lus:
Ce filtre récupère la liste des notifications non lues sur des modèles notifiables excluant les messages privés:

.. sourcecode:: html

Expand Down
57 changes: 24 additions & 33 deletions templates/base.html
Expand Up @@ -279,46 +279,39 @@
{# MESSAGERIE PRIVEE #}
<div>
{% with topics=user|interventions_privatetopics %}
{% with unread_topics=topics.unread %}
{% with total_topics=topics.total %}
{% with notifications=topics.notifications %}
{% with total_notifications=topics.total %}
<a href="{% url "mp-list" %}" class="ico-link">
{% if total_topics > 0 %}
<span class="notif-count">{{ total_topics }}</span>
{% if total_notifications > 0 %}
<span class="notif-count">{{ total_notifications }}</span>
{% endif %}
<span class="notif-text ico ico-messages">{% trans "Messagerie privée" %}</span>
</a>

<div class="dropdown">
<span class="dropdown-title">{% trans "Messagerie privée" %}</span>
<ul class="dropdown-list">
{% for topic in unread_topics %}
{% with last_answer=topic.get_last_answer %}
<li>
{% if last_answer == None %}
{% set topic.last_read_post as last_answer %}
{% endif %}
<a href="{{ topic.last_read_post.get_absolute_url }}">
{% with p=last_answer.author.profile %}
<img src="{{ p.get_avatar_url|remove_url_protocole }}" alt="" class="avatar">
{% endwith %}
<span class="username">{{ last_answer.author.username }}</span>
<span class="date">{{ last_answer.pubdate|format_date:True|capfirst }}</span>
<span class="topic">{{ topic.title }}</span>
</a>
</li>
{% endwith %}
{% for notification in notifications %}
<li>
<a href="{{ notification.url }}">
<img src="{{ notification.sender.profile.get_avatar_url|remove_url_protocole }}" alt="" class="avatar">
<span class="username">{{ notification.sender.username }}</span>
<span class="date">{{ notification.pubdate|format_date:True|capfirst }}</span>
<span class="topic">{{ notification.title }}</span>
</a>
</li>
{% endfor %}

{% if total_topics == 0 %}
<li class="dropdown-empty-message">
{% trans "Aucun nouveau message" %}
</li>
{% endif %}
</ul>
<a href="{% url "mp-list" %}" class="dropdown-link-all">
{% trans "Tous les messages" %}
</a>
</div>
{% if total_notifications == 0 %}
<li class="dropdown-empty-message">
{% trans "Aucune nouvelle notification" %}
</li>
{% endif %}
</ul>
<a href="{% url "mp-list" %}" class="dropdown-link-all">
{% trans "Toutes les notifications" %}
</a>
</div>
{% endwith %}
{% endwith %}
{% endwith %}
Expand All @@ -341,9 +334,7 @@
{% for first_unread in unread_posts %}
<li>
<a href="{{ first_unread.url }}">
{% with p=first_unread.author.profile %}
<img src="{{ p.get_avatar_url|remove_url_protocole }}" alt="" class="avatar">
{% endwith %}
<img src="{{ first_unread.author.profile.get_avatar_url|remove_url_protocole }}" alt="" class="avatar">
<span class="username">{{ first_unread.author.username }}</span>
<span class="date">{{ first_unread.pubdate|format_date:True|capfirst }}</span>
<span class="topic">{{ first_unread.title }}</span>
Expand Down
@@ -0,0 +1,17 @@
{% extends "email/base_from_staff.html" %}

{% load i18n %}

{% block content_from_staff %}
<p>
{% blocktrans %}
<strong>{{ author }}</strong> vous a envoyé un message privé sur {{ site_name }}.
{% endblocktrans %}
</p>

<p>
{% blocktrans %}
Pour le lire, <a href="{{ url }}">cliquez ici</a>.
{% endblocktrans %}
</p>
{% endblock %}
12 changes: 12 additions & 0 deletions templates/email/notification/private_topic_answer_subscription.txt
@@ -0,0 +1,12 @@
{% extends "email/base_from_staff.txt" %}
{% load i18n %}

{% block content_from_staff %}
{% blocktrans %}
{{ author }} vous a envoyé un message privé sur {{ site_name }}.
{% endblocktrans %}

{% blocktrans %}
Pour le lire, cliquez ou recopiez l'url suivante : {{ url }}
{% endblocktrans %}
{% endblock %}
17 changes: 17 additions & 0 deletions templates/email/notification/topic_answer_subscription.html
@@ -0,0 +1,17 @@
{% extends "email/base_from_staff.html" %}

{% load i18n %}

{% block content_from_staff %}
<p>
{% blocktrans %}
<strong>{{ author }}</strong> a répondu au sujet « {{ title }} » que vous suivez sur {{ site_name }}.
{% endblocktrans %}
</p>

<p>
{% blocktrans %}
Pour le lire, <a href="{{ url }}">cliquez ici</a>.
{% endblocktrans %}
</p>
{% endblock %}
12 changes: 12 additions & 0 deletions templates/email/notification/topic_answer_subscription.txt
@@ -0,0 +1,12 @@
{% extends "email/base_from_staff.txt" %}
{% load i18n %}

{% block content_from_staff %}
{% blocktrans %}
{{ author }} a répondu au sujet « {{ title }} » que vous suivez sur {{ site_name }}.
{% endblocktrans %}

{% blocktrans %}
Pour le lire, cliquez ou recopiez l'url suivante : {{ url }}
{% endblocktrans %}
{% endblock %}
18 changes: 11 additions & 7 deletions templates/forum/topic/index.html
Expand Up @@ -5,7 +5,7 @@
{% load profile %}
{% load crispy_forms_tags %}
{% load i18n %}

{% load interventions %}


{% block title %}
Expand Down Expand Up @@ -175,6 +175,7 @@
{% endif %}

<li>
{% with topic_is_followed=topic|is_followed %}
<form action="{% url 'topic-edit' %}" method="post">
<input type="hidden" name="topic" value="{{ topic.pk }}">
<input type="hidden" name="nb" value="{{ nb }}">
Expand All @@ -183,25 +184,27 @@
{% csrf_token %}

<button
class="follow ico-after star {% if topic.is_followed %}yellow{% else %}blue{% endif %}"
class="follow ico-after star {% if topic_is_followed %}yellow{% else %}blue{% endif %}"
type="submit" data-ajax-input="follow-topic"
data-content-on-click="
{% if topic.is_followed %}
{% if topic_is_followed %}
{% trans "Suivre ce sujet" %}
{% else %}
{% trans "Ne plus suivre ce sujet" %}
{% endif %}
"
>
{% if topic.is_followed %}
{% if topic_is_followed %}
{% trans "Ne plus suivre ce sujet" %}
{% else %}
{% trans "Suivre ce sujet" %}
{% endif %}
</button>
</form>
{% endwith %}
</li>
<li>
{% with topic_is_email_followed=topic|is_email_followed %}
<form action="{% url 'topic-edit' %}" method="post">
<input type="hidden" name="topic" value="{{ topic.pk }}">
<input type="hidden" name="nb" value="{{ nb }}">
Expand All @@ -210,23 +213,24 @@
{% csrf_token %}

<button
class="email ico-after {% if not topic.is_email_followed %}blue{% endif %}"
class="email ico-after {% if not topic_is_email_followed %}blue{% endif %}"
type="submit" data-ajax-input="follow-topic-by-email"
data-content-on-click="
{% if topic.is_email_followed %}
{% if topic_is_email_followed %}
{% trans "Être notifié par courriel" %}
{% else %}
{% trans "Ne plus être notifié par courriel" %}
{% endif %}
"
>
{% if topic.is_email_followed %}
{% if topic_is_email_followed %}
{% trans "Ne plus être notifié par courriel" %}
{% else %}
{% trans "Être notifié par courriel" %}
{% endif %}
</button>
</form>
{% endwith %}
</li>
{% endblock %}

Expand Down
32 changes: 32 additions & 0 deletions templates/tutorialv2/view/content_online.html
Expand Up @@ -6,6 +6,7 @@
{% load thumbnail %}
{% load i18n %}
{% load crispy_forms_tags %}
{% load interventions %}


{% block title %}
Expand Down Expand Up @@ -104,6 +105,37 @@ <h2 class="subtitle" itemprop="description">

{% endblock %}

{% block sidebar_actions %}

<li>
{% with content_is_followed=object|is_content_followed %}
<form action="{% url "content:follow" object.pk %}" method="post">
<input type="hidden" name="follow" value="1">
{% csrf_token %}

<button
class="follow ico-after star {% if content_is_followed %}yellow{% else %}blue{% endif %}"
type="submit" data-ajax-input="follow-topic"
data-content-on-click="
{% if content_is_followed %}
{% trans "Suivre ce contenu" %}
{% else %}
{% trans "Ne plus suivre ce contenu" %}
{% endif %}
"
>
{% if content_is_followed %}
{% trans "Ne plus suivre ce contenu" %}
{% else %}
{% trans "Suivre ce contenu" %}
{% endif %}
</button>
</form>
{% endwith %}
</li>

{% endblock %}

{% block sidebar_blocks %}
{% include "tutorialv2/includes/summary.part.html" with online=True %}

Expand Down
9 changes: 9 additions & 0 deletions update.md
Expand Up @@ -470,3 +470,12 @@ REST_FRAMEWORK
--------------

Vérifier qu'on ne surcharge pas la variable `REST_FRAMEWORK` dans le `settings_prod.py`. Si c'est le cas l'adapter en fonction du `settings.py`.

Actions à faire pour mettre en prod la version 18
=================================================

Notifications
-------------

1. Lors de l'application des migrations `python manage.py migrate`, Django va vous demander s'il doit supprimer la table topicfollowed. Renseignez oui.
2. Exécuter la commande `python manage.py migrate_subscriptions` pour migrer les anciennes notifications vers les nouvelles.
4 changes: 1 addition & 3 deletions zds/forum/admin.py
Expand Up @@ -2,13 +2,11 @@

from django.contrib import admin

from .models import Category, Forum, Topic, Post, TopicRead, TopicFollowed

from zds.forum.models import Category, Forum, Topic, Post, TopicRead

admin.site.register(Category)
admin.site.register(Forum)
# TODO Topic admin is broken (load an admin Topic page implies to load ALL Members and Posts!)
admin.site.register(Topic)
admin.site.register(Post)
admin.site.register(TopicRead)
admin.site.register(TopicFollowed)

0 comments on commit 9326809

Please sign in to comment.