flake8 compliance
This commit is contained in:
parent
a46a484b85
commit
26e96ce5a6
|
@ -3,7 +3,5 @@
|
||||||
flake8
|
flake8
|
||||||
mccabe
|
mccabe
|
||||||
pep8
|
pep8
|
||||||
django-nose
|
django_coverage_plugin
|
||||||
nose
|
|
||||||
coverage
|
coverage
|
||||||
pyflakes
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
try:
|
try:
|
||||||
from .local import *
|
from .local import * # NOQA
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# Dev env by defautl if no local file proviced
|
# Dev env by defautl if no local file proviced
|
||||||
from .dev import *
|
from .dev import * # NOQA
|
||||||
|
|
|
@ -50,7 +50,7 @@ ROOT_URLCONF = 'gwift.urls'
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
'DIRS': [ 'templates' ],
|
'DIRS': ['templates'],
|
||||||
'APP_DIRS': True,
|
'APP_DIRS': True,
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
'context_processors': [
|
'context_processors': [
|
||||||
|
@ -65,8 +65,6 @@ TEMPLATES = [
|
||||||
|
|
||||||
WSGI_APPLICATION = 'gwift.wsgi.application'
|
WSGI_APPLICATION = 'gwift.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Internationalization
|
# Internationalization
|
||||||
# https://docs.djangoproject.com/en/1.8/topics/i18n/
|
# 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/
|
# https://docs.djangoproject.com/en/1.8/howto/static-files/
|
||||||
|
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from .base import *
|
from .base import * # NOQA
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
@ -8,7 +8,7 @@ SECRET_KEY = '5r4-zjux*_p7@^()pc+0sv(6rc@_vdjmce#!5!tx&qx7)opu$7'
|
||||||
|
|
||||||
for template_engine in TEMPLATES:
|
for template_engine in TEMPLATES:
|
||||||
template_engine['OPTIONS']['debug'] = True
|
template_engine['OPTIONS']['debug'] = True
|
||||||
|
|
||||||
'''INSTALLED_APPS += [
|
'''INSTALLED_APPS += [
|
||||||
'debug_toolbar',
|
'debug_toolbar',
|
||||||
]'''
|
]'''
|
||||||
|
@ -30,4 +30,4 @@ DATABASES = {
|
||||||
|
|
||||||
STATICFILES_DIRS = [
|
STATICFILES_DIRS = [
|
||||||
os.path.join(BASE_DIR, "static"),
|
os.path.join(BASE_DIR, "static"),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from .base import *
|
from .base import * # NOQA
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
|
@ -26,4 +26,3 @@ CSRF_COOKIE_SECURE = True
|
||||||
|
|
||||||
# Same for session cookie
|
# Same for session cookie
|
||||||
SESSION_COOKIE_SECURE = True
|
SESSION_COOKIE_SECURE = True
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
|
from .models import Wishlist, Wish, WishPart
|
||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
admin.site.register(Wishlist)
|
||||||
|
admin.site.register(Wish)
|
||||||
|
admin.site.register(WishPart)
|
||||||
|
|
|
@ -11,11 +11,13 @@ class AbstractModel(models.Model):
|
||||||
created_at = models.DateTimeField(auto_now_add=True)
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
updated_at = models.DateTimeField(auto_now=True)
|
updated_at = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
|
|
||||||
class UnknownUser(models.Model):
|
class UnknownUser(models.Model):
|
||||||
|
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
email = models.CharField(max_length=255, unique=True)
|
email = models.CharField(max_length=255, unique=True)
|
||||||
|
|
||||||
|
|
||||||
class Wishlist(AbstractModel):
|
class Wishlist(AbstractModel):
|
||||||
|
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
|
@ -36,14 +38,14 @@ class Wish(AbstractModel):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def percentage_of_completion(self):
|
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()
|
number_of_linked_parts = WishPart.objects.filter(wish=self).count()
|
||||||
total = self.number_of_parts * self.numbers_available
|
total = self.number_of_parts * self.numbers_available
|
||||||
percentage = (number_of_linked_parts / total)
|
percentage = (number_of_linked_parts / total)
|
||||||
return percentage * 100
|
return percentage * 100
|
||||||
|
|
||||||
|
|
||||||
class WishPart(models.Model):
|
class WishPart(models.Model):
|
||||||
|
|
||||||
wish = models.ForeignKey(Wish)
|
wish = models.ForeignKey(Wish)
|
||||||
|
|
|
@ -1,19 +1,24 @@
|
||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
|
||||||
from django import template
|
from django import template
|
||||||
|
|
||||||
from wish.models import Wishlist
|
from wish.models import Wishlist
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
@register.filter(is_safe=True)
|
@register.filter(is_safe=True)
|
||||||
def add_xx(value):
|
def add_xx(value):
|
||||||
return '%sxx' % value
|
return '%sxx' % value
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def current_time(format_string):
|
def current_time(format_string):
|
||||||
return datetime.datetime.now().strftime(format_string)
|
return datetime.datetime.now().strftime(format_string)
|
||||||
|
|
||||||
|
|
||||||
@register.inclusion_tag('wish/templatetags/wishlists_list.html')
|
@register.inclusion_tag('wish/templatetags/wishlists_list.html')
|
||||||
def wishlists_list():
|
def wishlists_list():
|
||||||
return { 'list': Wishlist.objects.all() }
|
return {'list': Wishlist.objects.all()}
|
||||||
|
|
|
@ -2,34 +2,35 @@ from django.test import TestCase
|
||||||
|
|
||||||
from .models import Wishlist, Wish, WishPart
|
from .models import Wishlist, Wish, WishPart
|
||||||
|
|
||||||
|
|
||||||
class TestWishModel(TestCase):
|
class TestWishModel(TestCase):
|
||||||
def test_percentage_of_completion(self):
|
def test_percentage_of_completion(self):
|
||||||
"""
|
"""
|
||||||
Vérifie que le pourcentage de complétion d'un souhait
|
Vérifie que le pourcentage de complétion d'un souhait
|
||||||
est correctement calculé.
|
est correctement calculé.
|
||||||
"""
|
"""
|
||||||
wishlist = Wishlist(name='Fake WishList',
|
wishlist = Wishlist(name='Fake WishList',
|
||||||
description='This is a faked wishlist')
|
description='This is a faked wishlist')
|
||||||
wishlist.save()
|
wishlist.save()
|
||||||
|
|
||||||
wish = Wish(wishlist=wishlist,
|
wish = Wish(wishlist=wishlist,
|
||||||
name='Fake Wish',
|
name='Fake Wish',
|
||||||
description='This is a faked wish',
|
description='This is a faked wish',
|
||||||
number_of_parts=4)
|
number_of_parts=4)
|
||||||
wish.save()
|
wish.save()
|
||||||
|
|
||||||
part1 = WishPart(wish=wish, comment='part1')
|
part1 = WishPart(wish=wish, comment='part1')
|
||||||
part1.save()
|
part1.save()
|
||||||
self.assertEqual(25, wish.percentage_of_completion)
|
self.assertEqual(25, wish.percentage_of_completion)
|
||||||
|
|
||||||
part2 = WishPart(wish=wish, comment='part2')
|
part2 = WishPart(wish=wish, comment='part2')
|
||||||
part2.save()
|
part2.save()
|
||||||
self.assertEqual(50, wish.percentage_of_completion)
|
self.assertEqual(50, wish.percentage_of_completion)
|
||||||
|
|
||||||
part3 = WishPart(wish=wish, comment='part3')
|
part3 = WishPart(wish=wish, comment='part3')
|
||||||
part3.save()
|
part3.save()
|
||||||
self.assertEqual(75, wish.percentage_of_completion)
|
self.assertEqual(75, wish.percentage_of_completion)
|
||||||
|
|
||||||
part4 = WishPart(wish=wish, comment='part4')
|
part4 = WishPart(wish=wish, comment='part4')
|
||||||
part4.save()
|
part4.save()
|
||||||
self.assertEqual(100, wish.percentage_of_completion)
|
self.assertEqual(100, wish.percentage_of_completion)
|
||||||
|
|
|
@ -4,6 +4,7 @@ from django.views.generic import ListView
|
||||||
|
|
||||||
from .models import Wishlist
|
from .models import Wishlist
|
||||||
|
|
||||||
|
|
||||||
class WishListList(ListView):
|
class WishListList(ListView):
|
||||||
context_object_name = 'wishlists'
|
context_object_name = 'wishlists'
|
||||||
model = Wishlist
|
model = Wishlist
|
||||||
|
|
Loading…
Reference in New Issue