diff --git a/todo/forms.py b/todo/forms.py
index bca5925..756e5c8 100644
--- a/todo/forms.py
+++ b/todo/forms.py
@@ -19,16 +19,17 @@ class AddTaskListForm(ModelForm):
exclude = []
-class AddItemForm(ModelForm):
+class AddEditItemForm(ModelForm):
"""The picklist showing the users to which a new task can be assigned
must find other members of the groups the current list belongs to."""
- def __init__(self, task_list, *args, **kwargs):
+ def __init__(self, user, *args, **kwargs):
super().__init__(*args, **kwargs)
- self.fields['assigned_to'].queryset = get_user_model().objects.filter(groups__in=[task_list.group])
+ self.fields['assigned_to'].queryset = get_user_model().objects.filter(groups__in=user.groups.all())
self.fields['assigned_to'].label_from_instance = lambda obj: "%s (%s)" % (obj.get_full_name(), obj.username)
self.fields['assigned_to'].widget.attrs = {
'id': 'id_assigned_to', 'class': "custom-select mb-3", 'name': 'assigned_to'}
+ self.fields['task_list'].value = kwargs['initial']['task_list'].id
due_date = forms.DateField(
widget=forms.DateInput(attrs={'type': 'date'}), required=False)
@@ -44,22 +45,6 @@ class AddItemForm(ModelForm):
exclude = []
-class EditItemForm(ModelForm):
- """The picklist showing the users to which a new task can be assigned
- 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.task_list.group])
-
- due_date = forms.DateField(widget=forms.DateInput(attrs={'type': 'date'}), required=False)
-
- class Meta:
- model = Item
- exclude = ('created_date', 'created_by',)
-
-
class AddExternalItemForm(ModelForm):
"""Form to allow users who are not part of the GTD system to file a ticket."""
diff --git a/todo/templates/todo/include/task_edit.html b/todo/templates/todo/include/task_edit.html
new file mode 100644
index 0000000..8139c16
--- /dev/null
+++ b/todo/templates/todo/include/task_edit.html
@@ -0,0 +1,54 @@
+{# Form used by both Add Task and Edit Task views #}
+
+
diff --git a/todo/templates/todo/list_detail.html b/todo/templates/todo/list_detail.html
index 9b4e499..e8937f2 100644
--- a/todo/templates/todo/list_detail.html
+++ b/todo/templates/todo/list_detail.html
@@ -6,49 +6,11 @@
{% block content %}
{% if list_slug != "mine" %}
-
+ {# Task edit / new task form #}
+ {% include 'todo/include/task_edit.html' %}
{% endif %}
@@ -74,6 +36,7 @@