Rename List model to TaskList
This commit is contained in:
parent
774cd3d057
commit
efc2dbe11a
10 changed files with 130 additions and 90 deletions
|
@ -1,20 +1,20 @@
|
|||
from django import forms
|
||||
from django.forms import ModelForm
|
||||
from django.contrib.auth.models import Group
|
||||
from todo.models import Item, List
|
||||
from todo.models import Item, TaskList
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
|
||||
class AddListForm(ModelForm):
|
||||
class AddTaskListForm(ModelForm):
|
||||
# The picklist showing allowable groups to which a new list can be added
|
||||
# determines which groups the user belongs to. This queries the form object
|
||||
# to derive that list.
|
||||
def __init__(self, user, *args, **kwargs):
|
||||
super(AddListForm, self).__init__(*args, **kwargs)
|
||||
super(AddTaskListForm, self).__init__(*args, **kwargs)
|
||||
self.fields['group'].queryset = Group.objects.filter(user=user)
|
||||
|
||||
class Meta:
|
||||
model = List
|
||||
model = TaskList
|
||||
exclude = []
|
||||
|
||||
|
||||
|
@ -23,19 +23,21 @@ class AddItemForm(ModelForm):
|
|||
# must find other members of the groups the current list belongs to.
|
||||
def __init__(self, task_list, *args, **kwargs):
|
||||
super(AddItemForm, self).__init__(*args, **kwargs)
|
||||
# print dir(self.fields['list'])
|
||||
# print self.fields['list'].initial
|
||||
# debug:
|
||||
# print(dir(self.fields['list']))
|
||||
# print(self.fields['list'].initial)
|
||||
self.fields['assigned_to'].queryset = get_user_model().objects.filter(groups__in=[task_list.group])
|
||||
self.fields['assigned_to'].label_from_instance = \
|
||||
lambda obj: "%s (%s)" % (obj.get_full_name(), obj.username)
|
||||
|
||||
due_date = forms.DateField(widget=forms.DateInput(attrs={'type': 'date'}), required=False)
|
||||
due_date = forms.DateField(
|
||||
widget=forms.DateInput(attrs={'type': 'date'}), required=False)
|
||||
|
||||
title = forms.CharField(
|
||||
widget=forms.widgets.TextInput(attrs={'size': 35})
|
||||
)
|
||||
widget=forms.widgets.TextInput(attrs={'size': 35}))
|
||||
|
||||
note = forms.CharField(widget=forms.Textarea(), required=False)
|
||||
note = forms.CharField(
|
||||
widget=forms.Textarea(), required=False)
|
||||
|
||||
class Meta:
|
||||
model = Item
|
||||
|
@ -47,7 +49,7 @@ class EditItemForm(ModelForm):
|
|||
# must find other members of the groups the current list belongs to.
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EditItemForm, self).__init__(*args, **kwargs)
|
||||
self.fields['assigned_to'].queryset = get_user_model().objects.filter(groups__in=[self.instance.list.group])
|
||||
self.fields['assigned_to'].queryset = get_user_model().objects.filter(groups__in=[self.instance.task_list.group])
|
||||
|
||||
due_date = forms.DateField(widget=forms.DateInput(attrs={'type': 'date'}), required=False)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue