Commit 7f219cc5e863b50cc21ff28820753a23e9d1ec86
1 parent
0ae15162
Exists in
master
and in
5 other branches
Adapting forum creation [Issue: #88]
Showing
3 changed files
with
3 additions
and
4 deletions
Show diff stats
forum/static/js/forum.js
@@ -69,7 +69,7 @@ function createForum(url, topic) { | @@ -69,7 +69,7 @@ function createForum(url, topic) { | ||
69 | console.log(data); | 69 | console.log(data); |
70 | data = data.split('-'); | 70 | data = data.split('-'); |
71 | 71 | ||
72 | - $('.foruns_list').append("<a id='forum_"+data[1]+"' href='javascript:showForum("+data[0]+","+data[1]+")'>"+data[2]+"<br /></a>"); | 72 | + $('.foruns_list').append("<a id='forum_"+data[1]+"' href='"+data[0]+"'>"+data[2]+"<br /></a>"); |
73 | 73 | ||
74 | $("#createForum").modal('hide'); | 74 | $("#createForum").modal('hide'); |
75 | 75 |
forum/templates/forum/forum_form.html
1 | {% load static i18n %} | 1 | {% load static i18n %} |
2 | {% load widget_tweaks %} | 2 | {% load widget_tweaks %} |
3 | 3 | ||
4 | -<form id="forum_create" method="post" action="{% url 'forum:create' %}" enctype="multipart/form-data"> | 4 | +<form id="forum_create" method="post" action="{% url 'course:forum:create' %}" enctype="multipart/form-data"> |
5 | {% csrf_token %} | 5 | {% csrf_token %} |
6 | {% for field in form %} | 6 | {% for field in form %} |
7 | <div class="form-group {% if form.has_error %} has-error {% endif %} is-fileinput"> | 7 | <div class="form-group {% if form.has_error %} has-error {% endif %} is-fileinput"> |
forum/views.py
@@ -41,7 +41,6 @@ class CreateForumView(LoginRequiredMixin, generic.edit.CreateView): | @@ -41,7 +41,6 @@ class CreateForumView(LoginRequiredMixin, generic.edit.CreateView): | ||
41 | return self.render_to_response(self.get_context_data(form = form), status = 400) | 41 | return self.render_to_response(self.get_context_data(form = form), status = 400) |
42 | 42 | ||
43 | def get_success_url(self): | 43 | def get_success_url(self): |
44 | - print("Pass") | ||
45 | self.success_url = reverse('course:forum:render_forum', args = (self.object.id, )) | 44 | self.success_url = reverse('course:forum:render_forum', args = (self.object.id, )) |
46 | 45 | ||
47 | return self.success_url | 46 | return self.success_url |
@@ -49,7 +48,7 @@ class CreateForumView(LoginRequiredMixin, generic.edit.CreateView): | @@ -49,7 +48,7 @@ class CreateForumView(LoginRequiredMixin, generic.edit.CreateView): | ||
49 | def render_forum(request, forum): | 48 | def render_forum(request, forum): |
50 | last_forum = get_object_or_404(Forum, id = forum) | 49 | last_forum = get_object_or_404(Forum, id = forum) |
51 | 50 | ||
52 | - return HttpResponse(str(reverse_lazy('course:forum:index')) + '-' + str(forum) + '-' + str(last_forum.name)) | 51 | + return HttpResponse(str(reverse_lazy('course:forum:view', args = (), kwargs = {'slug': last_forum.slug})) + '-' + str(forum) + '-' + str(last_forum.name)) |
53 | 52 | ||
54 | class ForumDeleteView(LoginRequiredMixin, generic.DeleteView): | 53 | class ForumDeleteView(LoginRequiredMixin, generic.DeleteView): |
55 | login_url = reverse_lazy("core:home") | 54 | login_url = reverse_lazy("core:home") |