Merge pull request #24 from bittner/feature/flake8
Add flake8 configuration, address flake8 complaints
This commit is contained in:
commit
1760e4f72a
7 changed files with 22 additions and 24 deletions
4
setup.cfg
Normal file
4
setup.cfg
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
[flake8]
|
||||||
|
max-line-length = 120
|
||||||
|
max-complexity = 10
|
||||||
|
exclude = build,dist,docs/conf.py,todo/migrations,*.egg-info
|
|
@ -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'
|
||||||
|
|
|
@ -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):
|
||||||
|
@ -15,4 +15,4 @@ class CommentAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
admin.site.register(List)
|
admin.site.register(List)
|
||||||
admin.site.register(Comment, CommentAdmin)
|
admin.site.register(Comment, CommentAdmin)
|
||||||
admin.site.register(Item, ItemAdmin)
|
admin.site.register(Item, ItemAdmin)
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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):
|
||||||
|
|
|
@ -166,15 +166,15 @@ 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:
|
||||||
task_list = Item.objects.filter(list=list.id, completed=0)
|
task_list = Item.objects.filter(list=list.id, completed=0)
|
||||||
|
@ -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,
|
||||||
|
@ -308,8 +309,8 @@ def reorder_tasks(request):
|
||||||
newitem.save()
|
newitem.save()
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
||||||
# All views must return an httpresponse of some kind ... without this we get
|
# All views must return an httpresponse of some kind ... without this we get
|
||||||
# error 500s in the log even though things look peachy in the browser.
|
# error 500s in the log even though things look peachy in the browser.
|
||||||
return HttpResponse(status=201)
|
return HttpResponse(status=201)
|
||||||
|
|
||||||
|
|
||||||
|
@ -368,14 +369,13 @@ def add_list(request):
|
||||||
"Most likely a list with the same name in the same group already exists.")
|
"Most likely a list with the same name in the same group already exists.")
|
||||||
else:
|
else:
|
||||||
if request.user.groups.all().count() == 1:
|
if request.user.groups.all().count() == 1:
|
||||||
form = AddListForm(request.user, initial = {"group": request.user.groups.all()[0]})
|
form = AddListForm(request.user, initial={"group": request.user.groups.all()[0]})
|
||||||
else:
|
else:
|
||||||
form = AddListForm(request.user)
|
form = AddListForm(request.user)
|
||||||
|
|
||||||
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):
|
||||||
"""
|
"""
|
||||||
|
@ -409,7 +409,7 @@ def search(request):
|
||||||
# In that case we still need found_items in a queryset so it can be "excluded" below.
|
# In that case we still need found_items in a queryset so it can be "excluded" below.
|
||||||
found_items = Item.objects.all()
|
found_items = Item.objects.all()
|
||||||
|
|
||||||
if 'inc_complete' in request.GET:
|
if 'inc_complete' in request.GET:
|
||||||
found_items = found_items.exclude(completed=True)
|
found_items = found_items.exclude(completed=True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue