Fix doublespace listing of Groups on AddList form
This commit is contained in:
parent
b3194da825
commit
e4643eea26
4 changed files with 6 additions and 9 deletions
|
@ -13,6 +13,8 @@ class AddTaskListForm(ModelForm):
|
||||||
def __init__(self, user, *args, **kwargs):
|
def __init__(self, user, *args, **kwargs):
|
||||||
super(AddTaskListForm, self).__init__(*args, **kwargs)
|
super(AddTaskListForm, self).__init__(*args, **kwargs)
|
||||||
self.fields['group'].queryset = Group.objects.filter(user=user)
|
self.fields['group'].queryset = Group.objects.filter(user=user)
|
||||||
|
self.fields['group'].widget.attrs = {
|
||||||
|
'id': 'id_group', 'class': "custom-select mb-3", 'name': 'group'}
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = TaskList
|
model = TaskList
|
||||||
|
@ -25,7 +27,7 @@ class AddEditItemForm(ModelForm):
|
||||||
|
|
||||||
def __init__(self, user, *args, **kwargs):
|
def __init__(self, user, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields['assigned_to'].queryset = get_user_model().objects.filter(groups__in=user.groups.all())
|
self.fields['assigned_to'].queryset = get_user_model().objects.filter(groups__in=user.groups.all()).distinct()
|
||||||
self.fields['assigned_to'].label_from_instance = lambda obj: "%s (%s)" % (obj.get_full_name(), obj.username)
|
self.fields['assigned_to'].label_from_instance = lambda obj: "%s (%s)" % (obj.get_full_name(), obj.username)
|
||||||
self.fields['assigned_to'].widget.attrs = {
|
self.fields['assigned_to'].widget.attrs = {
|
||||||
'id': 'id_assigned_to', 'class': "custom-select mb-3", 'name': 'assigned_to'}
|
'id': 'id_assigned_to', 'class': "custom-select mb-3", 'name': 'assigned_to'}
|
||||||
|
|
|
@ -21,12 +21,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="id_group">Group</label>
|
<label for="id_group">Group</label>
|
||||||
<select id="id_group" name ="group" class="custom-select size="3" mb-3">
|
{{form.group}}
|
||||||
{% for g in form.group %}
|
|
||||||
{{ g }}
|
|
||||||
<option value="{{ g.id }}">{{ g.name }}</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary">Submit</button>
|
<button type="submit" class="btn btn-primary">Submit</button>
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="id_assigned_to">Assigned To</label>
|
<label for="id_assigned_to">Assigned To</label>
|
||||||
{# See todo.forms.AddItemForm #}
|
{# See todo.forms.AddEditItemForm #}
|
||||||
{{form.assigned_to}}
|
{{form.assigned_to}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
{% regroup lists by group as section_list %}
|
{% regroup lists by group as section_list %}
|
||||||
{% for group in section_list %}
|
{% for group in section_list %}
|
||||||
<h3>Group: {{ group.grouper }}</h3>
|
<h3>Group: {{ group.grouper }}</h3>
|
||||||
<ul class="list-group">
|
<ul class="list-group mb-4">
|
||||||
{% for item in group.list %}
|
{% for item in group.list %}
|
||||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||||
<a href="{% url 'todo:list_detail' item.id item.slug %}">{{ item.name }}</a>
|
<a href="{% url 'todo:list_detail' item.id item.slug %}">{{ item.name }}</a>
|
||||||
|
|
Loading…
Reference in a new issue