Merge pull request #24 from bittner/feature/flake8

Add flake8 configuration, address flake8 complaints
This commit is contained in:
Scot Hacker 2015-09-02 23:50:24 -07:00
commit 1760e4f72a
7 changed files with 22 additions and 24 deletions

4
setup.cfg Normal file
View file

@ -0,0 +1,4 @@
[flake8]
max-line-length = 120
max-complexity = 10
exclude = build,dist,docs/conf.py,todo/migrations,*.egg-info

View file

@ -1,5 +1,5 @@
"""django todo""" """django todo"""
__version__ = '1.5.dev' __version__ = '1.5'
__author__ = 'Scot Hacker' __author__ = 'Scot Hacker'
__email__ = 'shacker@birdhouse.org' __email__ = 'shacker@birdhouse.org'

View file

@ -1,5 +1,5 @@
from django.contrib import admin from django.contrib import admin
from todo.models import Item, User, List, Comment from todo.models import Item, List, Comment
class ItemAdmin(admin.ModelAdmin): class ItemAdmin(admin.ModelAdmin):

View file

@ -25,9 +25,8 @@ class AddItemForm(ModelForm):
# print dir(self.fields['list']) # print dir(self.fields['list'])
# print self.fields['list'].initial # print self.fields['list'].initial
self.fields['assigned_to'].queryset = User.objects.filter(groups__in=[task_list.group]) self.fields['assigned_to'].queryset = User.objects.filter(groups__in=[task_list.group])
self.fields['assigned_to'].label_from_instance = lambda obj: "%s (%s)" % ( self.fields['assigned_to'].label_from_instance = \
obj.get_full_name(), obj.username) lambda obj: "%s (%s)" % (obj.get_full_name(), obj.username)
due_date = forms.DateField( due_date = forms.DateField(
required=False, required=False,

View file

@ -61,8 +61,7 @@ class Item(models.Model):
return self.title return self.title
def get_absolute_url(self): def get_absolute_url(self):
return reverse('todo-task_detail', return reverse('todo-task_detail', kwargs={'task_id': self.id, })
kwargs={'task_id': self.id,})
# Auto-set the item creation / completed date # Auto-set the item creation / completed date
def save(self): def save(self):
@ -71,7 +70,6 @@ class Item(models.Model):
self.completed_date = datetime.datetime.now() self.completed_date = datetime.datetime.now()
super(Item, self).save() super(Item, self).save()
class Meta: class Meta:
ordering = ["priority"] ordering = ["priority"]
@ -93,5 +91,3 @@ class Comment(models.Model):
def __str__(self): def __str__(self):
return self.snippet return self.snippet

View file

@ -1,6 +1,5 @@
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
from todo.models import List
class MissingSuperuserException(Exception): class MissingSuperuserException(Exception):

View file

@ -166,14 +166,14 @@ def view_list(request, list_id=0, list_slug=None, view_completed=0):
elif list_slug == "recent-add": elif list_slug == "recent-add":
# We'll assume this only includes uncompleted items to avoid confusion. # We'll assume this only includes uncompleted items to avoid confusion.
# Only show items in lists that are in groups that the current user is also in. # Only show items in lists that are in groups that the current user is also in.
task_list = Item.objects.filter(list__group__in=(request.user.groups.all()), completed=0).order_by( task_list = Item.objects.filter(list__group__in=(request.user.groups.all()),
'-created_date')[:50] completed=0).order_by('-created_date')[:50]
# completed_list = Item.objects.filter(assigned_to=request.user, completed=1) # completed_list = Item.objects.filter(assigned_to=request.user, completed=1)
elif list_slug == "recent-complete": elif list_slug == "recent-complete":
# Only show items in lists that are in groups that the current user is also in. # Only show items in lists that are in groups that the current user is also in.
task_list = Item.objects.filter(list__group__in=request.user.groups.all(), completed=1).order_by( task_list = Item.objects.filter(list__group__in=request.user.groups.all(),
'-completed_date')[:50] completed=1).order_by('-completed_date')[:50]
# completed_list = Item.objects.filter(assigned_to=request.user, completed=1) # completed_list = Item.objects.filter(assigned_to=request.user, completed=1)
else: else:
@ -209,7 +209,8 @@ def view_list(request, list_id=0, list_slug=None, view_completed=0):
return HttpResponseRedirect(request.path) return HttpResponseRedirect(request.path)
else: else:
if list_slug != "mine" and list_slug != "recent-add" and list_slug != "recent-complete": # We don't allow adding a task on the "mine" view # We don't allow adding a task on the "mine" view
if list_slug != "mine" and list_slug != "recent-add" and list_slug != "recent-complete":
form = AddItemForm(list, initial={ form = AddItemForm(list, initial={
'assigned_to': request.user.id, 'assigned_to': request.user.id,
'priority': 999, 'priority': 999,
@ -375,7 +376,6 @@ def add_list(request):
return render_to_response('todo/add_list.html', locals(), context_instance=RequestContext(request)) return render_to_response('todo/add_list.html', locals(), context_instance=RequestContext(request))
@user_passes_test(check_user_allowed) @user_passes_test(check_user_allowed)
def search_post(request): def search_post(request):
""" """