taskapp/forms/task.py
changeset 165 8ea5bcf3bd01
parent 151 d0cb85ba462a
child 178 106909df0c17
equal deleted inserted replaced
164:bfe621e64a16 165:8ea5bcf3bd01
     3 
     3 
     4 class TaskCreateForm(forms.ModelForm):
     4 class TaskCreateForm(forms.ModelForm):
     5     class Meta:
     5     class Meta:
     6         model = Task
     6         model = Task
     7         fields = ['title', 'desc', 'tags_field', 'credits']
     7         fields = ['title', 'desc', 'tags_field', 'credits']
     8     publish = forms.BooleanField(required=False)
     8     #publish = forms.BooleanField(required=False)
       
     9 
       
    10 def EditTaskForm(task, instance=None):
       
    11     class myForm(forms.ModelForm):
       
    12         class Meta:
       
    13             model = Task
       
    14             fields = ['title', 'desc', 'tags_field', 'credits']
       
    15     data = {
       
    16         'title': task.title,
       
    17         'desc': task.desc,
       
    18         'tags_field': task.tags_field,
       
    19         'credits': task.credits,
       
    20     }
       
    21     return myForm(instance) if instance else myForm(data)
     9 
    22 
    10 def AddMentorForm(choices,instance=None):
    23 def AddMentorForm(choices,instance=None):
    11     """ return a form object with appropriate choices """
    24     """ return a form object with appropriate choices """
    12     
    25     
    13     class myform(forms.Form):
    26     class myform(forms.Form):