From 9e66137c09500894319381f2e27b3d47daff445d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Delobelle?= Date: Tue, 23 Aug 2016 15:43:16 +0200 Subject: [PATCH] Commandes sur #13 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Un commentaire est demandé. Une permission est nécessaire (afin d'enregistrer la personne ayant enregistré la commande) - Fix annulation K-Psul. Appuyer sur Suppr appelait tout le temps `cancelOperations` même si aucune opération à supprimer n'était sélectionné. --- kfet/forms.py | 2 +- kfet/migrations/0035_auto_20160823_1505.py | 18 ++++++++ kfet/models.py | 9 +++- kfet/templates/kfet/kpsul.html | 48 ++++++++++++++++++---- kfet/views.py | 6 +++ 5 files changed, 71 insertions(+), 12 deletions(-) create mode 100644 kfet/migrations/0035_auto_20160823_1505.py diff --git a/kfet/forms.py b/kfet/forms.py index 71f5a78e..e39ff9e1 100644 --- a/kfet/forms.py +++ b/kfet/forms.py @@ -222,7 +222,7 @@ class KPsulOperationGroupForm(forms.ModelForm): widget = forms.HiddenInput()) class Meta: model = OperationGroup - fields = ['on_acc', 'checkout'] + fields = ['on_acc', 'checkout', 'comment'] widgets = { 'on_acc' : forms.HiddenInput(), } diff --git a/kfet/migrations/0035_auto_20160823_1505.py b/kfet/migrations/0035_auto_20160823_1505.py new file mode 100644 index 00000000..5fd73ae8 --- /dev/null +++ b/kfet/migrations/0035_auto_20160823_1505.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('kfet', '0034_auto_20160823_0206'), + ] + + operations = [ + migrations.AlterModelOptions( + name='globalpermissions', + options={'managed': False, 'permissions': (('is_team', 'Is part of the team'), ('perform_deposit', 'Effectuer une charge'), ('perform_negative_operations', 'Enregistrer des commandes en négatif'), ('override_frozen_protection', "Forcer le gel d'un compte"), ('cancel_old_operations', 'Annuler des commandes non récentes'), ('manage_perms', 'Gérer les permissions K-Fêt'), ('manage_addcosts', 'Gérer les majorations'), ('perform_commented_operations', 'Enregistrer des commandes avec commentaires'))}, + ), + ] diff --git a/kfet/models.py b/kfet/models.py index 52862f1b..1b03ed8b 100644 --- a/kfet/models.py +++ b/kfet/models.py @@ -86,6 +86,10 @@ class Account(models.Model): def is_cash(self): return self.trigramme == 'LIQ' + @property + def need_comment(self): + return self.trigramme == '#13' + @staticmethod def is_validandfree(trigramme): data = { 'is_valid' : False, 'is_free' : False } @@ -109,13 +113,13 @@ class Account(models.Model): if self.is_cash: # Yes, so no perms and no stop return set(), False + if self.need_comment: + perms.add('kfet.perform_commented_operations') # Checking is frozen account if self.is_frozen: perms.add('kfet.override_frozen_protection') new_balance = self.balance + amount if new_balance < 0 and amount < 0: - print(new_balance) - print(amount) # Retrieving overdraft amount limit if (hasattr(self, 'negative') and self.negative.authz_overdraft_amount is not None): @@ -518,6 +522,7 @@ class GlobalPermissions(models.Model): ('cancel_old_operations', 'Annuler des commandes non récentes'), ('manage_perms', 'Gérer les permissions K-Fêt'), ('manage_addcosts', 'Gérer les majorations'), + ('perform_commented_operations', 'Enregistrer des commandes avec commentaires'), ) class Settings(models.Model): diff --git a/kfet/templates/kfet/kpsul.html b/kfet/templates/kfet/kpsul.html index 4007b286..c27d7f27 100644 --- a/kfet/templates/kfet/kpsul.html +++ b/kfet/templates/kfet/kpsul.html @@ -21,8 +21,6 @@ {% csrf_token %} -
{{ operationgroup_form }}
-
@@ -100,9 +98,8 @@
- + +