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']