equal
deleted
inserted
replaced
1 from django import forms |
1 from django import forms |
2 from pytask.taskapp.models import Task, Claim |
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', 'credits'] |
51 class myform(forms.Form): |
51 class myform(forms.Form): |
52 mentor = forms.ChoiceField(choices=choices, required=True) |
52 mentor = forms.ChoiceField(choices=choices, required=True) |
53 form = myform(instance) if instance else myform() |
53 form = myform(instance) if instance else myform() |
54 return form |
54 return form |
55 |
55 |
56 class ClaimTaskForm(forms.ModelForm): |
56 class ClaimTaskForm(forms.Form): |
57 class Meta: |
57 message = forms.CharField(label="Proposal") |
58 model = Claim |
58 |
59 fields = ['message'] |
59 def clean_message(self): |
|
60 data = self.cleaned_data['message'].strip() |
|
61 if not data: |
|
62 raise forms.ValidationError('Enter something as a proposal') |
|
63 return data |
|
64 |
60 |
65 |
61 def ChoiceForm(choices, instance=None): |
66 def ChoiceForm(choices, instance=None): |
62 """ return a form object with appropriate choices """ |
67 """ return a form object with appropriate choices """ |
63 |
68 |
64 class myform(forms.Form): |
69 class myform(forms.Form): |