diff --git a/courses/templates/subject/form_view_teacher.html b/courses/templates/subject/form_view_teacher.html
index 9acd26c..11ee35a 100644
--- a/courses/templates/subject/form_view_teacher.html
+++ b/courses/templates/subject/form_view_teacher.html
@@ -2,20 +2,31 @@
{% block javascript %}
{% endblock %}
@@ -43,10 +54,15 @@
diff --git a/forum/forms.py b/forum/forms.py
new file mode 100644
index 0000000..945ea8a
--- /dev/null
+++ b/forum/forms.py
@@ -0,0 +1,20 @@
+from django import forms
+from django.utils.translation import ugettext_lazy as _
+from .models import Forum
+
+class ForumForm(forms.ModelForm):
+
+ class Meta:
+ model = Forum
+ fields = ('title', 'description')
+ labels = {
+ 'title': _('Title'),
+ 'description': _('Description')
+ }
+ help_texts = {
+ 'title': _('Forum title'),
+ 'description': _('What is this forum about?')
+ }
+ widgets = {
+ 'description': forms.Textarea(attrs={'cols': 80, 'rows': 5}),
+ }
\ No newline at end of file
diff --git a/forum/templates/forum_form.html b/forum/templates/forum_form.html
new file mode 100644
index 0000000..06a4b8d
--- /dev/null
+++ b/forum/templates/forum_form.html
@@ -0,0 +1,30 @@
+{% load static i18n %}
+{% load widget_tweaks %}
+
+
\ No newline at end of file
diff --git a/forum/templates/forum_list.html b/forum/templates/forum_list.html
index 0556598..873bbe3 100644
--- a/forum/templates/forum_list.html
+++ b/forum/templates/forum_list.html
@@ -1,9 +1,19 @@
-
-
+{% load i18n %}
+
+{% if foruns|length > 0 %}
+ {% for forum in foruns %}
+
+ {% endfor %}
+{% else %}
+
+{% endif %}
+
\ No newline at end of file
diff --git a/forum/urls.py b/forum/urls.py
index a546bcb..c3e9dfd 100644
--- a/forum/urls.py
+++ b/forum/urls.py
@@ -5,4 +5,5 @@ from . import views
urlpatterns = [
url(r'^$', views.ForumIndex.as_view(), name='index'),
+ url(r'^create$', views.CreateForumView.as_view(), name='create'),
]
diff --git a/forum/views.py b/forum/views.py
index aee77a5..efe5055 100644
--- a/forum/views.py
+++ b/forum/views.py
@@ -1,18 +1,20 @@
from django.shortcuts import render, get_object_or_404
from django.core.urlresolvers import reverse_lazy
from django.utils.translation import ugettext_lazy as _
-from django.views.generic import ListView
+from django.views import generic
from django.contrib.auth.mixins import LoginRequiredMixin
from .models import Forum
from courses.models import Topic
-class ForumIndex(LoginRequiredMixin, ListView):
+from .forms import ForumForm
+
+class ForumIndex(LoginRequiredMixin, generic.ListView):
login_url = reverse_lazy("core:home")
redirect_field_name = 'next'
template_name = "forum_list.html"
- context_object_name = 'forum'
+ context_object_name = 'foruns'
def get_queryset(self):
topic = get_object_or_404(Topic, slug = self.request.GET.get('topic', ''))
@@ -20,3 +22,9 @@ class ForumIndex(LoginRequiredMixin, ListView):
context = Forum.objects.filter(topic = topic)
return context
+
+class CreateForumView(LoginRequiredMixin, generic.edit.CreateView):
+
+ template_name = 'forum_form.html'
+ form_class = ForumForm
+ success_url = reverse_lazy('forum:index')
\ No newline at end of file
--
libgit2 0.21.2