From 9bbc09dba82b8b58a3b4e468e471e1a27e4ca667 Mon Sep 17 00:00:00 2001 From: shantisuresh01 Date: Mon, 28 Nov 2016 16:15:46 -0500 Subject: [PATCH 1/4] forms.py: used get_user_model() inside __init__ instead of User, to facilitate late binding, models.py: used settings.AUTH_USER_MODEL instead of user --- todo/forms.py | 6 +++--- todo/models.py | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/todo/forms.py b/todo/forms.py index 36a9340..ee56d6e 100644 --- a/todo/forms.py +++ b/todo/forms.py @@ -1,6 +1,6 @@ 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 @@ -24,7 +24,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 +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 = 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..0c5dc53 100644 --- a/todo/models.py +++ b/todo/models.py @@ -2,10 +2,11 @@ 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 +44,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 +78,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) From 10df9f2cdf5c6d3f9b7cd4dce1056f2408f7c46a Mon Sep 17 00:00:00 2001 From: shantisuresh01 Date: Wed, 30 Nov 2016 16:32:22 -0500 Subject: [PATCH 2/4] view_list.html: Changed del_task to del_tasks, views.py: Changed del_task back to del_tasks --- todo/__init__.py | 10 ---------- todo/forms.py | 2 ++ todo/models.py | 1 + todo/templates/todo/view_list.html | 6 +++--- todo/views.py | 2 +- todo/werid_folder/py.py | 10 ++++++++++ todo/werid_folder/weird.py | 0 7 files changed, 17 insertions(+), 14 deletions(-) create mode 100644 todo/werid_folder/py.py create mode 100644 todo/werid_folder/weird.py diff --git a/todo/__init__.py b/todo/__init__.py index debe07b..e69de29 100644 --- a/todo/__init__.py +++ b/todo/__init__.py @@ -1,10 +0,0 @@ -""" -A multi-user, multi-group task management and assignment system for Django. -""" -__version__ = '1.6' - -__author__ = 'Scot Hacker' -__email__ = 'shacker@birdhouse.org' - -__url__ = 'https://github.com/shacker/django-todo' -__license__ = 'BSD License' diff --git a/todo/forms.py b/todo/forms.py index ee56d6e..77b7657 100644 --- a/todo/forms.py +++ b/todo/forms.py @@ -2,6 +2,8 @@ from django import forms from django.forms import ModelForm from django.contrib.auth.models import Group from todo.models import Item, List +from django.contrib.auth import get_user_model + class AddListForm(ModelForm): diff --git a/todo/models.py b/todo/models.py index 0c5dc53..345829d 100644 --- a/todo/models.py +++ b/todo/models.py @@ -9,6 +9,7 @@ from django.utils.encoding import python_2_unicode_compatible from django.conf import settings + @python_2_unicode_compatible class List(models.Model): name = models.CharField(max_length=60) 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 diff --git a/todo/werid_folder/py.py b/todo/werid_folder/py.py new file mode 100644 index 0000000..debe07b --- /dev/null +++ b/todo/werid_folder/py.py @@ -0,0 +1,10 @@ +""" +A multi-user, multi-group task management and assignment system for Django. +""" +__version__ = '1.6' + +__author__ = 'Scot Hacker' +__email__ = 'shacker@birdhouse.org' + +__url__ = 'https://github.com/shacker/django-todo' +__license__ = 'BSD License' diff --git a/todo/werid_folder/weird.py b/todo/werid_folder/weird.py new file mode 100644 index 0000000..e69de29 From 358acf315d3f4aafad9ee33ca411b37d9942c075 Mon Sep 17 00:00:00 2001 From: shantisuresh01 Date: Wed, 30 Nov 2016 16:33:38 -0500 Subject: [PATCH 3/4] removed unneeded temp folder --- todo/werid_folder/py.py | 10 ---------- todo/werid_folder/weird.py | 0 2 files changed, 10 deletions(-) delete mode 100644 todo/werid_folder/py.py delete mode 100644 todo/werid_folder/weird.py diff --git a/todo/werid_folder/py.py b/todo/werid_folder/py.py deleted file mode 100644 index debe07b..0000000 --- a/todo/werid_folder/py.py +++ /dev/null @@ -1,10 +0,0 @@ -""" -A multi-user, multi-group task management and assignment system for Django. -""" -__version__ = '1.6' - -__author__ = 'Scot Hacker' -__email__ = 'shacker@birdhouse.org' - -__url__ = 'https://github.com/shacker/django-todo' -__license__ = 'BSD License' diff --git a/todo/werid_folder/weird.py b/todo/werid_folder/weird.py deleted file mode 100644 index e69de29..0000000 From 1a0d6416502243e28024a0e6bee0816784e005c9 Mon Sep 17 00:00:00 2001 From: shantisuresh01 Date: Thu, 1 Dec 2016 09:38:55 -0500 Subject: [PATCH 4/4] Restored __init__.py --- todo/__init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/todo/__init__.py b/todo/__init__.py index e69de29..debe07b 100644 --- a/todo/__init__.py +++ b/todo/__init__.py @@ -0,0 +1,10 @@ +""" +A multi-user, multi-group task management and assignment system for Django. +""" +__version__ = '1.6' + +__author__ = 'Scot Hacker' +__email__ = 'shacker@birdhouse.org' + +__url__ = 'https://github.com/shacker/django-todo' +__license__ = 'BSD License'