Commit c51c806c authored by Jean Michel Rouly's avatar Jean Michel Rouly
Browse files

Added section field processing.

parent e28c760d
......@@ -2,18 +2,38 @@ from website.models import Question, Comment, Reply
from django import forms
from django.db import models
from django.forms import ModelForm, Textarea
from django.forms import ModelForm, Textarea, TextInput
class QuestionForm( ModelForm ):
class Meta:
model = Question
fields = ('text',)
fields = ('text','section',)
exclude = ('user','date','rating')
localized_fields = ('date',)
labels = {
'text' : 'Question Text',
'section' : 'Course Section',
widgets = {
'text':Textarea(attrs={'class': 'form-control',}),
'class': 'form-control',
'placeholder': 'Question Text',
'section': TextInput(attrs={
'class': 'form-control',
'placeholder': 'Course Section',
'pattern': '[a-zA-Z]+ {0,1}[0-9]*',
# Parse out unneeded spaces from the section. This makes everything
# nice and sanitary and uniform.
def clean_section(self):
data = self.cleaned_data.get('section')
if data is not None:
data = data.upper().replace(" ", "")
return data
class CommentForm( ModelForm ):
class Meta:
model = Comment
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment