flake8 compliance

This commit is contained in:
Fred 2016-09-30 13:20:12 +02:00
parent a46a484b85
commit 26e96ce5a6
11 changed files with 41 additions and 28 deletions

View File

@ -3,7 +3,5 @@
flake8
mccabe
pep8
django-nose
nose
django_coverage_plugin
coverage
pyflakes

View File

@ -1,5 +1,5 @@
try:
from .local import *
from .local import * # NOQA
except ImportError:
# Dev env by defautl if no local file proviced
from .dev import *
from .dev import * # NOQA

View File

@ -50,7 +50,7 @@ ROOT_URLCONF = 'gwift.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [ 'templates' ],
'DIRS': ['templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
@ -65,8 +65,6 @@ TEMPLATES = [
WSGI_APPLICATION = 'gwift.wsgi.application'
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
@ -85,4 +83,3 @@ USE_TZ = True
# https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_URL = '/static/'

View File

@ -1,4 +1,4 @@
from .base import *
from .base import * # NOQA
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

View File

@ -1,4 +1,4 @@
from .base import *
from .base import * # NOQA
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
@ -26,4 +26,3 @@ CSRF_COOKIE_SECURE = True
# Same for session cookie
SESSION_COOKIE_SECURE = True

View File

@ -1,3 +1,8 @@
from django.contrib import admin
from .models import Wishlist, Wish, WishPart
# Register your models here.
admin.site.register(Wishlist)
admin.site.register(Wish)
admin.site.register(WishPart)

View File

@ -11,11 +11,13 @@ class AbstractModel(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class UnknownUser(models.Model):
name = models.CharField(max_length=255)
email = models.CharField(max_length=255, unique=True)
class Wishlist(AbstractModel):
name = models.CharField(max_length=255)
@ -36,14 +38,14 @@ class Wish(AbstractModel):
@property
def percentage_of_completion(self):
"""
Calcule le pourcentage de complétion pour un élément.
"""
"""Calcule le pourcentage de complétion pour un élément."""
number_of_linked_parts = WishPart.objects.filter(wish=self).count()
total = self.number_of_parts * self.numbers_available
percentage = (number_of_linked_parts / total)
return percentage * 100
class WishPart(models.Model):
wish = models.ForeignKey(Wish)

View File

@ -1,19 +1,24 @@
# coding=utf-8
import datetime
from django import template
from wish.models import Wishlist
register = template.Library()
@register.filter(is_safe=True)
def add_xx(value):
return '%sxx' % value
@register.simple_tag
def current_time(format_string):
return datetime.datetime.now().strftime(format_string)
@register.inclusion_tag('wish/templatetags/wishlists_list.html')
def wishlists_list():
return { 'list': Wishlist.objects.all() }
return {'list': Wishlist.objects.all()}

View File

@ -2,6 +2,7 @@ from django.test import TestCase
from .models import Wishlist, Wish, WishPart
class TestWishModel(TestCase):
def test_percentage_of_completion(self):
"""

View File

@ -4,6 +4,7 @@ from django.views.generic import ListView
from .models import Wishlist
class WishListList(ListView):
context_object_name = 'wishlists'
model = Wishlist

5
tox.ini Normal file
View File

@ -0,0 +1,5 @@
[flake8]
max-line-length = 100
exclude = migrations, manage.py
max-complexity = 6
ignore = F405