taskapp/forms/task.py
author nishanth
Mon, 22 Feb 2010 18:13:20 +0530
changeset 50 d40e86f958f7
parent 25 c0e4fc8b8b5b
child 89 1cc03941ed5d
permissions -rw-r--r--
made changes in addtaskform to suit tagging.

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

class TaskCreateForm(forms.ModelForm):
    class Meta:
        model = Task
        fields = ['title', 'desc', 'tags_field', '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

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

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