{"action":"created","comment":{"url":"https://api.github.com/repos/zestedesavoir/zds-site/pulls/comments/50125104","id":50125104,"diff_hunk":"@@ -132,23 +113,12 @@ def interventions_topics(user):\n \n @register.filter('interventions_privatetopics')\n def interventions_privatetopics(user):\n-\n-    # Raw query because ORM doesn't seems to allow this kind of \"left outer join\" clauses.\n-    # Parameters = list with 3x the same ID because SQLite backend doesn't allow map parameters.\n-    privatetopics_unread = PrivateTopic.objects.raw(\n-        '''\n-        select distinct t.*\n-        from mp_privatetopic t\n-        left outer join mp_privatetopic_participants p on p.privatetopic_id = t.id\n-        left outer join mp_privatetopicread r on r.user_id = %s and r.privatepost_id = t.last_message_id\n-        where (t.author_id = %s or p.user_id = %s)\n-          and r.id is null\n-        order by t.pubdate desc''',\n-        [user.id, user.id, user.id])\n-\n-    # \"total\" re-do the query, but there is no other way to get the length as __len__ is not available on raw queries.\n-    topics = list(privatetopics_unread)\n-    return {'unread': topics, 'total': len(topics)}\n+    private_topic = ContentType.objects.get_for_model(PrivateTopic)\n+    notifications = list(Notification.objects\n+                         .get_unread_notifications_of(Profile.objects.get(user=user))\n+                         .filter(subscription__content_type=private_topic)","path":"zds/utils/templatetags/interventions.py","position":161,"original_position":161,"commit_id":"2bfb79a2f186c70c0cae57210f6dec45db5b4ebd","original_commit_id":"2bfb79a2f186c70c0cae57210f6dec45db5b4ebd","user":{"login":"firm1","id":6066015,"avatar_url":"https://avatars.githubusercontent.com/u/6066015?v=3","gravatar_id":"","url":"https://api.github.com/users/firm1","html_url":"https://github.com/firm1","followers_url":"https://api.github.com/users/firm1/followers","following_url":"https://api.github.com/users/firm1/following{/other_user}","gists_url":"https://api.github.com/users/firm1/gists{/gist_id}","starred_url":"https://api.github.com/users/firm1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/firm1/subscriptions","organizations_url":"https://api.github.com/users/firm1/orgs","repos_url":"https://api.github.com/users/firm1/repos","events_url":"https://api.github.com/users/firm1/events{/privacy}","received_events_url":"https://api.github.com/users/firm1/received_events","type":"User","site_admin":false},"body":"Ici on est à l'intérieur d'un filter, la condition `subscription__content_type=private_topic` devrait s'écrire `subscription__content_type=\"private_topic\"`","created_at":"2016-01-19T15:24:14Z","updated_at":"2016-01-19T15:24:14Z","html_url":"https://github.com/zestedesavoir/zds-site/pull/3301#discussion_r50125104","pull_request_url":"https://api.github.com/repos/zestedesavoir/zds-site/pulls/3301","_links":{"self":{"href":"https://api.github.com/repos/zestedesavoir/zds-site/pulls/comments/50125104"},"html":{"href":"https://github.com/zestedesavoir/zds-site/pull/3301#discussion_r50125104"},"pull_request":{"href":"https://api.github.com/repos/zestedesavoir/zds-site/pulls/3301"}}},"pull_request":{"url":"https://api.github.com/repos/zestedesavoir/zds-site/pulls/3301","id":56191477,"html_url":"https://github.com/zestedesavoir/zds-site/pull/3301","diff_url":"https://github.com/zestedesavoir/zds-site/pull/3301.diff","patch_url":"https://github.com/zestedesavoir/zds-site/pull/3301.patch","issue_url":"https://api.github.com/repos/zestedesavoir/zds-site/issues/3301","number":3301,"state":"open","locked":false,"title":"ZEP-24 : Centre de notifications","user":{"login":"GerardPaligot","id":1913901,"avatar_url":"https://avatars.githubusercontent.com/u/1913901?v=3","gravatar_id":"","url":"https://api.github.com/users/GerardPaligot","html_url":"https://github.com/GerardPaligot","followers_url":"https://api.github.com/users/GerardPaligot/followers","following_url":"https://api.github.com/users/GerardPaligot/following{/other_user}","gists_url":"https://api.github.com/users/GerardPaligot/gists{/gist_id}","starred_url":"https://api.github.com/users/GerardPaligot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GerardPaligot/subscriptions","organizations_url":"https://api.github.com/users/GerardPaligot/orgs","repos_url":"https://api.github.com/users/GerardPaligot/repos","events_url":"https://api.github.com/users/GerardPaligot/events{/privacy}","received_events_url":"https://api.github.com/users/GerardPaligot/received_events","type":"User","site_admin":false},"body":"| Q                             | R\r\n| ----------------------------- | -------------------------------------------\r\n| Correction de bugs ?          | Non\r\n| Nouvelle Fonctionnalité ?     | Oui\r\n| Tickets (_issues_) concernés  | ZEP-24\r\n\r\nHello,\r\n\r\nVoici venir la première PR pour la ZEP-24 ! Cette première PR vient poser le socle technique et baser l'existant dessus. Aujourd'hui, la ZEP gère les notifications pour les messages d'un sujet, les réactions d'un contenu et les conversations privées.\r\n\r\n# Pour la QA :\r\n\r\n## Important\r\n\r\n- Pensez à faire la migration : `python manage.py migrate`.\r\n- Pensez à faire la migration des anciennes données : `python manage.py migrate_subscriptions`.\r\n- Aucune commande `makemigrations` ne doit être nécessaire !\r\n\r\n## Pour les messages d'un sujet\r\n\r\n- Vérifiez que les notifications sont bien conservées avant la migration vers cette PR.\r\n- S'inscrire et se désinscrire à un sujet doit générer une souscription (regardez dans l'espace admin).\r\n- Recevoir des notifications dans un sujet souscrit.\r\n- Être notifié par mail ou non à un sujet.\r\n- Recevoir un mail et une notification dans un sujet souscrit.\r\n- Perdre la souscription lorsqu'un sujet est déplacé dans un forum non visible.\r\n- Souscription automatique au sujet bêta de tous les auteurs d'un contenu lors de sa mise en bêta.\r\n- Perdre les souscriptions et les notifications à la suppression d'un compte. Pour le vérifier, connectez-vous après avec un compte admin et rendez-vous dans l'espace admin.\r\n- Marqué comme lu une notification sur un message masqué.\r\n\r\n## Pour les réactions d'un contenu\r\n\r\n- Vérifiez que les notifications sont bien conservées avant la migration vers cette PR.\r\n- Poster dans un contenu doit créer une souscription (à vérifier dans l'espace admin).\r\n- Recevoir des notifications dans un contenu souscrit.\r\n- Perdre les souscriptions et les notifications à la suppression d'un compte. Pour le vérifier, connectez-vous après avec un compte admin et rendez-vous dans l'espace admin.\r\n\r\n## Pour les conversations privées\r\n\r\n> **Note :** Ne testez pas avec le MP généré grâce aux fixtures. Cette ressource là est toute pourrie. Limite, supprimez là dès que vous avez installé vos fixtures quand vous êtes sur la branche dev au tout début de votre QA.\r\n\r\n- Vérifiez que les notifications sont bien conservées avant la migration vers cette PR.\r\n- Les notifications sur les messages doivent s'afficher uniquement dans l'espace dédié dans l'en-tête du site.\r\n- La création d'un sujet avec des participants entrainent la création de notifications pour les participants.\r\n- Poster un message dans un message privé génère des notifications pour les autres (participants ou auteur).\r\n- Ajouter un nouveau membre dans une conversation doit générer une notification vers le dernier message d'une conversation privée.\r\n- Quitter une conversation privée doit supprimer la potentielle notification en cours (mais les autres doivent garder leurs notifications actives).\r\n- Si l'utilisateur a paramétré dans son profil qu'il voulait recevoir des mails à chaque réponse, le système doit envoyer des mails pour tous les cas précédemment cités.\r\n- Perdre les souscriptions et les notifications à la suppression d'un compte. Pour le vérifier, connectez-vous après avec un compte admin et rendez-vous dans l'espace admin.","created_at":"2016-01-15T16:37:51Z","updated_at":"2016-01-19T15:24:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"93c2302516f0f0ea1f4c7fa01a5eafb8e62fc46e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/zestedesavoir/zds-site/pulls/3301/commits","review_comments_url":"https://api.github.com/repos/zestedesavoir/zds-site/pulls/3301/comments","review_comment_url":"https://api.github.com/repos/zestedesavoir/zds-site/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zestedesavoir/zds-site/issues/3301/comments","statuses_url":"https://api.github.com/repos/zestedesavoir/zds-site/statuses/2bfb79a2f186c70c0cae57210f6dec45db5b4ebd","head":{"label":"GerardPaligot:new_zep_24","ref":"new_zep_24","sha":"2bfb79a2f186c70c0cae57210f6dec45db5b4ebd","user":{"login":"GerardPaligot","id":1913901,"avatar_url":"https://avatars.githubusercontent.com/u/1913901?v=3","gravatar_id":"","url":"https://api.github.com/users/GerardPaligot","html_url":"https://github.com/GerardPaligot","followers_url":"https://api.github.com/users/GerardPaligot/followers","following_url":"https://api.github.com/users/GerardPaligot/following{/other_user}","gists_url":"https://api.github.com/users/GerardPaligot/gists{/gist_id}","starred_url":"https://api.github.com/users/GerardPaligot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GerardPaligot/subscriptions","organizations_url":"https://api.github.com/users/GerardPaligot/orgs","repos_url":"https://api.github.com/users/GerardPaligot/repos","events_url":"https://api.github.com/users/GerardPaligot/events{/privacy}","received_events_url":"https://api.github.com/users/GerardPaligot/received_events","type":"User","site_admin":false},"repo":{"id":20162464,"name":"zds-site","full_name":"GerardPaligot/zds-site","owner":{"login":"GerardPaligot","id":1913901,"avatar_url":"https://avatars.githubusercontent.com/u/1913901?v=3","gravatar_id":"","url":"https://api.github.com/users/GerardPaligot","html_url":"https://github.com/GerardPaligot","followers_url":"https://api.github.com/users/GerardPaligot/followers","following_url":"https://api.github.com/users/GerardPaligot/following{/other_user}","gists_url":"https://api.github.com/users/GerardPaligot/gists{/gist_id}","starred_url":"https://api.github.com/users/GerardPaligot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GerardPaligot/subscriptions","organizations_url":"https://api.github.com/users/GerardPaligot/orgs","repos_url":"https://api.github.com/users/GerardPaligot/repos","events_url":"https://api.github.com/users/GerardPaligot/events{/privacy}","received_events_url":"https://api.github.com/users/GerardPaligot/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/GerardPaligot/zds-site","description":"Dépot ZDS","fork":true,"url":"https://api.github.com/repos/GerardPaligot/zds-site","forks_url":"https://api.github.com/repos/GerardPaligot/zds-site/forks","keys_url":"https://api.github.com/repos/GerardPaligot/zds-site/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GerardPaligot/zds-site/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GerardPaligot/zds-site/teams","hooks_url":"https://api.github.com/repos/GerardPaligot/zds-site/hooks","issue_events_url":"https://api.github.com/repos/GerardPaligot/zds-site/issues/events{/number}","events_url":"https://api.github.com/repos/GerardPaligot/zds-site/events","assignees_url":"https://api.github.com/repos/GerardPaligot/zds-site/assignees{/user}","branches_url":"https://api.github.com/repos/GerardPaligot/zds-site/branches{/branch}","tags_url":"https://api.github.com/repos/GerardPaligot/zds-site/tags","blobs_url":"https://api.github.com/repos/GerardPaligot/zds-site/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GerardPaligot/zds-site/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GerardPaligot/zds-site/git/refs{/sha}","trees_url":"https://api.github.com/repos/GerardPaligot/zds-site/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GerardPaligot/zds-site/statuses/{sha}","languages_url":"https://api.github.com/repos/GerardPaligot/zds-site/languages","stargazers_url":"https://api.github.com/repos/GerardPaligot/zds-site/stargazers","contributors_url":"https://api.github.com/repos/GerardPaligot/zds-site/contributors","subscribers_url":"https://api.github.com/repos/GerardPaligot/zds-site/subscribers","subscription_url":"https://api.github.com/repos/GerardPaligot/zds-site/subscription","commits_url":"https://api.github.com/repos/GerardPaligot/zds-site/commits{/sha}","git_commits_url":"https://api.github.com/repos/GerardPaligot/zds-site/git/commits{/sha}","comments_url":"https://api.github.com/repos/GerardPaligot/zds-site/comments{/number}","issue_comment_url":"https://api.github.com/repos/GerardPaligot/zds-site/issues/comments{/number}","contents_url":"https://api.github.com/repos/GerardPaligot/zds-site/contents/{+path}","compare_url":"https://api.github.com/repos/GerardPaligot/zds-site/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GerardPaligot/zds-site/merges","archive_url":"https://api.github.com/repos/GerardPaligot/zds-site/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GerardPaligot/zds-site/downloads","issues_url":"https://api.github.com/repos/GerardPaligot/zds-site/issues{/number}","pulls_url":"https://api.github.com/repos/GerardPaligot/zds-site/pulls{/number}","milestones_url":"https://api.github.com/repos/GerardPaligot/zds-site/milestones{/number}","notifications_url":"https://api.github.com/repos/GerardPaligot/zds-site/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GerardPaligot/zds-site/labels{/name}","releases_url":"https://api.github.com/repos/GerardPaligot/zds-site/releases{/id}","created_at":"2014-05-25T18:43:41Z","updated_at":"2016-01-15T15:55:46Z","pushed_at":"2016-01-18T08:44:19Z","git_url":"git://github.com/GerardPaligot/zds-site.git","ssh_url":"git@github.com:GerardPaligot/zds-site.git","clone_url":"https://github.com/GerardPaligot/zds-site.git","svn_url":"https://github.com/GerardPaligot/zds-site","homepage":null,"size":86952,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"zep_24_signal"}},"base":{"label":"zestedesavoir:dev","ref":"dev","sha":"ae4f5c83ef4ef9ed285935fe4bbcc22c23c6d758","user":{"login":"zestedesavoir","id":7406239,"avatar_url":"https://avatars.githubusercontent.com/u/7406239?v=3","gravatar_id":"","url":"https://api.github.com/users/zestedesavoir","html_url":"https://github.com/zestedesavoir","followers_url":"https://api.github.com/users/zestedesavoir/followers","following_url":"https://api.github.com/users/zestedesavoir/following{/other_user}","gists_url":"https://api.github.com/users/zestedesavoir/gists{/gist_id}","starred_url":"https://api.github.com/users/zestedesavoir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zestedesavoir/subscriptions","organizations_url":"https://api.github.com/users/zestedesavoir/orgs","repos_url":"https://api.github.com/users/zestedesavoir/repos","events_url":"https://api.github.com/users/zestedesavoir/events{/privacy}","received_events_url":"https://api.github.com/users/zestedesavoir/received_events","type":"Organization","site_admin":false},"repo":{"id":14778920,"name":"zds-site","full_name":"zestedesavoir/zds-site","owner":{"login":"zestedesavoir","id":7406239,"avatar_url":"https://avatars.githubusercontent.com/u/7406239?v=3","gravatar_id":"","url":"https://api.github.com/users/zestedesavoir","html_url":"https://github.com/zestedesavoir","followers_url":"https://api.github.com/users/zestedesavoir/followers","following_url":"https://api.github.com/users/zestedesavoir/following{/other_user}","gists_url":"https://api.github.com/users/zestedesavoir/gists{/gist_id}","starred_url":"https://api.github.com/users/zestedesavoir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zestedesavoir/subscriptions","organizations_url":"https://api.github.com/users/zestedesavoir/orgs","repos_url":"https://api.github.com/users/zestedesavoir/repos","events_url":"https://api.github.com/users/zestedesavoir/events{/privacy}","received_events_url":"https://api.github.com/users/zestedesavoir/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zestedesavoir/zds-site","description":"Dépot ZDS","fork":false,"url":"https://api.github.com/repos/zestedesavoir/zds-site","forks_url":"https://api.github.com/repos/zestedesavoir/zds-site/forks","keys_url":"https://api.github.com/repos/zestedesavoir/zds-site/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zestedesavoir/zds-site/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zestedesavoir/zds-site/teams","hooks_url":"https://api.github.com/repos/zestedesavoir/zds-site/hooks","issue_events_url":"https://api.github.com/repos/zestedesavoir/zds-site/issues/events{/number}","events_url":"https://api.github.com/repos/zestedesavoir/zds-site/events","assignees_url":"https://api.github.com/repos/zestedesavoir/zds-site/assignees{/user}","branches_url":"https://api.github.com/repos/zestedesavoir/zds-site/branches{/branch}","tags_url":"https://api.github.com/repos/zestedesavoir/zds-site/tags","blobs_url":"https://api.github.com/repos/zestedesavoir/zds-site/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zestedesavoir/zds-site/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zestedesavoir/zds-site/git/refs{/sha}","trees_url":"https://api.github.com/repos/zestedesavoir/zds-site/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zestedesavoir/zds-site/statuses/{sha}","languages_url":"https://api.github.com/repos/zestedesavoir/zds-site/languages","stargazers_url":"https://api.github.com/repos/zestedesavoir/zds-site/stargazers","contributors_url":"https://api.github.com/repos/zestedesavoir/zds-site/contributors","subscribers_url":"https://api.github.com/repos/zestedesavoir/zds-site/subscribers","subscription_url":"https://api.github.com/repos/zestedesavoir/zds-site/subscription","commits_url":"https://api.github.com/repos/zestedesavoir/zds-site/commits{/sha}","git_commits_url":"https://api.github.com/repos/zestedesavoir/zds-site/git/commits{/sha}","comments_url":"https://api.github.com/repos/zestedesavoir/zds-site/comments{/number}","issue_comment_url":"https://api.github.com/repos/zestedesavoir/zds-site/issues/comments{/number}","contents_url":"https://api.github.com/repos/zestedesavoir/zds-site/contents/{+path}","compare_url":"https://api.github.com/repos/zestedesavoir/zds-site/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zestedesavoir/zds-site/merges","archive_url":"https://api.github.com/repos/zestedesavoir/zds-site/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zestedesavoir/zds-site/downloads","issues_url":"https://api.github.com/repos/zestedesavoir/zds-site/issues{/number}","pulls_url":"https://api.github.com/repos/zestedesavoir/zds-site/pulls{/number}","milestones_url":"https://api.github.com/repos/zestedesavoir/zds-site/milestones{/number}","notifications_url":"https://api.github.com/repos/zestedesavoir/zds-site/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zestedesavoir/zds-site/labels{/name}","releases_url":"https://api.github.com/repos/zestedesavoir/zds-site/releases{/id}","created_at":"2013-11-28T14:23:48Z","updated_at":"2016-01-18T08:39:47Z","pushed_at":"2016-01-19T11:09:13Z","git_url":"git://github.com/zestedesavoir/zds-site.git","ssh_url":"git@github.com:zestedesavoir/zds-site.git","clone_url":"https://github.com/zestedesavoir/zds-site.git","svn_url":"https://github.com/zestedesavoir/zds-site","homepage":null,"size":160501,"stargazers_count":129,"watchers_count":129,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":100,"mirror_url":null,"open_issues_count":205,"forks":100,"open_issues":205,"watchers":129,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/zestedesavoir/zds-site/pulls/3301"},"html":{"href":"https://github.com/zestedesavoir/zds-site/pull/3301"},"issue":{"href":"https://api.github.com/repos/zestedesavoir/zds-site/issues/3301"},"comments":{"href":"https://api.github.com/repos/zestedesavoir/zds-site/issues/3301/comments"},"review_comments":{"href":"https://api.github.com/repos/zestedesavoir/zds-site/pulls/3301/comments"},"review_comment":{"href":"https://api.github.com/repos/zestedesavoir/zds-site/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zestedesavoir/zds-site/pulls/3301/commits"},"statuses":{"href":"https://api.github.com/repos/zestedesavoir/zds-site/statuses/2bfb79a2f186c70c0cae57210f6dec45db5b4ebd"}}}}