diff --git a/todo/forms.py b/todo/forms.py index 36a9340..77b7657 100644 --- a/todo/forms.py +++ b/todo/forms.py @@ -1,7 +1,9 @@ from django import forms from django.forms import ModelForm -from django.contrib.auth.models import User, Group +from django.contrib.auth.models import Group from todo.models import Item, List +from django.contrib.auth import get_user_model + class AddListForm(ModelForm): @@ -24,7 +26,7 @@ class AddItemForm(ModelForm): super(AddItemForm, self).__init__(*args, **kwargs) # print dir(self.fields['list']) # print self.fields['list'].initial - self.fields['assigned_to'].queryset = User.objects.filter(groups__in=[task_list.group]) + 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) @@ -49,7 +51,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 = User.objects.filter(groups__in=[self.instance.list.group]) + self.fields['assigned_to'].queryset = get_user_model().objects.filter(groups__in=[self.instance.list.group]) class Meta: model = Item diff --git a/todo/models.py b/todo/models.py index 742dbed..345829d 100644 --- a/todo/models.py +++ b/todo/models.py @@ -2,10 +2,12 @@ from __future__ import unicode_literals import datetime from django.db import models -from django.contrib.auth.models import User, Group +from django.contrib.auth.models import Group from django.template.defaultfilters import slugify from django.core.urlresolvers import reverse from django.utils.encoding import python_2_unicode_compatible +from django.conf import settings + @python_2_unicode_compatible @@ -43,8 +45,8 @@ class Item(models.Model): due_date = models.DateField(blank=True, null=True, ) completed = models.BooleanField(default=None) completed_date = models.DateField(blank=True, null=True) - created_by = models.ForeignKey(User, related_name='todo_created_by') - assigned_to = models.ForeignKey(User, blank=True, null=True, related_name='todo_assigned_to') + created_by = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='todo_created_by') + assigned_to = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True, related_name='todo_assigned_to') note = models.TextField(blank=True, null=True) priority = models.PositiveIntegerField() @@ -77,7 +79,7 @@ class Comment(models.Model): Not using Django's built-in comments because we want to be able to save a comment and change task details at the same time. Rolling our own since it's easy. """ - author = models.ForeignKey(User) + author = models.ForeignKey(settings.AUTH_USER_MODEL) task = models.ForeignKey(Item) date = models.DateTimeField(default=datetime.datetime.now) body = models.TextField(blank=True) diff --git a/todo/templates/todo/view_list.html b/todo/templates/todo/view_list.html index 535643a..1a27d38 100644 --- a/todo/templates/todo/view_list.html +++ b/todo/templates/todo/view_list.html @@ -112,13 +112,13 @@ {% if list_slug == "mine" %} {{ task.list }} {% endif %} - + {% endfor %}

-

View completed tasks

+

View completed tasks

{% else %} @@ -153,7 +153,7 @@

-

View incomplete tasks

+

View incomplete tasks

{% endif %} {% if user.is_staff %} diff --git a/todo/views.py b/todo/views.py index d10d4e3..76a28fd 100644 --- a/todo/views.py +++ b/todo/views.py @@ -14,7 +14,7 @@ from django.template.loader import render_to_string from django.views.decorators.csrf import csrf_exempt from django.contrib.sites.models import Site -from todo import settings +from todo import settings from todo.forms import AddListForm, AddItemForm, EditItemForm, AddExternalItemForm, SearchForm from todo.models import Item, List, Comment from todo.utils import mark_done, undo_completed_task, del_tasks, send_notify_mail