summaryrefslogtreecommitdiff
path: root/app/gtd/forms.py
blob: a4727cffea9e875d2e6706a12d2a074284168b0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from django.forms import ModelForm
from django.forms import ChoiceField

from .models import GTDNote, GTDProject, WiredNote, WiredPost


class GTDNoteCreateForm(ModelForm):
    class Meta:
        model = GTDNote 
        fields = ['title', 'body_markdown', 'project', 'note_type', 'reminder', 'status']


class GTDNoteEditForm(ModelForm):
    class Meta:
        model = GTDNote 
        fields = ['title', 'body_markdown', 'project', 'note_type', 'reminder', 'status']


class GTDProjectCreateForm(ModelForm):
    class Meta:
        model = GTDProject
        fields = ['title', 'body_markdown', 'date_goal', 'project_type', 'outcome']


class GTDProjectUpdateForm(ModelForm):
    class Meta:
        model = GTDProject
        fields = ['title', 'body_markdown', 'date_goal', 'project_type', 'outcome', 'date_ended']


class WiredNoteCreateForm(ModelForm):

    def __init__(self,*args,**kwargs):
        user = kwargs.pop('user')
        self.user = user
        super(WiredNoteCreateForm,self).__init__(*args,**kwargs)
        self.fields['post'].required = False

    def save(self, commit=True):
        self.instance.user = self.user
        return super().save(commit=commit)

    class Meta:
        model = WiredNote 
        fields = ['title', 'url', 'body_markdown', 'post']


class WiredNoteEditForm(ModelForm):

    def __init__(self,*args,**kwargs):
        super(WiredNoteEditForm,self).__init__(*args,**kwargs)
        self.fields['post'].queryset = WiredPost.objects.all().order_by("title")

    def save(self, commit=True):
        return super().save(commit=commit)

    class Meta:
        model = WiredNote 
        fields = ['title', 'url', 'body_markdown', 'post', 'status', 'plan']


class WiredPostUpdateForm(ModelForm):

    class Meta:
        model = WiredPost 
        fields = ['title', 'post_status', 'url', 'template_type', 'update_frequency', 'edit_url', 'date_last_pub']