From 92ec85dbbdf65e16da7595d6ae30eae8698a49d9 Mon Sep 17 00:00:00 2001 From: Hugo Manet Date: Wed, 7 Dec 2016 21:35:27 +0100 Subject: [PATCH 1/9] =?UTF-8?q?Ajout=20d'un=20.distinct()=20dans=20la=20se?= =?UTF-8?q?lection=20des=20articles=20li=C3=A9s=20=C3=A0=20un=20supplier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kfet/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/kfet/views.py b/kfet/views.py index 3f1e1f4d..039aa65a 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -1679,6 +1679,7 @@ def order_create(request, pk): articles = (Article.objects .filter(suppliers=supplier.pk) + .distinct() .select_related('category') .order_by('category__name', 'name')) From 783332bbe0f4548bedc60b4e64437f7e6054f6a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michele=20Orr=C3=B9?= Date: Mon, 19 Dec 2016 19:41:50 +0100 Subject: [PATCH 2/9] Fix #117. Not tested because there's no unittests. Reviewed by @manet. --- kfet/templates/kfet/kpsul.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kfet/templates/kfet/kpsul.html b/kfet/templates/kfet/kpsul.html index 88f8f2f9..5d84b926 100644 --- a/kfet/templates/kfet/kpsul.html +++ b/kfet/templates/kfet/kpsul.html @@ -906,7 +906,7 @@ $(document).ready(function() { var title = is_checkout ? 'Montant de la charge' : "Montant de l'édition"; $.confirm({ title: title, - content: '', + content: '', backgroundDismiss: true, animation:'top', closeAnimation:'bottom', @@ -933,7 +933,7 @@ $(document).ready(function() { function askWithdraw() { $.confirm({ title: 'Montant du retrait', - content: '', + content: '', backgroundDismiss: true, animation:'top', closeAnimation:'bottom', @@ -1097,7 +1097,7 @@ $(document).ready(function() { function askAddcost(errors = '') { $.confirm({ title: 'Majoration', - content: errors + '', + content: errors + '', backgroundDismiss: true, animation:'top', closeAnimation:'bottom', From a400832c6d42fdb25652473c471698b5aa08416f Mon Sep 17 00:00:00 2001 From: Qwann Date: Tue, 31 Jan 2017 15:55:38 +0100 Subject: [PATCH 3/9] fixing stock update --- kfet/templates/kfet/kpsul.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kfet/templates/kfet/kpsul.html b/kfet/templates/kfet/kpsul.html index 70cf4ba9..862ff20c 100644 --- a/kfet/templates/kfet/kpsul.html +++ b/kfet/templates/kfet/kpsul.html @@ -1251,7 +1251,7 @@ $(document).ready(function() { } for (var i=0; i Date: Tue, 31 Jan 2017 15:55:38 +0100 Subject: [PATCH 4/9] fixes #127 fixing stock update --- kfet/templates/kfet/kpsul.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kfet/templates/kfet/kpsul.html b/kfet/templates/kfet/kpsul.html index 70cf4ba9..862ff20c 100644 --- a/kfet/templates/kfet/kpsul.html +++ b/kfet/templates/kfet/kpsul.html @@ -1251,7 +1251,7 @@ $(document).ready(function() { } for (var i=0; i Date: Tue, 31 Jan 2017 16:35:52 -0200 Subject: [PATCH 5/9] fixes #87 --- kfet/forms.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/kfet/forms.py b/kfet/forms.py index 0c563b04..fe2e4a9c 100644 --- a/kfet/forms.py +++ b/kfet/forms.py @@ -1,21 +1,17 @@ # -*- coding: utf-8 -*- -from __future__ import (absolute_import, division, - print_function, unicode_literals) -from builtins import * - from decimal import Decimal from django import forms from django.core.exceptions import ValidationError from django.core.validators import MinLengthValidator from django.contrib.auth.models import User, Group, Permission from django.contrib.contenttypes.models import ContentType -from django.forms import modelformset_factory, inlineformset_factory -from django.forms.models import BaseInlineFormSet +from django.forms import modelformset_factory from django.utils import timezone -from kfet.models import (Account, Checkout, Article, OperationGroup, Operation, +from kfet.models import ( + Account, Checkout, Article, OperationGroup, Operation, CheckoutStatement, ArticleCategory, Settings, AccountNegative, Transfer, - TransferGroup, Supplier, Inventory, InventoryArticle) + TransferGroup, Supplier) from gestioncof.models import CofProfile # ----- @@ -131,7 +127,16 @@ class UserRestrictTeamForm(UserForm): class UserGroupForm(forms.ModelForm): groups = forms.ModelMultipleChoiceField( - Group.objects.filter(name__icontains='K-Fêt')) + Group.objects.filter(name__icontains='K-Fêt'), + required=False) + + def clean_groups(self): + groups = self.cleaned_data.get('groups') + # Si aucun groupe, on le dénomme + if not groups: + groups = self.instance.groups.exclude(name__icontains='K-Fêt') + return groups + class Meta: model = User fields = ['groups'] From bc14205d29bb5ed8c80ff285589eba4ea8304dd4 Mon Sep 17 00:00:00 2001 From: Qwann Date: Wed, 1 Feb 2017 19:32:18 +0100 Subject: [PATCH 6/9] fixing decimal issue2 --- kfet/templatetags/kfet_tags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kfet/templatetags/kfet_tags.py b/kfet/templatetags/kfet_tags.py index 59840b27..2dd704b6 100644 --- a/kfet/templatetags/kfet_tags.py +++ b/kfet/templatetags/kfet_tags.py @@ -40,6 +40,6 @@ def highlight_clipper(clipper, q): @register.filter() def ukf(balance, is_cof): - grant = is_cof and (1 + Settings.SUBVENTION_COF() / 100) or 1 + grant = 1 + float(Settings.SUBVENTION_COF()) / 100 if is_cof else 1. # float nécessaire car sinon problème avec le round de future.builtins return floor(float(balance) * 10 * grant) From 44202811ae09e118482db18092b435504ef8dac4 Mon Sep 17 00:00:00 2001 From: Qwann Date: Sun, 5 Feb 2017 22:39:20 +0100 Subject: [PATCH 7/9] not supporting future.builtins anymore in templatetags --- kfet/templatetags/kfet_tags.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kfet/templatetags/kfet_tags.py b/kfet/templatetags/kfet_tags.py index 2dd704b6..3b1bb639 100644 --- a/kfet/templatetags/kfet_tags.py +++ b/kfet/templatetags/kfet_tags.py @@ -40,6 +40,5 @@ def highlight_clipper(clipper, q): @register.filter() def ukf(balance, is_cof): - grant = 1 + float(Settings.SUBVENTION_COF()) / 100 if is_cof else 1. - # float nécessaire car sinon problème avec le round de future.builtins - return floor(float(balance) * 10 * grant) + grant = is_cof and (1 + Settings.SUBVENTION_COF() / 100) or 1 + return floor(balance * 10 * grant) From 8d0f8036393ea8563edd57757abceb853db83a45 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Mon, 6 Feb 2017 16:42:19 -0200 Subject: [PATCH 8/9] Corrige l'affichage du prix fixes #128 --- kfet/static/kfet/js/kfet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kfet/static/kfet/js/kfet.js b/kfet/static/kfet/js/kfet.js index 31758c36..e3e5a6d9 100644 --- a/kfet/static/kfet/js/kfet.js +++ b/kfet/static/kfet/js/kfet.js @@ -39,7 +39,7 @@ function amountDisplay(amount, is_cof=false, tri='') { function amountToUKF(amount, is_cof=false) { var coef_cof = is_cof ? 1 + settings['subvention_cof'] / 100 : 1; - return Math.floor(amount * coef_cof * 10); + return Math.round(amount * coef_cof * 10); } function isValidTrigramme(trigramme) { From 3fa0e4de6c083db2793f2250cedbfec987f0dc32 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Sun, 12 Feb 2017 19:05:41 -0200 Subject: [PATCH 9/9] different rounding for accounts --- kfet/static/kfet/js/kfet.js | 5 +++-- kfet/templates/kfet/kpsul.html | 16 ++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/kfet/static/kfet/js/kfet.js b/kfet/static/kfet/js/kfet.js index e3e5a6d9..bab21c12 100644 --- a/kfet/static/kfet/js/kfet.js +++ b/kfet/static/kfet/js/kfet.js @@ -37,9 +37,10 @@ function amountDisplay(amount, is_cof=false, tri='') { return amountToUKF(amount, is_cof); } -function amountToUKF(amount, is_cof=false) { +function amountToUKF(amount, is_cof=false, account=false) { + var rounding = account ? Math.floor : Math.round ; var coef_cof = is_cof ? 1 + settings['subvention_cof'] / 100 : 1; - return Math.round(amount * coef_cof * 10); + return rounding(amount * coef_cof * 10); } function isValidTrigramme(trigramme) { diff --git a/kfet/templates/kfet/kpsul.html b/kfet/templates/kfet/kpsul.html index fb59060b..e064a10c 100644 --- a/kfet/templates/kfet/kpsul.html +++ b/kfet/templates/kfet/kpsul.html @@ -221,7 +221,7 @@ $(document).ready(function() { function displayAccountData() { var balance = account_data['trigramme'] != 'LIQ' ? account_data['balance'] : ''; if (balance != '') - balance = amountToUKF(account_data['balance'], account_data['is_cof']); + balance = amountToUKF(account_data['balance'], account_data['is_cof'], true); var is_cof = account_data['trigramme'] ? account_data['is_cof'] : ''; if (is_cof !== '') is_cof = is_cof ? 'COF' : 'Non-COF'; @@ -616,7 +616,7 @@ $(document).ready(function() { for (var elem in article) { article_html.find('.'+elem).text(article[elem]) } - article_html.find('.price').text(amountToUKF(article['price'], false)); + article_html.find('.price').text(amountToUKF(article['price'], false, false)); var category_html = articles_container .find('#data-category-'+article['category_id']); if (category_html.length == 0) { @@ -834,7 +834,7 @@ $(document).ready(function() { .attr('data-opeindex', index) .find('.number').text(nb).end() .find('.name').text(article_data[0]).end() - .find('.amount').text(amountToUKF(amount_euro, account_data['is_cof'])); + .find('.amount').text(amountToUKF(amount_euro, account_data['is_cof'], false)); basket_container.prepend(article_basket_html); updateBasketRel(); } @@ -848,7 +848,7 @@ $(document).ready(function() { .attr('data-opeindex', index) .find('.number').text(amount+"€").end() .find('.name').text(text).end() - .find('.amount').text(amountToUKF(amount, account_data['is_cof'])); + .find('.amount').text(amountToUKF(amount, account_data['is_cof'], false)); basket_container.prepend(deposit_basket_html); updateBasketRel(); } @@ -861,7 +861,7 @@ $(document).ready(function() { .attr('data-opeindex', index) .find('.number').text(amount+"€").end() .find('.name').text('Retrait').end() - .find('.amount').text(amountToUKF(amount, account_data['is_cof'])); + .find('.amount').text(amountToUKF(amount, account_data['is_cof'], false)); basket_container.prepend(withdraw_basket_html); updateBasketRel(); } @@ -903,7 +903,7 @@ $(document).ready(function() { var amount = $(this).find('#id_form-'+opeindex+'-amount'); if (!deleted && type == "purchase") amount.val(amountEuroPurchase(article_id, article_nb)); - basket_container.find('[data-opeindex='+opeindex+'] .amount').text(amountToUKF(amount.val(), account_data['is_cof'])); + basket_container.find('[data-opeindex='+opeindex+'] .amount').text(amountToUKF(amount.val(), account_data['is_cof'], false)); }); } @@ -922,9 +922,9 @@ $(document).ready(function() { basketrel_html += '
Sur 20€: '+ (20-amount).toFixed(2) +' €
'; } else if (account_data['trigramme'] != '' && !isBasketEmpty()) { var amount = getAmountBasket(); - var amountUKF = amountToUKF(amount, account_data['is_cof']); + var amountUKF = amountToUKF(amount, account_data['is_cof'], false); var newBalance = account_data['balance'] + amount; - var newBalanceUKF = amountToUKF(newBalance, account_data['is_cof']); + var newBalanceUKF = amountToUKF(newBalance, account_data['is_cof'], true); basketrel_html += '
Total: '+amountUKF+'
'; basketrel_html += '
Nouveau solde: '+newBalanceUKF+'
'; if (newBalance < 0)