pytask/taskapp/forms/task.py
author anoop
Mon, 01 Feb 2010 17:30:30 +0530
changeset 22 943a35c14cf7
parent 18 293692eb8f06
permissions -rw-r--r--
added browse users functionality, added user/browse.html, fixed view my profile template.

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

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

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