From 525e272f8fc7702dc382776abcff4cbcde767e8b Mon Sep 17 00:00:00 2001 From: Zambom Date: Wed, 21 Sep 2016 22:39:21 -0300 Subject: [PATCH] Adding form to create forum [Issue: #73] --- courses/templates/subject/form_view_teacher.html | 26 +++++++++++++++++++++----- forum/forms.py | 20 ++++++++++++++++++++ forum/templates/forum_form.html | 30 ++++++++++++++++++++++++++++++ forum/templates/forum_list.html | 24 +++++++++++++++++------- forum/urls.py | 1 + forum/views.py | 14 +++++++++++--- 6 files changed, 100 insertions(+), 15 deletions(-) create mode 100644 forum/forms.py create mode 100644 forum/templates/forum_form.html 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 %} + +
+ {% csrf_token %} + {% for field in form %} +
+ + {% render_field field class='form-control' %} + {{ field.help_text }} + {% if field.errors %} +
+
+ +
+ {% endif %} +
+ {% endfor %} + + +
\ 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 @@ - -