Add flake8 configuration, fix flake8 complaints
This commit is contained in:
parent
c408224e02
commit
767eb75e7d
6 changed files with 21 additions and 23 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 @@
|
||||||
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):
|
||||||
|
|
|
@ -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,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):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue