taskapp/forms/task.py
changeset 151 d0cb85ba462a
parent 136 8632a44b743d
child 165 8ea5bcf3bd01
equal deleted inserted replaced
150:604808d27483 151:d0cb85ba462a
    10 def AddMentorForm(choices,instance=None):
    10 def AddMentorForm(choices,instance=None):
    11     """ return a form object with appropriate choices """
    11     """ return a form object with appropriate choices """
    12     
    12     
    13     class myform(forms.Form):
    13     class myform(forms.Form):
    14         mentor = forms.ChoiceField(choices=choices, required=True)
    14         mentor = forms.ChoiceField(choices=choices, required=True)
    15     form = myform(instance=instance) if instance else myform()
    15     form = myform(instance) if instance else myform()
    16     return form
    16     return form
    17 
    17 
    18 class ClaimTaskForm(forms.ModelForm):
    18 class ClaimTaskForm(forms.ModelForm):
    19     class Meta:
    19     class Meta:
    20         model = Claim
    20         model = Claim
    21         fields = ['message']
    21         fields = ['message']
    22 
    22 
    23 def ChoiceForm(choices):
    23 def ChoiceForm(choices, instance=None):
    24     """ return a form object with appropriate choices """
    24     """ return a form object with appropriate choices """
    25     
    25     
    26     class myform(forms.Form):
    26     class myform(forms.Form):
    27         choice = forms.ChoiceField(choices=choices, required=True)
    27         choice = forms.ChoiceField(choices=choices, required=True)
    28     form = myform()
    28     form = myform(instance) if instance else myform()
    29     return form
    29     return form
    30 
    30 
    31 def AddTaskForm(task_choices, is_plain=False):
    31 def AddTaskForm(task_choices, is_plain=False):
    32     """ if is_plain is true, it means the task has no subs/deps.
    32     """ if is_plain is true, it means the task has no subs/deps.
    33     so we also give a radio button to choose between subs and dependencies.
    33     so we also give a radio button to choose between subs and dependencies.