taskapp/forms/task.py
author nishanth
Thu, 04 Feb 2010 22:37:15 +0530
changeset 21 c28774fe7ffd
parent 18 a39549bd5b08
child 22 36d3173ab7f9
permissions -rw-r--r--
implemented "add another mentor" functionality to a task.

from django import forms
from pytask.taskapp.models import Task

class TaskCreateForm(forms.ModelForm):
    class Meta:
        model = Task
        fields = ['title', 'desc', 'tags', 'credits']
    publish = forms.BooleanField(required=False)

def AddMentorForm(choices,instance=None):
    """ return a form object with appropriate choices """
    
    class myform(forms.Form):
        mentor = forms.ChoiceField(choices=choices, required=True)
    form = myform(instance=instance) if instance else myform()
    return form

def ClaimTaskForm(models.ModelForm):
    class Meta:
        model = Claim
        fields = ['message']