Commit bfc4ec8f3bc0902dc1aa1e2fc99543621afab99f

Authored by Zambom
1 parent 9e9f87be

Adding comment edit

amadeus/static/js/mural.js 0 → 100644
@@ -0,0 +1,271 @@ @@ -0,0 +1,271 @@
  1 +var new_posts = [];
  2 +// loadOnScroll handler
  3 +var loadOnScroll = function() {
  4 + // If the current scroll position is past out cutoff point...
  5 + if ($(window).scrollTop() >= $(document).height() - $(window).height() - 10) {
  6 + // temporarily unhook the scroll event watcher so we don't call a bunch of times in a row
  7 + $(window).unbind();
  8 + // execute the load function below that will visit the view and return the content
  9 + loadPosts();
  10 + }
  11 +};
  12 +
  13 +var loadPosts = function() {
  14 + var loadUrl = $('.mural').data('url'),
  15 + pageNum = $('.mural').data('page'),
  16 + numberPages = $('.mural').data('pages'),
  17 + favorites = $('.mural').data('fav'),
  18 + mine = $('.mural').data('mine'),
  19 + showing = new_posts.join(',');
  20 + // Check if page is equal to the number of pages
  21 + if (pageNum == numberPages) {
  22 + return false
  23 + }
  24 + // Update the page number
  25 + pageNum = pageNum + 1;
  26 +
  27 + $("#loading_posts").show();
  28 + // Configure the url we're about to hit
  29 + setTimeout(function (){
  30 + $.ajax({
  31 + url: loadUrl,
  32 + data: {'page': pageNum, "favorite": favorites, "mine": mine, "showing": showing},
  33 + success: function(data) {
  34 + $("#loading_posts").hide();
  35 +
  36 + $(".posts").append(data);
  37 +
  38 + $('.mural').data('page', pageNum);
  39 + },
  40 + complete: function(data, textStatus){
  41 + // Turn the scroll monitor back on
  42 + $(window).bind('scroll', loadOnScroll);
  43 + }
  44 + });
  45 + }, 1000)
  46 +};
  47 +
  48 +$(function () {
  49 + $(window).bind('scroll', loadOnScroll);
  50 +
  51 + $(".post-field").click(function () {
  52 + var url = $(this).find('h4').data('url');
  53 +
  54 + $.ajax({
  55 + url: url,
  56 + success: function (data) {
  57 + $('#post-modal-form').html(data);
  58 +
  59 + setPostFormSubmit();
  60 +
  61 + $('#post-modal-form').modal('show');
  62 + }
  63 + });
  64 + });
  65 +
  66 + $("#clear_filter").click(function () {
  67 + var frm = $(this).parent();
  68 +
  69 + frm.find("input[type='checkbox']").prop('checked', false);
  70 +
  71 + frm.submit();
  72 + });
  73 +});
  74 +
  75 +function setPostFormSubmit(post = "") {
  76 + var frm = $('#post-form');
  77 +
  78 + frm.submit(function () {
  79 + var formData = new FormData($(this)[0]);
  80 +
  81 + $.ajax({
  82 + type: frm.attr('method'),
  83 + url: frm.attr('action'),
  84 + data: formData,
  85 + dataType: "json",
  86 + async: false,
  87 + success: function (data) {
  88 + if (post != "") {
  89 + var old = $("#post-" + post);
  90 +
  91 + old.before(data.view);
  92 +
  93 + old.remove();
  94 + } else {
  95 + $('.posts').prepend(data.view);
  96 +
  97 + new_posts.push(data.new_id);
  98 +
  99 + $('.no-subjects').attr('style', 'display:none');
  100 + }
  101 +
  102 + $('#post-modal-form').modal('hide');
  103 +
  104 + alertify.success(data.message);
  105 + },
  106 + error: function(data) {
  107 + $("#post-modal-form").html(data.responseText);
  108 + setPostFormSubmit(post);
  109 + },
  110 + cache: false,
  111 + contentType: false,
  112 + processData: false
  113 + });
  114 +
  115 + return false;
  116 + });
  117 +}
  118 +
  119 +function favorite(btn) {
  120 + var action = btn.data('action'),
  121 + url = btn.data('url');
  122 +
  123 + $.ajax({
  124 + url: url,
  125 + data: {'action': action},
  126 + dataType: 'json',
  127 + success: function (response) {
  128 + if (action == 'favorite') {
  129 + btn.switchClass("btn_fav", "btn_unfav", 250, "easeInOutQuad");
  130 + btn.data('action', 'unfavorite');
  131 + } else {
  132 + btn.switchClass("btn_unfav", "btn_fav", 250, "easeInOutQuad");
  133 + btn.data('action', 'favorite');
  134 + }
  135 +
  136 + btn.attr('data-original-title', response.label);
  137 + }
  138 + });
  139 +}
  140 +
  141 +function editPost(btn) {
  142 + var url = btn.data('url');
  143 + var post = btn.data('post');
  144 +
  145 + $.ajax({
  146 + url: url,
  147 + success: function (data) {
  148 + $('#post-modal-form').html(data);
  149 +
  150 + setPostFormSubmit(post);
  151 +
  152 + $('#post-modal-form').modal('show');
  153 + }
  154 + });
  155 +}
  156 +
  157 +function deletePost(btn) {
  158 + var url = btn.data('url');
  159 + var post = btn.data('post');
  160 +
  161 + $.ajax({
  162 + url: url,
  163 + success: function (data) {
  164 + $('#post-modal-form').html(data);
  165 +
  166 + setPostDeleteSubmit(post);
  167 +
  168 + $('#post-modal-form').modal('show');
  169 + }
  170 + });
  171 +}
  172 +
  173 +function setPostDeleteSubmit (post) {
  174 + var frm = $("#delete_form");
  175 +
  176 + frm.submit(function () {
  177 + $.ajax({
  178 + type: frm.attr('method'),
  179 + url: frm.attr('action'),
  180 + data: frm.serialize(),
  181 + success: function (response) {
  182 + $("#post-" + post).remove();
  183 +
  184 + $('#post-modal-form').modal('hide');
  185 +
  186 + alertify.success(response.msg);
  187 + },
  188 + error: function (data) {
  189 + console.log(data);
  190 + }
  191 + });
  192 +
  193 + return false;
  194 + });
  195 +}
  196 +
  197 +function comment(field) {
  198 + var url = field.find('h4').data('url'),
  199 + post = field.parent().parent();
  200 +
  201 + $.ajax({
  202 + url: url,
  203 + success: function (data) {
  204 + $('#post-modal-form').html(data);
  205 +
  206 + setCommentFormSubmit(post);
  207 +
  208 + $('#post-modal-form').modal('show');
  209 + }
  210 + });
  211 +}
  212 +
  213 +function editComment(btn) {
  214 + var url = btn.data('url'),
  215 + post_id = btn.data('post'),
  216 + post = $("#post-" + post_id),
  217 + comment = btn.data('id');
  218 +
  219 + $.ajax({
  220 + url: url,
  221 + success: function (data) {
  222 + $('#post-modal-form').html(data);
  223 +
  224 + setCommentFormSubmit(post, comment);
  225 +
  226 + $('#post-modal-form').modal('show');
  227 + }
  228 + });
  229 +}
  230 +
  231 +function setCommentFormSubmit(post, comment = "") {
  232 + var frm = $('#comment-form');
  233 +
  234 + frm.submit(function () {
  235 + var formData = new FormData($(this)[0]);
  236 +
  237 + $.ajax({
  238 + type: frm.attr('method'),
  239 + url: frm.attr('action'),
  240 + data: formData,
  241 + dataType: "json",
  242 + async: false,
  243 + success: function (data) {
  244 + if (comment != "") {
  245 + var old = $("#comment-" + comment);
  246 +
  247 + old.before(data.view);
  248 +
  249 + old.remove();
  250 + } else {
  251 + $(post).find(".comment-section").append(data.view);
  252 +
  253 + //new_posts.push(data.new_id);
  254 + }
  255 +
  256 + $('#post-modal-form').modal('hide');
  257 +
  258 + alertify.success(data.message);
  259 + },
  260 + error: function(data) {
  261 + $("#post-modal-form").html(data.responseText);
  262 + setPostFormSubmit(post, comment);
  263 + },
  264 + cache: false,
  265 + contentType: false,
  266 + processData: false
  267 + });
  268 +
  269 + return false;
  270 + });
  271 +}
0 \ No newline at end of file 272 \ No newline at end of file
mural/migrations/0007_comment_edited.py 0 → 100644
@@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
  1 +# -*- coding: utf-8 -*-
  2 +# Generated by Django 1.10 on 2017-02-09 21:47
  3 +from __future__ import unicode_literals
  4 +
  5 +from django.db import migrations, models
  6 +
  7 +
  8 +class Migration(migrations.Migration):
  9 +
  10 + dependencies = [
  11 + ('mural', '0006_auto_20170209_1434'),
  12 + ]
  13 +
  14 + operations = [
  15 + migrations.AddField(
  16 + model_name='comment',
  17 + name='edited',
  18 + field=models.BooleanField(default=False, verbose_name='Edited'),
  19 + ),
  20 + ]
mural/models.py
@@ -69,6 +69,7 @@ class Comment(models.Model): @@ -69,6 +69,7 @@ class Comment(models.Model):
69 user = models.ForeignKey(User, verbose_name = _('User'), related_name = "comment_user", null = True) 69 user = models.ForeignKey(User, verbose_name = _('User'), related_name = "comment_user", null = True)
70 create_date = models.DateTimeField(_('Create Date'), auto_now_add = True) 70 create_date = models.DateTimeField(_('Create Date'), auto_now_add = True)
71 last_update = models.DateTimeField(_('Last Update'), auto_now = True) 71 last_update = models.DateTimeField(_('Last Update'), auto_now = True)
  72 + edited = models.BooleanField(_('Edited'), default = False)
72 73
73 """ 74 """
74 Model to handle posts visualizations 75 Model to handle posts visualizations
mural/templates/mural/_form_comment.html
@@ -73,16 +73,10 @@ @@ -73,16 +73,10 @@
73 <div id="add-user-modal" style="display:none"> 73 <div id="add-user-modal" style="display:none">
74 <div class="modal-dialog" role="document"> 74 <div class="modal-dialog" role="document">
75 <div class="modal-content"> 75 <div class="modal-content">
76 - <div class="modal-header">  
77 - <h3>{% trans 'Mark user in comment' %}</h3>  
78 - </div>  
79 <div class="modal-body"> 76 <div class="modal-body">
80 - <p>{% trans 'Type the user name in the field below' %}</p>  
81 <div class="form-group"> 77 <div class="form-group">
82 - <input type="text" class="form-control" id="adduser_field" oninput="typing_search($(this));" />  
83 - <div class="suggestions list-group" data-url="{% url 'mural:suggest_users' %}" style="display:none">  
84 -  
85 - </div> 78 + <input type="text" class="form-control" id="adduser_field" oninput="typing_search($(this));" placeholder="{% trans 'Insert here the name of the user you wish to mark in this comment' %}" />
  79 + <div class="suggestions list-group" data-url="{% url 'mural:suggest_users' %}" style="display:none"></div>
86 </div> 80 </div>
87 </div> 81 </div>
88 <div class="modal-footer"> 82 <div class="modal-footer">
mural/templates/mural/_user_suggestions_list.html
@@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
12 </a> 12 </a>
13 {% endfor %} 13 {% endfor %}
14 {% else %} 14 {% else %}
15 - <a href="#" class="list-group-item suggested-user"> 15 + <a class="list-group-item suggested-user">
16 <h4 class="text-center">{% trans 'No results found.' %}</h4> 16 <h4 class="text-center">{% trans 'No results found.' %}</h4>
17 </a> 17 </a>
18 {% endif %} 18 {% endif %}
19 \ No newline at end of file 19 \ No newline at end of file
mural/templates/mural/_view_comment.html
1 -{% load i18n %} 1 +{% load i18n mural_filters %}
2 2
3 <div id="comment-{{ comment.id }}" class="row comment"> 3 <div id="comment-{{ comment.id }}" class="row comment">
4 <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 comment-img"> 4 <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 comment-img">
@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
19 <i class="fa fa-ellipsis-v" aria-hidden="true"></i> 19 <i class="fa fa-ellipsis-v" aria-hidden="true"></i>
20 </button> 20 </button>
21 <ul class="dropdown-menu pull-right" aria-labelledby="moreActions"> 21 <ul class="dropdown-menu pull-right" aria-labelledby="moreActions">
22 - <li><a onclick="editPost($(this));"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i> {% trans 'Edit' %}</a></li> 22 + <li><a onclick="editComment($(this));" data-url="{% url 'mural:update_comment' comment.id %}" data-id="{{ comment.id }}" data-post="{{ comment.post.id }}"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i> {% trans 'Edit' %}</a></li>
23 <li> 23 <li>
24 <a onclick="deletePost($(this))" aria-hidden="true"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans 'Remove' %}</a></li> 24 <a onclick="deletePost($(this))" aria-hidden="true"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans 'Remove' %}</a></li>
25 </ul> 25 </ul>
@@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
28 </h4> 28 </h4>
29 <p class="comment-time"> 29 <p class="comment-time">
30 <i class="fa fa-clock-o"></i> 30 <i class="fa fa-clock-o"></i>
31 - {% trans 'In' %} {{ comment.last_update }} 31 + {% trans 'In' %} {{ comment.last_update }} {{ comment|is_edited }}
32 </p> 32 </p>
33 33
34 {% autoescape off %} 34 {% autoescape off %}
mural/templates/mural/list.html
@@ -72,259 +72,5 @@ @@ -72,259 +72,5 @@
72 72
73 <div class="modal fade" id="post-modal-form" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"></div> 73 <div class="modal fade" id="post-modal-form" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"></div>
74 74
75 - <script type="text/javascript">  
76 - var new_posts = [];  
77 - // loadOnScroll handler  
78 - var loadOnScroll = function() {  
79 - // If the current scroll position is past out cutoff point...  
80 - if ($(window).scrollTop() >= $(document).height() - $(window).height() - 10) {  
81 - // temporarily unhook the scroll event watcher so we don't call a bunch of times in a row  
82 - $(window).unbind();  
83 - // execute the load function below that will visit the view and return the content  
84 - loadPosts();  
85 - }  
86 - };  
87 -  
88 - var loadPosts = function() {  
89 - var loadUrl = $('.mural').data('url'),  
90 - pageNum = $('.mural').data('page'),  
91 - numberPages = $('.mural').data('pages'),  
92 - favorites = $('.mural').data('fav'),  
93 - mine = $('.mural').data('mine'),  
94 - showing = new_posts.join(',');  
95 - // Check if page is equal to the number of pages  
96 - if (pageNum == numberPages) {  
97 - return false  
98 - }  
99 - // Update the page number  
100 - pageNum = pageNum + 1;  
101 -  
102 - $("#loading_posts").show();  
103 - // Configure the url we're about to hit  
104 - setTimeout(function (){  
105 - $.ajax({  
106 - url: loadUrl,  
107 - data: {'page': pageNum, "favorite": favorites, "mine": mine, "showing": showing},  
108 - success: function(data) {  
109 - $("#loading_posts").hide();  
110 -  
111 - $(".posts").append(data);  
112 -  
113 - $('.mural').data('page', pageNum);  
114 - },  
115 - complete: function(data, textStatus){  
116 - // Turn the scroll monitor back on  
117 - $(window).bind('scroll', loadOnScroll);  
118 - }  
119 - });  
120 - }, 1000)  
121 - };  
122 -  
123 - $(function () {  
124 - $(window).bind('scroll', loadOnScroll);  
125 -  
126 - $(".post-field").click(function () {  
127 - var url = $(this).find('h4').data('url');  
128 -  
129 - $.ajax({  
130 - url: url,  
131 - success: function (data) {  
132 - $('#post-modal-form').html(data);  
133 -  
134 - setPostFormSubmit();  
135 -  
136 - $('#post-modal-form').modal('show');  
137 - }  
138 - });  
139 - });  
140 -  
141 - $("#clear_filter").click(function () {  
142 - var frm = $(this).parent();  
143 -  
144 - frm.find("input[type='checkbox']").prop('checked', false);  
145 -  
146 - frm.submit();  
147 - });  
148 - });  
149 -  
150 - function setPostFormSubmit(post = "") {  
151 - var frm = $('#post-form');  
152 -  
153 - frm.submit(function () {  
154 - var formData = new FormData($(this)[0]);  
155 -  
156 - $.ajax({  
157 - type: frm.attr('method'),  
158 - url: frm.attr('action'),  
159 - data: formData,  
160 - dataType: "json",  
161 - async: false,  
162 - success: function (data) {  
163 - if (post != "") {  
164 - var old = $("#post-" + post);  
165 -  
166 - old.before(data.view);  
167 -  
168 - old.remove();  
169 - } else {  
170 - $('.posts').prepend(data.view);  
171 -  
172 - new_posts.push(data.new_id);  
173 -  
174 - $('.no-subjects').attr('style', 'display:none');  
175 - }  
176 -  
177 - $('#post-modal-form').modal('hide');  
178 -  
179 - alertify.success(data.message);  
180 - },  
181 - error: function(data) {  
182 - $("#post-modal-form").html(data.responseText);  
183 - setPostFormSubmit(post);  
184 - },  
185 - cache: false,  
186 - contentType: false,  
187 - processData: false  
188 - });  
189 -  
190 - return false;  
191 - });  
192 - }  
193 -  
194 - function favorite(btn) {  
195 - var action = btn.data('action'),  
196 - url = btn.data('url');  
197 -  
198 - $.ajax({  
199 - url: url,  
200 - data: {'action': action},  
201 - dataType: 'json',  
202 - success: function (response) {  
203 - if (action == 'favorite') {  
204 - btn.switchClass("btn_fav", "btn_unfav", 250, "easeInOutQuad");  
205 - btn.data('action', 'unfavorite');  
206 - } else {  
207 - btn.switchClass("btn_unfav", "btn_fav", 250, "easeInOutQuad");  
208 - btn.data('action', 'favorite');  
209 - }  
210 -  
211 - btn.attr('data-original-title', response.label);  
212 - }  
213 - });  
214 - }  
215 -  
216 - function editPost(btn) {  
217 - var url = btn.data('url');  
218 - var post = btn.data('post');  
219 -  
220 - $.ajax({  
221 - url: url,  
222 - success: function (data) {  
223 - $('#post-modal-form').html(data);  
224 -  
225 - setPostFormSubmit(post);  
226 -  
227 - $('#post-modal-form').modal('show');  
228 - }  
229 - });  
230 - }  
231 -  
232 - function deletePost(btn) {  
233 - var url = btn.data('url');  
234 - var post = btn.data('post');  
235 -  
236 - $.ajax({  
237 - url: url,  
238 - success: function (data) {  
239 - $('#post-modal-form').html(data);  
240 -  
241 - setPostDeleteSubmit(post);  
242 -  
243 - $('#post-modal-form').modal('show');  
244 - }  
245 - });  
246 - }  
247 -  
248 - function setPostDeleteSubmit (post) {  
249 - var frm = $("#delete_form");  
250 -  
251 - frm.submit(function () {  
252 - $.ajax({  
253 - type: frm.attr('method'),  
254 - url: frm.attr('action'),  
255 - data: frm.serialize(),  
256 - success: function (response) {  
257 - $("#post-" + post).remove();  
258 -  
259 - $('#post-modal-form').modal('hide');  
260 -  
261 - alertify.success(response.msg);  
262 - },  
263 - error: function (data) {  
264 - console.log(data);  
265 - }  
266 - });  
267 -  
268 - return false;  
269 - });  
270 - }  
271 -  
272 - function comment(field) {  
273 - var url = field.find('h4').data('url'),  
274 - post = field.parent().parent();  
275 -  
276 - $.ajax({  
277 - url: url,  
278 - success: function (data) {  
279 - $('#post-modal-form').html(data);  
280 -  
281 - setCommentFormSubmit(post);  
282 -  
283 - $('#post-modal-form').modal('show');  
284 - }  
285 - });  
286 - }  
287 -  
288 - function setCommentFormSubmit(post, comment = "") {  
289 - var frm = $('#comment-form');  
290 -  
291 - frm.submit(function () {  
292 - var formData = new FormData($(this)[0]);  
293 -  
294 - $.ajax({  
295 - type: frm.attr('method'),  
296 - url: frm.attr('action'),  
297 - data: formData,  
298 - dataType: "json",  
299 - async: false,  
300 - success: function (data) {  
301 - /*if (post != "") {  
302 - var old = $("#post-" + post);  
303 -  
304 - old.before(data.view);  
305 -  
306 - old.remove();  
307 - } else {*/  
308 - $(post).find(".comment-section").append(data.view);  
309 -  
310 - //new_posts.push(data.new_id);  
311 - //}  
312 -  
313 - $('#post-modal-form').modal('hide');  
314 -  
315 - alertify.success(data.message);  
316 - },  
317 - error: function(data) {  
318 - $("#post-modal-form").html(data.responseText);  
319 - setPostFormSubmit(post, comment);  
320 - },  
321 - cache: false,  
322 - contentType: false,  
323 - processData: false  
324 - });  
325 -  
326 - return false;  
327 - });  
328 - }  
329 - </script> 75 + <script type="text/javascript" src="{% static 'js/mural.js' %}"></script>
330 {% endblock %} 76 {% endblock %}
331 \ No newline at end of file 77 \ No newline at end of file
@@ -9,6 +9,7 @@ urlpatterns = [ @@ -9,6 +9,7 @@ urlpatterns = [
9 url(r'^favorite/([\w_-]+)/$', views.favorite, name='favorite'), 9 url(r'^favorite/([\w_-]+)/$', views.favorite, name='favorite'),
10 url(r'^deleted/$', views.deleted_post, name='deleted_post'), 10 url(r'^deleted/$', views.deleted_post, name='deleted_post'),
11 url(r'^comment/(?P<post>[\w_-]+)/$', views.CommentCreate.as_view(), name='create_comment'), 11 url(r'^comment/(?P<post>[\w_-]+)/$', views.CommentCreate.as_view(), name='create_comment'),
  12 + url(r'^update_comment/(?P<pk>[\w_-]+)/$', views.CommentUpdate.as_view(), name='update_comment'),
12 url(r'^render_comment/([\w_-]+)/([\w_-]+)/$', views.render_comment, name='render_comment'), 13 url(r'^render_comment/([\w_-]+)/([\w_-]+)/$', views.render_comment, name='render_comment'),
13 url(r'^render_post/([\w_-]+)/([\w_-]+)/$', views.render_gen_post, name='render_post_general'), 14 url(r'^render_post/([\w_-]+)/([\w_-]+)/$', views.render_gen_post, name='render_post_general'),
14 url(r'^suggest_users/$', views.suggest_users, name='suggest_users'), 15 url(r'^suggest_users/$', views.suggest_users, name='suggest_users'),
mural/views.py
@@ -259,7 +259,6 @@ class CommentCreate(LoginRequiredMixin, generic.edit.CreateView): @@ -259,7 +259,6 @@ class CommentCreate(LoginRequiredMixin, generic.edit.CreateView):
259 self.object.save() 259 self.object.save()
260 260
261 users = User.objects.all().exclude(id = self.request.user.id) 261 users = User.objects.all().exclude(id = self.request.user.id)
262 - entries = []  
263 262
264 notify_type = "mural" 263 notify_type = "mural"
265 user_icon = self.object.user.image_url 264 user_icon = self.object.user.image_url
@@ -271,8 +270,6 @@ class CommentCreate(LoginRequiredMixin, generic.edit.CreateView): @@ -271,8 +270,6 @@ class CommentCreate(LoginRequiredMixin, generic.edit.CreateView):
271 # entries.append(MuralVisualizations(viewed = False, user = user, post = self.object)) 270 # entries.append(MuralVisualizations(viewed = False, user = user, post = self.object))
272 # 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})}) 271 # 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})})
273 272
274 - #MuralVisualizations.objects.bulk_create(entries)  
275 -  
276 return super(CommentCreate, self).form_valid(form) 273 return super(CommentCreate, self).form_valid(form)
277 274
278 def get_context_data(self, *args, **kwargs): 275 def get_context_data(self, *args, **kwargs):
@@ -287,6 +284,54 @@ class CommentCreate(LoginRequiredMixin, generic.edit.CreateView): @@ -287,6 +284,54 @@ class CommentCreate(LoginRequiredMixin, generic.edit.CreateView):
287 def get_success_url(self): 284 def get_success_url(self):
288 return reverse_lazy('mural:render_comment', args = (self.object.id, 'create', )) 285 return reverse_lazy('mural:render_comment', args = (self.object.id, 'create', ))
289 286
  287 +class CommentUpdate(LoginRequiredMixin, generic.UpdateView):
  288 + login_url = reverse_lazy("users:login")
  289 + redirect_field_name = 'next'
  290 +
  291 + template_name = 'mural/_form_comment.html'
  292 + model = Comment
  293 + form_class = CommentForm
  294 +
  295 + def form_invalid(self, form):
  296 + context = super(CommentUpdate, self).form_invalid(form)
  297 + context.status_code = 400
  298 +
  299 + return context
  300 +
  301 + def form_valid(self, form):
  302 + self.object = form.save(commit = False)
  303 +
  304 + self.object.edited = True
  305 +
  306 + self.object.save()
  307 +
  308 + users = User.objects.all().exclude(id = self.request.user.id)
  309 + entries = []
  310 +
  311 + notify_type = "mural"
  312 + user_icon = self.object.user.image_url
  313 + #_view = render_to_string("mural/_view.html", {"post": self.object}, self.request)
  314 + simple_notify = _("%s has made a post in General")%(str(self.object.user))
  315 + pathname = reverse("mural:manage_general")
  316 +
  317 + #for user in users:
  318 + # entries.append(MuralVisualizations(viewed = False, user = user, post = self.object))
  319 + # 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})})
  320 +
  321 + #MuralVisualizations.objects.bulk_create(entries)
  322 +
  323 + return super(CommentUpdate, self).form_valid(form)
  324 +
  325 + def get_context_data(self, *args, **kwargs):
  326 + context = super(CommentUpdate, self).get_context_data(*args, **kwargs)
  327 +
  328 + context['form_url'] = reverse_lazy("mural:update_comment", args = (), kwargs = {'pk': self.object.id})
  329 +
  330 + return context
  331 +
  332 + def get_success_url(self):
  333 + return reverse_lazy('mural:render_comment', args = (self.object.id, 'update', ))
  334 +
290 def render_comment(request, comment, msg): 335 def render_comment(request, comment, msg):
291 comment = get_object_or_404(Comment, id = comment) 336 comment = get_object_or_404(Comment, id = comment)
292 337