Validation commande K-Psul (compte gelé)
- Empêche l'enregistrement de commande sur un compte gelé sans la permission 'kfet.override_frozen_protection' - Modifie les noms de deux permissions pour éviter d'avoir des 'can_...' partout
This commit is contained in:
parent
4c8b23e999
commit
f9c87088fc
3 changed files with 44 additions and 5 deletions
18
kfet/migrations/0018_auto_20160808_0341.py
Normal file
18
kfet/migrations/0018_auto_20160808_0341.py
Normal file
|
@ -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},
|
||||||
|
),
|
||||||
|
]
|
18
kfet/migrations/0019_auto_20160808_0343.py
Normal file
18
kfet/migrations/0019_auto_20160808_0343.py
Normal file
|
@ -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"))},
|
||||||
|
),
|
||||||
|
]
|
|
@ -94,10 +94,12 @@ class Account(models.Model):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def perms_to_perform_operation(self, amount):
|
def perms_to_perform_operation(self, amount):
|
||||||
new_balance = self.balance + amount
|
|
||||||
perms = []
|
perms = []
|
||||||
|
if self.is_frozen:
|
||||||
|
perms.append('kfet.override_frozen_protection')
|
||||||
|
new_balance = self.balance + amount
|
||||||
if new_balance < 0:
|
if new_balance < 0:
|
||||||
perms.append('kfet.can_perform_negative_operations')
|
perms.append('kfet.perform_negative_operations')
|
||||||
return perms
|
return perms
|
||||||
|
|
||||||
# Surcharge Méthode save() avec gestions de User et CofProfile
|
# Surcharge Méthode save() avec gestions de User et CofProfile
|
||||||
|
@ -422,9 +424,10 @@ class GlobalPermissions(models.Model):
|
||||||
managed = False
|
managed = False
|
||||||
permissions = (
|
permissions = (
|
||||||
('is_team', 'Is part of the team'),
|
('is_team', 'Is part of the team'),
|
||||||
('can_perform_deposit', 'Peut effectuer une charge'),
|
('perform_deposit', 'Effectuer une charge'),
|
||||||
('can_perform_negative_operations',
|
('perform_negative_operations',
|
||||||
'Peut enregistrer des commandes en négatif')
|
'Enregistrer des commandes en négatif'),
|
||||||
|
('override_frozen_protection', "Forcer le gel d'un compte"),
|
||||||
)
|
)
|
||||||
|
|
||||||
class Settings(models.Model):
|
class Settings(models.Model):
|
||||||
|
|
Loading…
Reference in a new issue