Commit d15fce459677b7afd59239d35ede0651dd810f40
1 parent
4555e862
Exists in
master
and in
3 other branches
Adjusting post and comment propagation to specific subject/resource pages
Showing
3 changed files
with
53 additions
and
9 deletions
Show diff stats
amadeus/static/js/socket.js
@@ -26,9 +26,10 @@ if (socket.readyState == WebSocket.OPEN) socket.onopen(); | @@ -26,9 +26,10 @@ if (socket.readyState == WebSocket.OPEN) socket.onopen(); | ||
26 | 26 | ||
27 | function muralNotificationPost(content) { | 27 | function muralNotificationPost(content) { |
28 | var page = window.location.pathname, | 28 | var page = window.location.pathname, |
29 | - render = (content.paths.indexOf(page) != -1); | 29 | + render = (content.paths.indexOf(page) != -1), |
30 | + is_resource = (page.indexOf("resource") != -1); | ||
30 | 31 | ||
31 | - if ((render && page.indexOf(content.post_type) != -1) || (render && content.post_type == "general")) { | 32 | + if ((render && page.indexOf(content.post_type) != -1) || (render && content.post_type == "general") || (render && is_resource)) { |
32 | if (content.accordion) { | 33 | if (content.accordion) { |
33 | var section = $(content.container); | 34 | var section = $(content.container); |
34 | 35 | ||
@@ -136,6 +137,7 @@ function muralNotificationMuralDelete(content) { | @@ -136,6 +137,7 @@ function muralNotificationMuralDelete(content) { | ||
136 | function muralNotificationComment(content) { | 137 | function muralNotificationComment(content) { |
137 | var page = window.location.pathname, | 138 | var page = window.location.pathname, |
138 | render = (content.paths.indexOf(page) != -1), | 139 | render = (content.paths.indexOf(page) != -1), |
140 | + is_resource = (page.indexOf("resource") != -1), | ||
139 | checker = "general"; | 141 | checker = "general"; |
140 | 142 | ||
141 | switch (content.post_type) { | 143 | switch (content.post_type) { |
@@ -147,7 +149,7 @@ function muralNotificationComment(content) { | @@ -147,7 +149,7 @@ function muralNotificationComment(content) { | ||
147 | break; | 149 | break; |
148 | } | 150 | } |
149 | 151 | ||
150 | - if ((render && page.indexOf(checker) != -1) || (render && content.post_type == "generalpost" && page.indexOf("categories") == -1 && page.indexOf("subjects") == -1)) { | 152 | + if ((render && page.indexOf(checker) != -1) || (render && content.post_type == "generalpost" && page.indexOf("categories") == -1 && page.indexOf("subjects") == -1) || (render && is_resource)) { |
151 | var section = $(content.container); | 153 | var section = $(content.container); |
152 | 154 | ||
153 | if (section.is(":visible") || section.is(":hidden")) { | 155 | if (section.is(":visible") || section.is(":hidden")) { |
mural/templates/mural/resource_view.html
@@ -17,10 +17,10 @@ | @@ -17,10 +17,10 @@ | ||
17 | {% subject_permissions request.user subject as has_subject_permissions %} | 17 | {% subject_permissions request.user subject as has_subject_permissions %} |
18 | 18 | ||
19 | {% if subject.visible %} | 19 | {% if subject.visible %} |
20 | - <div class="panel panel-info topic-panel"> | 20 | + <div class="panel panel-info topic-panel" id="subject_{{subject.slug}}"> |
21 | <div class="panel-heading"> | 21 | <div class="panel-heading"> |
22 | {% elif has_subject_permissions %} | 22 | {% elif has_subject_permissions %} |
23 | - <div class="panel panel-info topic-panel-invisible"> | 23 | + <div class="panel panel-info topic-panel-invisible" id="subject_{{subject.slug}}"> |
24 | <div class="panel-heading panel-invisible"> | 24 | <div class="panel-heading panel-invisible"> |
25 | {% endif %} | 25 | {% endif %} |
26 | <div class="row"> | 26 | <div class="row"> |
mural/views.py
@@ -597,7 +597,13 @@ class SubjectCreate(LoginRequiredMixin, generic.edit.CreateView): | @@ -597,7 +597,13 @@ class SubjectCreate(LoginRequiredMixin, generic.edit.CreateView): | ||
597 | users = getSpaceUsers(self.request.user.id, self.object) | 597 | users = getSpaceUsers(self.request.user.id, self.object) |
598 | entries = [] | 598 | entries = [] |
599 | 599 | ||
600 | - paths = [reverse("mural:manage_subject")] | 600 | + paths = [ |
601 | + reverse("mural:manage_subject"), | ||
602 | + reverse("mural:subject_view", args = (), kwargs = {'slug': self.object.space.slug}) | ||
603 | + ] | ||
604 | + | ||
605 | + if self.object.resource: | ||
606 | + paths.append(reverse("mural:resource_view", args = (), kwargs = {'slug': self.object.resource.slug})) | ||
601 | 607 | ||
602 | notification = { | 608 | notification = { |
603 | "type": "mural", | 609 | "type": "mural", |
@@ -668,7 +674,13 @@ class SubjectUpdate(LoginRequiredMixin, generic.UpdateView): | @@ -668,7 +674,13 @@ class SubjectUpdate(LoginRequiredMixin, generic.UpdateView): | ||
668 | 674 | ||
669 | users = getSpaceUsers(self.request.user.id, self.object) | 675 | users = getSpaceUsers(self.request.user.id, self.object) |
670 | 676 | ||
671 | - paths = [reverse("mural:manage_subject")] | 677 | + paths = [ |
678 | + reverse("mural:manage_subject"), | ||
679 | + reverse("mural:subject_view", args = (), kwargs = {'slug': self.object.space.slug}) | ||
680 | + ] | ||
681 | + | ||
682 | + if self.object.resource: | ||
683 | + paths.append(reverse("mural:resource_view", args = (), kwargs = {'slug': self.object.resource.slug})) | ||
672 | 684 | ||
673 | notification = { | 685 | notification = { |
674 | "type": "mural", | 686 | "type": "mural", |
@@ -713,7 +725,13 @@ class SubjectDelete(LoginRequiredMixin, generic.DeleteView): | @@ -713,7 +725,13 @@ class SubjectDelete(LoginRequiredMixin, generic.DeleteView): | ||
713 | def get_success_url(self): | 725 | def get_success_url(self): |
714 | users = getSpaceUsers(self.request.user.id, self.object) | 726 | users = getSpaceUsers(self.request.user.id, self.object) |
715 | 727 | ||
716 | - paths = [reverse("mural:manage_subject")] | 728 | + paths = [ |
729 | + reverse("mural:manage_subject"), | ||
730 | + reverse("mural:subject_view", args = (), kwargs = {'slug': self.object.space.slug}) | ||
731 | + ] | ||
732 | + | ||
733 | + if self.object.resource: | ||
734 | + paths.append(reverse("mural:resource_view", args = (), kwargs = {'slug': self.object.resource.slug})) | ||
717 | 735 | ||
718 | notification = { | 736 | notification = { |
719 | "type": "mural", | 737 | "type": "mural", |
@@ -911,7 +929,13 @@ class ResourceCreate(LoginRequiredMixin, generic.edit.CreateView): | @@ -911,7 +929,13 @@ class ResourceCreate(LoginRequiredMixin, generic.edit.CreateView): | ||
911 | users = getSpaceUsers(self.request.user.id, self.object) | 929 | users = getSpaceUsers(self.request.user.id, self.object) |
912 | entries = [] | 930 | entries = [] |
913 | 931 | ||
914 | - paths = [reverse("mural:manage_subject")] | 932 | + paths = [ |
933 | + reverse("mural:manage_subject"), | ||
934 | + reverse("mural:subject_view", args = (), kwargs = {'slug': self.object.space.slug}) | ||
935 | + ] | ||
936 | + | ||
937 | + if self.object.resource: | ||
938 | + paths.append(reverse("mural:resource_view", args = (), kwargs = {'slug': self.object.resource.slug})) | ||
915 | 939 | ||
916 | notification = { | 940 | notification = { |
917 | "type": "mural", | 941 | "type": "mural", |
@@ -1023,6 +1047,12 @@ class CommentCreate(LoginRequiredMixin, generic.edit.CreateView): | @@ -1023,6 +1047,12 @@ class CommentCreate(LoginRequiredMixin, generic.edit.CreateView): | ||
1023 | reverse("mural:manage_subject") | 1047 | reverse("mural:manage_subject") |
1024 | ] | 1048 | ] |
1025 | 1049 | ||
1050 | + if post._my_subclass == "subjectpost": | ||
1051 | + paths.append(reverse("mural:subject_view", args = (), kwargs = {'slug': post.get_space_slug()})) | ||
1052 | + | ||
1053 | + if post.subjectpost.resource: | ||
1054 | + paths.append(reverse("mural:resource_view", args = (), kwargs = {'slug': post.subjectpost.resource.slug})) | ||
1055 | + | ||
1026 | notification = { | 1056 | notification = { |
1027 | "type": "mural", | 1057 | "type": "mural", |
1028 | "subtype": "comment", | 1058 | "subtype": "comment", |
@@ -1086,6 +1116,12 @@ class CommentUpdate(LoginRequiredMixin, generic.UpdateView): | @@ -1086,6 +1116,12 @@ class CommentUpdate(LoginRequiredMixin, generic.UpdateView): | ||
1086 | reverse("mural:manage_subject") | 1116 | reverse("mural:manage_subject") |
1087 | ] | 1117 | ] |
1088 | 1118 | ||
1119 | + if self.object.post._my_subclass == "subjectpost": | ||
1120 | + paths.append(reverse("mural:subject_view", args = (), kwargs = {'slug': self.object.post.get_space_slug()})) | ||
1121 | + | ||
1122 | + if self.object.post.subjectpost.resource: | ||
1123 | + paths.append(reverse("mural:resource_view", args = (), kwargs = {'slug': self.object.post.subjectpost.resource.slug})) | ||
1124 | + | ||
1089 | notification = { | 1125 | notification = { |
1090 | "type": "mural", | 1126 | "type": "mural", |
1091 | "subtype": "mural_update", | 1127 | "subtype": "mural_update", |
@@ -1135,6 +1171,12 @@ class CommentDelete(LoginRequiredMixin, generic.DeleteView): | @@ -1135,6 +1171,12 @@ class CommentDelete(LoginRequiredMixin, generic.DeleteView): | ||
1135 | reverse("mural:manage_subject") | 1171 | reverse("mural:manage_subject") |
1136 | ] | 1172 | ] |
1137 | 1173 | ||
1174 | + if self.object.post._my_subclass == "subjectpost": | ||
1175 | + paths.append(reverse("mural:subject_view", args = (), kwargs = {'slug': self.object.post.get_space_slug()})) | ||
1176 | + | ||
1177 | + if self.object.post.subjectpost.resource: | ||
1178 | + paths.append(reverse("mural:resource_view", args = (), kwargs = {'slug': self.object.post.subjectpost.resource.slug})) | ||
1179 | + | ||
1138 | notification = { | 1180 | notification = { |
1139 | "type": "mural", | 1181 | "type": "mural", |
1140 | "subtype": "mural_delete", | 1182 | "subtype": "mural_delete", |