author | nishanth |
Thu, 25 Feb 2010 02:11:49 +0530 | |
changeset 89 | 1cc03941ed5d |
parent 50 | d40e86f958f7 |
child 90 | b2426897ff18 |
permissions | -rw-r--r-- |
18
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
12
diff
changeset
|
1 |
from django import forms |
22 | 2 |
from pytask.taskapp.models import Task, Claim |
18
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
12
diff
changeset
|
3 |
|
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
12
diff
changeset
|
4 |
class TaskCreateForm(forms.ModelForm): |
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
12
diff
changeset
|
5 |
class Meta: |
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
12
diff
changeset
|
6 |
model = Task |
50 | 7 |
fields = ['title', 'desc', 'tags_field', 'credits'] |
18
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
12
diff
changeset
|
8 |
publish = forms.BooleanField(required=False) |
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
9 |
|
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
10 |
def AddMentorForm(choices,instance=None): |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
11 |
""" return a form object with appropriate choices """ |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
12 |
|
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
13 |
class myform(forms.Form): |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
14 |
mentor = forms.ChoiceField(choices=choices, required=True) |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
15 |
form = myform(instance=instance) if instance else myform() |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
16 |
return form |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
17 |
|
22 | 18 |
class ClaimTaskForm(forms.ModelForm): |
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
19 |
class Meta: |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
20 |
model = Claim |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
21 |
fields = ['message'] |
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
22 |
|
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
23 |
def AssignTaskForm(choices, instance=None): |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
24 |
""" return a form object with appropriate choices """ |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
25 |
|
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
26 |
class myform(forms.Form): |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
27 |
user = forms.ChoiceField(choices=choices, required=True) |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
28 |
form = myform() |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
29 |
return form |
89
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
50
diff
changeset
|
30 |
|
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
50
diff
changeset
|
31 |
def AddTaskForm(task_choices, is_plain=False): |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
50
diff
changeset
|
32 |
""" if is_plain is true, it means the task has no subs/deps. |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
50
diff
changeset
|
33 |
so we also give a radio button to choose between subs and dependencies. |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
50
diff
changeset
|
34 |
else we only give choices. |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
50
diff
changeset
|
35 |
""" |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
50
diff
changeset
|
36 |
|
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
50
diff
changeset
|
37 |
class myForm(forms.Form): |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
50
diff
changeset
|
38 |
if is_plain: |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
50
diff
changeset
|
39 |
type_choices = [('S','Subtasks'),('D','Dependencies')] |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
50
diff
changeset
|
40 |
type = forms.ChoiceField(type_choices, widget=forms.RadioSelect) |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
50
diff
changeset
|
41 |
|
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
50
diff
changeset
|
42 |
task = forms.MultipleChoiceField(choices=task_choices) |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
50
diff
changeset
|
43 |
return myForm() |