diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..789b9c3 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,4 @@ +[flake8] +max-line-length = 120 +max-complexity = 10 +exclude = build,dist,docs/conf.py,todo/migrations,*.egg-info diff --git a/todo/admin.py b/todo/admin.py index 1193a86..9e28467 100644 --- a/todo/admin.py +++ b/todo/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from todo.models import Item, User, List, Comment +from todo.models import Item, List, Comment class ItemAdmin(admin.ModelAdmin): @@ -15,4 +15,4 @@ class CommentAdmin(admin.ModelAdmin): admin.site.register(List) admin.site.register(Comment, CommentAdmin) -admin.site.register(Item, ItemAdmin) \ No newline at end of file +admin.site.register(Item, ItemAdmin) diff --git a/todo/forms.py b/todo/forms.py index 9b1b59d..10ec669 100644 --- a/todo/forms.py +++ b/todo/forms.py @@ -25,9 +25,8 @@ class AddItemForm(ModelForm): # 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'].label_from_instance = lambda obj: "%s (%s)" % ( - obj.get_full_name(), obj.username) - + self.fields['assigned_to'].label_from_instance = \ + lambda obj: "%s (%s)" % (obj.get_full_name(), obj.username) due_date = forms.DateField( required=False, diff --git a/todo/models.py b/todo/models.py index fe29179..becbd78 100644 --- a/todo/models.py +++ b/todo/models.py @@ -61,8 +61,7 @@ class Item(models.Model): return self.title def get_absolute_url(self): - return reverse('todo-task_detail', - kwargs={'task_id': self.id,}) + return reverse('todo-task_detail', kwargs={'task_id': self.id, }) # Auto-set the item creation / completed date def save(self): @@ -71,7 +70,6 @@ class Item(models.Model): self.completed_date = datetime.datetime.now() super(Item, self).save() - class Meta: ordering = ["priority"] @@ -93,5 +91,3 @@ class Comment(models.Model): def __str__(self): return self.snippet - - diff --git a/todo/settings.py b/todo/settings.py index 618c64b..005e736 100644 --- a/todo/settings.py +++ b/todo/settings.py @@ -1,6 +1,5 @@ from django.conf import settings from django.contrib.auth.models import User -from todo.models import List class MissingSuperuserException(Exception): diff --git a/todo/views.py b/todo/views.py index d249f43..8636c6c 100644 --- a/todo/views.py +++ b/todo/views.py @@ -166,15 +166,15 @@ def view_list(request, list_id=0, list_slug=None, view_completed=0): elif list_slug == "recent-add": # 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. - task_list = Item.objects.filter(list__group__in=(request.user.groups.all()), completed=0).order_by( - '-created_date')[:50] - # completed_list = Item.objects.filter(assigned_to=request.user, completed=1) + task_list = Item.objects.filter(list__group__in=(request.user.groups.all()), + completed=0).order_by('-created_date')[:50] + # completed_list = Item.objects.filter(assigned_to=request.user, completed=1) elif list_slug == "recent-complete": # 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( - '-completed_date')[:50] - # completed_list = Item.objects.filter(assigned_to=request.user, completed=1) + task_list = Item.objects.filter(list__group__in=request.user.groups.all(), + completed=1).order_by('-completed_date')[:50] + # completed_list = Item.objects.filter(assigned_to=request.user, completed=1) else: 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) 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={ 'assigned_to': request.user.id, 'priority': 999, @@ -308,8 +309,8 @@ def reorder_tasks(request): newitem.save() i = i + 1 - # 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. + # 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. 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.") else: 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: form = AddListForm(request.user) return render_to_response('todo/add_list.html', locals(), context_instance=RequestContext(request)) - @user_passes_test(check_user_allowed) 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. found_items = Item.objects.all() - if 'inc_complete' in request.GET: + if 'inc_complete' in request.GET: found_items = found_items.exclude(completed=True) else: