Commit 5e7b5b9790da01192dee4187fcea7f70a1de66ca
1 parent
534d7f70
Exists in
master
and in
3 other branches
Updating mural notifications
Showing
2 changed files
with
187 additions
and
231 deletions
Show diff stats
amadeus/static/js/socket.js
... | ... | @@ -10,102 +10,38 @@ socket.onmessage = function(e) { |
10 | 10 | content = JSON.parse(e.data); |
11 | 11 | |
12 | 12 | if (content.type == "mural") { |
13 | - if (content.subtype == "create") { | |
14 | - muralNotificationCreate(content); | |
15 | - } else if (content.subtype == "update") { | |
16 | - muralNotificationUpdate(content); | |
17 | - } else if (content.subtype == "delete") { | |
18 | - muralNotificationDelete(content); | |
13 | + if (content.subtype == "post") { | |
14 | + muralNotificationPost(content); | |
15 | + } else if (content.subtype == "mural_update") { | |
16 | + muralNotificationMuralUpdate(content); | |
17 | + } else if (content.subtype == "mural_delete") { | |
18 | + muralNotificationMuralDelete(content); | |
19 | 19 | } else if (content.subtype == "create_comment") { |
20 | 20 | muralNotificationComment(content); |
21 | - } else if (content.subtype == "update_comment") { | |
22 | - muralNotificationCommentUpdate(content); | |
23 | - } else if (content.subtype == "delete_comment") { | |
24 | - muralNotificationCommentDelete(content); | |
25 | - } else if (content.subtype == "create_cat") { | |
26 | - muralNotificationCategory(content); | |
27 | - } else if (content.subtype == "update_cat") { | |
28 | - muralNotificationCategoryUpdate(content); | |
29 | - } else if (content.subtype == "delete_cat") { | |
30 | - muralNotificationCategoryDelete(content); | |
31 | - } else if (content.subtype == "create_sub") { | |
32 | - muralNotificationSubject(content); | |
33 | - } else if (content.subtype == "update_sub") { | |
34 | - muralNotificationSubjectUpdate(content); | |
35 | - } else if (content.subtype == "delete_sub") { | |
36 | - muralNotificationSubjectDelete(content); | |
37 | 21 | } |
38 | 22 | } |
39 | 23 | } |
40 | 24 | // Call onopen directly if socket is already open |
41 | 25 | if (socket.readyState == WebSocket.OPEN) socket.onopen(); |
42 | 26 | |
43 | -function muralNotificationCreate(content) { | |
44 | - if (window.location.pathname == content.pathname) { | |
45 | - $('.posts').prepend(content.complete); | |
46 | - | |
47 | - $('.no-subjects').attr('style', 'display:none'); | |
48 | - } else { | |
49 | - $('.mural_badge').each(function () { | |
50 | - var actual = $(this).text(); | |
51 | - | |
52 | - if (actual != "+99") { | |
53 | - actual = parseInt(actual, 10) + 1; | |
54 | - | |
55 | - if (actual > 99) { | |
56 | - actual = "+99"; | |
57 | - } | |
58 | - | |
59 | - $(this).text(actual); | |
60 | - } | |
61 | - | |
62 | - $(this).show(); | |
63 | - }); | |
64 | - } | |
65 | - | |
66 | - if (("Notification" in window)) { | |
67 | - var options = { | |
68 | - icon: content.user_icon, | |
69 | - body: content.simple | |
70 | - } | |
71 | - | |
72 | - if (Notification.permission === "granted") { | |
73 | - var notification = new Notification("", options); | |
27 | +function muralNotificationPost(content) { | |
28 | + var page = window.location.pathname, | |
29 | + render = (content.paths.indexOf(page) != -1); | |
74 | 30 | |
75 | - setTimeout(notification.close.bind(notification), 3000); | |
76 | - } | |
77 | - } | |
78 | -} | |
79 | - | |
80 | -function muralNotificationUpdate(content) { | |
81 | - if (window.location.pathname == content.pathname) { | |
82 | - var post = $("#post-" + content.post_id); | |
83 | - | |
84 | - if (post.is(":visible")) { | |
85 | - post.before(content.complete); | |
31 | + if (render) { | |
32 | + if (content.accordion) { | |
33 | + var section = $(content.container); | |
86 | 34 | |
87 | - post.remove(); | |
88 | - } | |
89 | - } | |
90 | -} | |
91 | - | |
92 | -function muralNotificationDelete(content) { | |
93 | - if (window.location.pathname == content.pathname) { | |
94 | - var post = $("#post-" + content.post_id); | |
95 | - | |
96 | - if (post.is(":visible")) { | |
97 | - post.remove(); | |
98 | - } | |
99 | - } | |
100 | -} | |
35 | + if (section.is(':visible')) { | |
36 | + section.find('.posts').prepend(content.complete); | |
101 | 37 | |
102 | -function muralNotificationComment(content) { | |
103 | - if (window.location.pathname == content.pathname) { | |
104 | - if ($("#post-" + content.post_id).is(":visible")) { | |
105 | - var section = $("#post-" + content.post_id).find('.comment-section'); | |
38 | + section.find('.no-subjects').hide(); | |
39 | + } | |
40 | + } else { | |
41 | + $(content.container).prepend(content.complete); | |
106 | 42 | |
107 | - section.append(content.complete); | |
108 | - } | |
43 | + $('.no-subjects').attr('style', 'display:none'); | |
44 | + } | |
109 | 45 | } else { |
110 | 46 | $('.mural_badge').each(function () { |
111 | 47 | var actual = $(this).text(); |
... | ... | @@ -127,7 +63,7 @@ function muralNotificationComment(content) { |
127 | 63 | if (("Notification" in window)) { |
128 | 64 | var options = { |
129 | 65 | icon: content.user_icon, |
130 | - body: content.simple | |
66 | + body: content.simple_notify | |
131 | 67 | } |
132 | 68 | |
133 | 69 | if (Notification.permission === "granted") { |
... | ... | @@ -138,98 +74,41 @@ function muralNotificationComment(content) { |
138 | 74 | } |
139 | 75 | } |
140 | 76 | |
141 | -function muralNotificationCommentUpdate(content) { | |
142 | - if (window.location.pathname == content.pathname) { | |
143 | - var comment = $("#comment-" + content.comment_id); | |
144 | - | |
145 | - if (comment.is(":visible")) { | |
146 | - comment.before(content.complete); | |
77 | +function muralNotificationMuralUpdate(content) { | |
78 | + var page = window.location.pathname, | |
79 | + render = (content.paths.indexOf(page) != -1); | |
147 | 80 | |
148 | - comment.remove(); | |
149 | - } | |
150 | - } | |
151 | -} | |
81 | + if (render) { | |
82 | + var mural_item = $(content.container); | |
152 | 83 | |
153 | -function muralNotificationCommentDelete(content) { | |
154 | - if (window.location.pathname == content.pathname) { | |
155 | - var comment = $("#comment-" + content.comment_id); | |
84 | + if (mural_item.is(":visible") || mural_item.is(":hidden")) { | |
85 | + mural_item.before(content.complete); | |
156 | 86 | |
157 | - if (comment.is(":visible")) { | |
158 | - comment.remove(); | |
87 | + mural_item.remove(); | |
159 | 88 | } |
160 | 89 | } |
161 | 90 | } |
162 | 91 | |
163 | -function muralNotificationCategory(content) { | |
164 | - var cat_section = $("#" + content.cat); | |
165 | - | |
166 | - if (window.location.pathname == content.pathname && cat_section.is(':visible')) { | |
167 | - | |
168 | - cat_section.find('.posts').prepend(content.complete); | |
169 | - | |
170 | - cat_section.find('.no-subjects').hide(); | |
171 | - } else { | |
172 | - $('.mural_badge').each(function () { | |
173 | - var actual = $(this).text(); | |
174 | - | |
175 | - if (actual != "+99") { | |
176 | - actual = parseInt(actual, 10) + 1; | |
177 | - | |
178 | - if (actual > 99) { | |
179 | - actual = "+99"; | |
180 | - } | |
181 | - | |
182 | - $(this).text(actual); | |
183 | - } | |
184 | - | |
185 | - $(this).show(); | |
186 | - }); | |
187 | - } | |
188 | - | |
189 | - if (("Notification" in window)) { | |
190 | - var options = { | |
191 | - icon: content.user_icon, | |
192 | - body: content.simple | |
193 | - } | |
194 | - | |
195 | - if (Notification.permission === "granted") { | |
196 | - var notification = new Notification("", options); | |
197 | - | |
198 | - setTimeout(notification.close.bind(notification), 3000); | |
199 | - } | |
200 | - } | |
201 | -} | |
202 | - | |
203 | -function muralNotificationCategoryUpdate(content) { | |
204 | - if (window.location.pathname == content.pathname) { | |
205 | - var post = $("#post-" + content.post_id); | |
92 | +function muralNotificationMuralDelete(content) { | |
93 | + var page = window.location.pathname, | |
94 | + render = (content.paths.indexOf(page) != -1); | |
206 | 95 | |
207 | - if (post.is(":visible") || post.is(":hidden")) { | |
208 | - post.before(content.complete); | |
96 | + if (render) { | |
97 | + var mural_item = $(content.container); | |
209 | 98 | |
210 | - post.remove(); | |
99 | + if (mural_item.is(":visible") || mural_item.is(":hidden")) { | |
100 | + mural_item.remove(); | |
211 | 101 | } |
212 | 102 | } |
213 | 103 | } |
214 | 104 | |
215 | -function muralNotificationCategoryDelete(content) { | |
105 | +function muralNotificationComment(content) { | |
216 | 106 | if (window.location.pathname == content.pathname) { |
217 | - var post = $("#post-" + content.post_id); | |
107 | + if ($("#post-" + content.post_id).is(":visible")) { | |
108 | + var section = $("#post-" + content.post_id).find('.comment-section'); | |
218 | 109 | |
219 | - if (post.is(":visible") || post.is(":hidden")) { | |
220 | - post.remove(); | |
110 | + section.append(content.complete); | |
221 | 111 | } |
222 | - } | |
223 | -} | |
224 | - | |
225 | -function muralNotificationSubject(content) { | |
226 | - var sub_section = $("#" + content.sub); | |
227 | - | |
228 | - if (window.location.pathname == content.pathname && sub_section.is(':visible')) { | |
229 | - | |
230 | - sub_section.find('.posts').prepend(content.complete); | |
231 | - | |
232 | - sub_section.find('.no-subjects').hide(); | |
233 | 112 | } else { |
234 | 113 | $('.mural_badge').each(function () { |
235 | 114 | var actual = $(this).text(); |
... | ... | @@ -260,26 +139,4 @@ function muralNotificationSubject(content) { |
260 | 139 | setTimeout(notification.close.bind(notification), 3000); |
261 | 140 | } |
262 | 141 | } |
263 | -} | |
264 | - | |
265 | -function muralNotificationSubjectUpdate(content) { | |
266 | - if (window.location.pathname == content.pathname) { | |
267 | - var post = $("#post-" + content.post_id); | |
268 | - | |
269 | - if (post.is(":visible") || post.is(":hidden")) { | |
270 | - post.before(content.complete); | |
271 | - | |
272 | - post.remove(); | |
273 | - } | |
274 | - } | |
275 | -} | |
276 | - | |
277 | -function muralNotificationSubjectDelete(content) { | |
278 | - if (window.location.pathname == content.pathname) { | |
279 | - var post = $("#post-" + content.post_id); | |
280 | - | |
281 | - if (post.is(":visible") || post.is(":hidden")) { | |
282 | - post.remove(); | |
283 | - } | |
284 | - } | |
285 | 142 | } |
286 | 143 | \ No newline at end of file | ... | ... |
mural/views.py
... | ... | @@ -119,15 +119,24 @@ class GeneralCreate(LoginRequiredMixin, generic.edit.CreateView): |
119 | 119 | users = User.objects.all().exclude(id = self.request.user.id) |
120 | 120 | entries = [] |
121 | 121 | |
122 | - notify_type = "mural" | |
123 | - user_icon = self.object.user.image_url | |
124 | - _view = render_to_string("mural/_view.html", {"post": self.object}, self.request) | |
125 | - simple_notify = _("%s has made a post in General")%(str(self.object.user)) | |
126 | - pathname = reverse("mural:manage_general") | |
122 | + paths = [reverse("mural:manage_general")] | |
123 | + | |
124 | + notification = { | |
125 | + "type": "mural", | |
126 | + "subtype": "post", | |
127 | + "paths": paths, | |
128 | + "user_icon": self.object.user.image_url, | |
129 | + "simple_notify": _("%s has made a post in General")%(str(self.object.user)), | |
130 | + "complete": render_to_string("mural/_view.html", {"post": self.object}, self.request), | |
131 | + "container": ".post", | |
132 | + "accordion": False | |
133 | + } | |
134 | + | |
135 | + notification = json.dumps(notification) | |
127 | 136 | |
128 | 137 | for user in users: |
129 | 138 | entries.append(MuralVisualizations(viewed = False, user = user, post = self.object)) |
130 | - Group("user-%s" % user.id).send({'text': json.dumps({"type": notify_type, "subtype": "create", "user_icon": user_icon, "pathname": pathname, "simple": simple_notify, "complete": _view})}) | |
139 | + Group("user-%s" % user.id).send({'text': notification}) | |
131 | 140 | |
132 | 141 | MuralVisualizations.objects.bulk_create(entries) |
133 | 142 | |
... | ... | @@ -166,12 +175,20 @@ class GeneralUpdate(LoginRequiredMixin, generic.UpdateView): |
166 | 175 | |
167 | 176 | users = User.objects.all().exclude(id = self.request.user.id) |
168 | 177 | |
169 | - notify_type = "mural" | |
170 | - _view = render_to_string("mural/_view.html", {"post": self.object}, self.request) | |
171 | - pathname = reverse("mural:manage_general") | |
178 | + paths = [reverse("mural:manage_general")] | |
179 | + | |
180 | + notification = { | |
181 | + "type": "mural", | |
182 | + "subtype": "mural_update", | |
183 | + "paths": paths, | |
184 | + "complete": render_to_string("mural/_view.html", {"post": self.object}, self.request), | |
185 | + "container": "#post-" + str(self.object.id), | |
186 | + } | |
187 | + | |
188 | + notification = json.dumps(notification) | |
172 | 189 | |
173 | 190 | for user in users: |
174 | - Group("user-%s" % user.id).send({'text': json.dumps({"type": notify_type, "subtype": "update", "pathname": pathname, "complete": _view, "post_id": self.object.id})}) | |
191 | + Group("user-%s" % user.id).send({'text': notification}) | |
175 | 192 | |
176 | 193 | return super(GeneralUpdate, self).form_valid(form) |
177 | 194 | |
... | ... | @@ -202,12 +219,20 @@ class GeneralDelete(LoginRequiredMixin, generic.DeleteView): |
202 | 219 | |
203 | 220 | def get_success_url(self): |
204 | 221 | users = User.objects.all().exclude(id = self.request.user.id) |
205 | - | |
206 | - notify_type = "mural" | |
207 | - pathname = reverse("mural:manage_general") | |
222 | + | |
223 | + paths = [reverse("mural:manage_general")] | |
224 | + | |
225 | + notification = { | |
226 | + "type": "mural", | |
227 | + "subtype": "mural_delete", | |
228 | + "paths": paths, | |
229 | + "container": "#post-" + str(self.object.id), | |
230 | + } | |
231 | + | |
232 | + notification = json.dumps(notification) | |
208 | 233 | |
209 | 234 | for user in users: |
210 | - Group("user-%s" % user.id).send({'text': json.dumps({"type": notify_type, "subtype": "delete", "pathname": pathname, "post_id": self.object.id})}) | |
235 | + Group("user-%s" % user.id).send({'text': notification}) | |
211 | 236 | |
212 | 237 | return reverse_lazy('mural:deleted_post') |
213 | 238 | |
... | ... | @@ -324,16 +349,25 @@ class CategoryCreate(LoginRequiredMixin, generic.edit.CreateView): |
324 | 349 | |
325 | 350 | users = getSpaceUsers(self.request.user.id, self.object) |
326 | 351 | entries = [] |
352 | + | |
353 | + paths = [reverse("mural:manage_category")] | |
327 | 354 | |
328 | - notify_type = "mural" | |
329 | - user_icon = self.object.user.image_url | |
330 | - _view = render_to_string("mural/_view.html", {"post": self.object}, self.request) | |
331 | - simple_notify = _("%s has made a post in %s")%(str(self.object.user), str(self.object.space)) | |
332 | - pathname = reverse("mural:manage_category") | |
355 | + notification = { | |
356 | + "type": "mural", | |
357 | + "subtype": "post", | |
358 | + "paths": paths, | |
359 | + "user_icon": self.object.user.image_url, | |
360 | + "simple_notify": _("%s has made a post in %s")%(str(self.object.user), str(self.object.space)), | |
361 | + "complete": render_to_string("mural/_view.html", {"post": self.object}, self.request), | |
362 | + "container": "#" + slug, | |
363 | + "accordion": True | |
364 | + } | |
365 | + | |
366 | + notification = json.dumps(notification) | |
333 | 367 | |
334 | 368 | for user in users: |
335 | 369 | entries.append(MuralVisualizations(viewed = False, user = user, post = self.object)) |
336 | - Group("user-%s" % user.id).send({'text': json.dumps({"type": notify_type, "subtype": "create_cat", "user_icon": user_icon, "pathname": pathname, "simple": simple_notify, "complete": _view, "cat": slug})}) | |
370 | + Group("user-%s" % user.id).send({'text': notification}) | |
337 | 371 | |
338 | 372 | MuralVisualizations.objects.bulk_create(entries) |
339 | 373 | |
... | ... | @@ -372,12 +406,20 @@ class CategoryUpdate(LoginRequiredMixin, generic.UpdateView): |
372 | 406 | |
373 | 407 | users = getSpaceUsers(self.request.user.id, self.object) |
374 | 408 | |
375 | - notify_type = "mural" | |
376 | - _view = render_to_string("mural/_view.html", {"post": self.object}, self.request) | |
377 | - pathname = reverse("mural:manage_category") | |
409 | + paths = [reverse("mural:manage_category")] | |
410 | + | |
411 | + notification = { | |
412 | + "type": "mural", | |
413 | + "subtype": "mural_update", | |
414 | + "paths": paths, | |
415 | + "complete": render_to_string("mural/_view.html", {"post": self.object}, self.request), | |
416 | + "container": "#post-" + str(self.object.id), | |
417 | + } | |
418 | + | |
419 | + notification = json.dumps(notification) | |
378 | 420 | |
379 | 421 | for user in users: |
380 | - Group("user-%s" % user.id).send({'text': json.dumps({"type": notify_type, "subtype": "update_cat", "pathname": pathname, "complete": _view, "post_id": self.object.id})}) | |
422 | + Group("user-%s" % user.id).send({'text': notification}) | |
381 | 423 | |
382 | 424 | return super(CategoryUpdate, self).form_valid(form) |
383 | 425 | |
... | ... | @@ -409,11 +451,19 @@ class CategoryDelete(LoginRequiredMixin, generic.DeleteView): |
409 | 451 | def get_success_url(self): |
410 | 452 | users = getSpaceUsers(self.request.user.id, self.object) |
411 | 453 | |
412 | - notify_type = "mural" | |
413 | - pathname = reverse("mural:manage_category") | |
454 | + paths = [reverse("mural:manage_category")] | |
455 | + | |
456 | + notification = { | |
457 | + "type": "mural", | |
458 | + "subtype": "mural_delete", | |
459 | + "paths": paths, | |
460 | + "container": "#post-" + str(self.object.id), | |
461 | + } | |
462 | + | |
463 | + notification = json.dumps(notification) | |
414 | 464 | |
415 | 465 | for user in users: |
416 | - Group("user-%s" % user.id).send({'text': json.dumps({"type": notify_type, "subtype": "delete_cat", "pathname": pathname, "post_id": self.object.id})}) | |
466 | + Group("user-%s" % user.id).send({'text': notification}) | |
417 | 467 | |
418 | 468 | return reverse_lazy('mural:deleted_post') |
419 | 469 | |
... | ... | @@ -542,15 +592,24 @@ class SubjectCreate(LoginRequiredMixin, generic.edit.CreateView): |
542 | 592 | users = getSpaceUsers(self.request.user.id, self.object) |
543 | 593 | entries = [] |
544 | 594 | |
545 | - notify_type = "mural" | |
546 | - user_icon = self.object.user.image_url | |
547 | - _view = render_to_string("mural/_view.html", {"post": self.object}, self.request) | |
548 | - simple_notify = _("%s has made a post in %s")%(str(self.object.user), str(self.object.space)) | |
549 | - pathname = reverse("mural:manage_subject") | |
595 | + paths = [reverse("mural:manage_subject")] | |
596 | + | |
597 | + notification = { | |
598 | + "type": "mural", | |
599 | + "subtype": "post", | |
600 | + "paths": paths, | |
601 | + "user_icon": self.object.user.image_url, | |
602 | + "simple_notify": _("%s has made a post in %s")%(str(self.object.user), str(self.object.space)), | |
603 | + "complete": render_to_string("mural/_view.html", {"post": self.object}, self.request), | |
604 | + "container": "#" + slug, | |
605 | + "accordion": True | |
606 | + } | |
607 | + | |
608 | + notification = json.dumps(notification) | |
550 | 609 | |
551 | 610 | for user in users: |
552 | 611 | entries.append(MuralVisualizations(viewed = False, user = user, post = self.object)) |
553 | - Group("user-%s" % user.id).send({'text': json.dumps({"type": notify_type, "subtype": "create_sub", "user_icon": user_icon, "pathname": pathname, "simple": simple_notify, "complete": _view, "sub": slug})}) | |
612 | + Group("user-%s" % user.id).send({'text': notification}) | |
554 | 613 | |
555 | 614 | MuralVisualizations.objects.bulk_create(entries) |
556 | 615 | |
... | ... | @@ -596,12 +655,20 @@ class SubjectUpdate(LoginRequiredMixin, generic.UpdateView): |
596 | 655 | |
597 | 656 | users = getSpaceUsers(self.request.user.id, self.object) |
598 | 657 | |
599 | - notify_type = "mural" | |
600 | - _view = render_to_string("mural/_view.html", {"post": self.object}, self.request) | |
601 | - pathname = reverse("mural:manage_subject") | |
658 | + paths = [reverse("mural:manage_subject")] | |
659 | + | |
660 | + notification = { | |
661 | + "type": "mural", | |
662 | + "subtype": "mural_update", | |
663 | + "paths": paths, | |
664 | + "complete": render_to_string("mural/_view.html", {"post": self.object}, self.request), | |
665 | + "container": "#post-" + str(self.object.id), | |
666 | + } | |
667 | + | |
668 | + notification = json.dumps(notification) | |
602 | 669 | |
603 | 670 | for user in users: |
604 | - Group("user-%s" % user.id).send({'text': json.dumps({"type": notify_type, "subtype": "update_sub", "pathname": pathname, "complete": _view, "post_id": self.object.id})}) | |
671 | + Group("user-%s" % user.id).send({'text': notification}) | |
605 | 672 | |
606 | 673 | return super(SubjectUpdate, self).form_valid(form) |
607 | 674 | |
... | ... | @@ -633,11 +700,19 @@ class SubjectDelete(LoginRequiredMixin, generic.DeleteView): |
633 | 700 | def get_success_url(self): |
634 | 701 | users = getSpaceUsers(self.request.user.id, self.object) |
635 | 702 | |
636 | - notify_type = "mural" | |
637 | - pathname = reverse("mural:manage_subject") | |
703 | + paths = [reverse("mural:manage_subject")] | |
704 | + | |
705 | + notification = { | |
706 | + "type": "mural", | |
707 | + "subtype": "mural_delete", | |
708 | + "paths": paths, | |
709 | + "container": "#post-" + str(self.object.id), | |
710 | + } | |
711 | + | |
712 | + notification = json.dumps(notification) | |
638 | 713 | |
639 | 714 | for user in users: |
640 | - Group("user-%s" % user.id).send({'text': json.dumps({"type": notify_type, "subtype": "delete_sub", "pathname": pathname, "post_id": self.object.id})}) | |
715 | + Group("user-%s" % user.id).send({'text': notification}) | |
641 | 716 | |
642 | 717 | return reverse_lazy('mural:deleted_post') |
643 | 718 | |
... | ... | @@ -762,12 +837,24 @@ class CommentUpdate(LoginRequiredMixin, generic.UpdateView): |
762 | 837 | |
763 | 838 | users = getSpaceUsers(self.request.user.id, self.object.post) |
764 | 839 | |
765 | - notify_type = "mural" | |
766 | - _view = render_to_string("mural/_view_comment.html", {"comment": self.object}, self.request) | |
767 | - pathname = reverse("mural:manage_general") | |
840 | + paths = [ | |
841 | + reverse("mural:manage_general"), | |
842 | + reverse("mural:manage_category"), | |
843 | + reverse("mural:manage_subject") | |
844 | + ] | |
845 | + | |
846 | + notification = { | |
847 | + "type": "mural", | |
848 | + "subtype": "mural_update", | |
849 | + "paths": paths, | |
850 | + "complete": render_to_string("mural/_view_comment.html", {"comment": self.object}, self.request), | |
851 | + "container": "#comment-" + str(self.object.id), | |
852 | + } | |
853 | + | |
854 | + notification = json.dumps(notification) | |
768 | 855 | |
769 | 856 | for user in users: |
770 | - Group("user-%s" % user.id).send({'text': json.dumps({"type": notify_type, "subtype": "update_comment", "pathname": pathname, "complete": _view, "comment_id": self.object.id})}) | |
857 | + Group("user-%s" % user.id).send({'text': notification}) | |
771 | 858 | |
772 | 859 | return super(CommentUpdate, self).form_valid(form) |
773 | 860 | |
... | ... | @@ -798,12 +885,24 @@ class CommentDelete(LoginRequiredMixin, generic.DeleteView): |
798 | 885 | |
799 | 886 | def get_success_url(self): |
800 | 887 | users = getSpaceUsers(self.request.user.id, self.object.post) |
801 | - | |
802 | - notify_type = "mural" | |
803 | - pathname = reverse("mural:manage_general") | |
888 | + | |
889 | + paths = [ | |
890 | + reverse("mural:manage_general"), | |
891 | + reverse("mural:manage_category"), | |
892 | + reverse("mural:manage_subject") | |
893 | + ] | |
894 | + | |
895 | + notification = { | |
896 | + "type": "mural", | |
897 | + "subtype": "mural_delete", | |
898 | + "paths": paths, | |
899 | + "container": "#comment-" + str(self.object.id), | |
900 | + } | |
901 | + | |
902 | + notification = json.dumps(notification) | |
804 | 903 | |
805 | 904 | for user in users: |
806 | - Group("user-%s" % user.id).send({'text': json.dumps({"type": notify_type, "subtype": "delete_comment", "pathname": pathname, "comment_id": self.object.id})}) | |
905 | + Group("user-%s" % user.id).send({'text': notification}) | |
807 | 906 | |
808 | 907 | return reverse_lazy('mural:deleted_comment') |
809 | 908 | ... | ... |