Commit 1299e09d6112590680c37b97dce27627eb415095
1 parent
ff97c0d0
Exists in
master
and in
5 other branches
Fixing same name forum creation [Issue: #215]
Showing
2 changed files
with
3 additions
and
4 deletions
Show diff stats
forum/static/js/forum.js
@@ -70,10 +70,9 @@ function setForumCreateFormSubmit() { | @@ -70,10 +70,9 @@ function setForumCreateFormSubmit() { | ||
70 | type: frm.attr('method'), | 70 | type: frm.attr('method'), |
71 | url: frm.attr('action'), | 71 | url: frm.attr('action'), |
72 | data: frm.serialize(), | 72 | data: frm.serialize(), |
73 | + dataType: "json", | ||
73 | success: function (data) { | 74 | success: function (data) { |
74 | - data = data.split('-'); | ||
75 | - | ||
76 | - $('.foruns_list').append("<li><i class='fa fa-commenting' aria-hidden='true'></i> <a id='forum_"+data[1]+"' href='"+data[0]+"'> "+data[2]+"</a></li>"); | 75 | + $('.foruns_list').append("<li><i class='fa fa-commenting' aria-hidden='true'></i> <a id='forum_"+data.forum_id+"' href='"+data.url+"'> "+data.name+"</a></li>"); |
77 | 76 | ||
78 | $("#createForum").modal('hide'); | 77 | $("#createForum").modal('hide'); |
79 | }, | 78 | }, |
forum/views.py
@@ -67,7 +67,7 @@ class CreateForumView(LoginRequiredMixin, generic.edit.CreateView, NotificationM | @@ -67,7 +67,7 @@ class CreateForumView(LoginRequiredMixin, generic.edit.CreateView, NotificationM | ||
67 | def render_forum(request, forum): | 67 | def render_forum(request, forum): |
68 | last_forum = get_object_or_404(Forum, id = forum) | 68 | last_forum = get_object_or_404(Forum, id = forum) |
69 | 69 | ||
70 | - return HttpResponse(str(reverse_lazy('course:forum:view', args = (), kwargs = {'slug': last_forum.slug})) + '-' + str(forum) + '-' + str(last_forum.name)) | 70 | + return JsonResponse({'url': str(reverse_lazy('course:forum:view', args = (), kwargs = {'slug': last_forum.slug})), 'forum_id': str(forum), 'name': str(last_forum.name)}) |
71 | 71 | ||
72 | class UpdateForumView(LoginRequiredMixin, generic.UpdateView): | 72 | class UpdateForumView(LoginRequiredMixin, generic.UpdateView): |
73 | login_url = reverse_lazy("core:home") | 73 | login_url = reverse_lazy("core:home") |