diff --git a/kfet/migrations/0018_auto_20160808_0341.py b/kfet/migrations/0018_auto_20160808_0341.py new file mode 100644 index 00000000..384e82b2 --- /dev/null +++ b/kfet/migrations/0018_auto_20160808_0341.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', '0017_auto_20160808_0234'), + ] + + operations = [ + migrations.AlterModelOptions( + name='globalpermissions', + options={'permissions': (('is_team', 'Is part of the team'), ('can_perform_deposit', 'Effectuer une charge'), ('can_perform_negative_operations', 'Enregistrer des commandes en négatif'), ('override_frozen_protection', "Forcer le gel d'un compte")), 'managed': False}, + ), + ] diff --git a/kfet/migrations/0019_auto_20160808_0343.py b/kfet/migrations/0019_auto_20160808_0343.py new file mode 100644 index 00000000..6512b7ea --- /dev/null +++ b/kfet/migrations/0019_auto_20160808_0343.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', '0018_auto_20160808_0341'), + ] + + 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"))}, + ), + ] diff --git a/kfet/models.py b/kfet/models.py index 672a2b0b..5f740d27 100644 --- a/kfet/models.py +++ b/kfet/models.py @@ -94,10 +94,12 @@ class Account(models.Model): return data def perms_to_perform_operation(self, amount): - new_balance = self.balance + amount perms = [] + if self.is_frozen: + perms.append('kfet.override_frozen_protection') + new_balance = self.balance + amount if new_balance < 0: - perms.append('kfet.can_perform_negative_operations') + perms.append('kfet.perform_negative_operations') return perms # Surcharge Méthode save() avec gestions de User et CofProfile @@ -422,9 +424,10 @@ class GlobalPermissions(models.Model): managed = False permissions = ( ('is_team', 'Is part of the team'), - ('can_perform_deposit', 'Peut effectuer une charge'), - ('can_perform_negative_operations', - 'Peut enregistrer des commandes en négatif') + ('perform_deposit', 'Effectuer une charge'), + ('perform_negative_operations', + 'Enregistrer des commandes en négatif'), + ('override_frozen_protection', "Forcer le gel d'un compte"), ) class Settings(models.Model):