equal
deleted
inserted
replaced
2 from pytask.taskapp.models import Task |
2 from pytask.taskapp.models import Task |
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', 'pynts'] |
8 #publish = forms.BooleanField(required=False) |
8 #publish = forms.BooleanField(required=False) |
9 |
9 |
10 def clean_title(self): |
10 def clean_title(self): |
11 data = self.cleaned_data['title'].strip() |
11 data = self.cleaned_data['title'].strip() |
12 try: |
12 try: |
23 return data |
23 return data |
24 |
24 |
25 class EditTaskForm(forms.ModelForm): |
25 class EditTaskForm(forms.ModelForm): |
26 class Meta: |
26 class Meta: |
27 model = Task |
27 model = Task |
28 fields = ['title', 'desc', 'tags_field', 'credits'] |
28 fields = ['title', 'desc', 'tags_field', 'pynts'] |
29 |
29 |
30 def clean_desc(self): |
30 def clean_desc(self): |
31 data = self.cleaned_data['desc'].strip() |
31 data = self.cleaned_data['desc'].strip() |
32 if not data: |
32 if not data: |
33 raise forms.ValidationError("Enter some description for the task") |
33 raise forms.ValidationError("Enter some description for the task") |
83 type = forms.ChoiceField(type_choices, widget=forms.RadioSelect) |
83 type = forms.ChoiceField(type_choices, widget=forms.RadioSelect) |
84 |
84 |
85 task = forms.ChoiceField(choices=task_choices) |
85 task = forms.ChoiceField(choices=task_choices) |
86 return myForm() |
86 return myForm() |
87 |
87 |
88 def AssignCreditForm(choices, instance=None): |
88 def AssignPyntForm(choices, instance=None): |
89 |
89 |
90 class myForm(forms.Form): |
90 class myForm(forms.Form): |
91 user = forms.ChoiceField(choices=choices, required=True) |
91 user = forms.ChoiceField(choices=choices, required=True) |
92 pynts = forms.IntegerField(min_value=0, required=True, help_text="Choose wisely since it cannot be undone.") |
92 pynts = forms.IntegerField(min_value=0, required=True, help_text="Choose wisely since it cannot be undone.") |
93 return myForm(instance) if instance else myForm() |
93 return myForm(instance) if instance else myForm() |