Commit f220b7a8811dbc3563306684931f4e39840b5a34

Authored by Zambom
1 parent 27792fef

Adapting forum deletion [Issue: #86 and #96]

forum/static/js/forum.js
@@ -92,7 +92,7 @@ function createForum(url, topic) { @@ -92,7 +92,7 @@ function createForum(url, topic) {
92 * Function to delete a forum 92 * Function to delete a forum
93 * 93 *
94 */ 94 */
95 -function delete_forum(url, forum, message) { 95 +function delete_forum(url, forum, message, return_url) {
96 alertify.confirm(message, function(){ 96 alertify.confirm(message, function(){
97 var csrftoken = getCookie('csrftoken'); 97 var csrftoken = getCookie('csrftoken');
98 98
@@ -103,8 +103,9 @@ function delete_forum(url, forum, message) { @@ -103,8 +103,9 @@ function delete_forum(url, forum, message) {
103 }, 103 },
104 url: url, 104 url: url,
105 success: function(data) { 105 success: function(data) {
106 - $("#forum_"+forum).remove();  
107 - $('#forumModal').modal('hide'); 106 + alertify.alert('Amadeus', data, function(){
  107 + window.location.href = return_url;
  108 + });
108 } 109 }
109 }); 110 });
110 }); 111 });
forum/templates/forum/forum_view.html
@@ -42,7 +42,7 @@ @@ -42,7 +42,7 @@
42 <div class="panel-body"> 42 <div class="panel-body">
43 <ul class="nav nav-pills nav-stacked"> 43 <ul class="nav nav-pills nav-stacked">
44 <li><a href="javascript:edit_forum('{% url 'course:forum:index' %}', '{{ forum.id }}')">{% trans 'Edit' %}</a></li> 44 <li><a href="javascript:edit_forum('{% url 'course:forum:index' %}', '{{ forum.id }}')">{% trans 'Edit' %}</a></li>
45 - <li><a href="javascript:delete_forum('{% url 'course:forum:delete' forum.id %}', '{{ forum.id }}', '{% trans "Are you sure you want to delete this forum?" %}')">{% trans 'Delete' %}</a></li> 45 + <li><a href="javascript:delete_forum('{% url 'course:forum:delete' forum.id %}', '{{ forum.id }}', '{% trans "Are you sure you want to delete this forum?" %}', '{% url 'course:view_subject' forum.topic.subject.slug %}')">{% trans 'Delete' %}</a></li>
46 </ul> 46 </ul>
47 </div> 47 </div>
48 </div> 48 </div>