New frozen function
This commit is contained in:
parent
4136cb6868
commit
1e44550e12
2 changed files with 15 additions and 0 deletions
|
@ -2,6 +2,9 @@ from django.contrib.auth.decorators import user_passes_test
|
||||||
|
|
||||||
|
|
||||||
def kfet_is_team(user):
|
def kfet_is_team(user):
|
||||||
|
if hasattr(user.profile, "account_kfet") and user.profile.account_kfet.is_frozen:
|
||||||
|
return False
|
||||||
|
|
||||||
return user.has_perm("kfet.is_team")
|
return user.has_perm("kfet.is_team")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1055,6 +1055,9 @@ def kpsul_perform_operations(request):
|
||||||
)
|
)
|
||||||
need_comment = operationgroup.on_acc.need_comment
|
need_comment = operationgroup.on_acc.need_comment
|
||||||
|
|
||||||
|
if operationgroup.on_acc.is_frozen:
|
||||||
|
data["errors"]["frozen"] = [operationgroup.on_acc.trigramme]
|
||||||
|
|
||||||
# Filling data of each operations
|
# Filling data of each operations
|
||||||
# + operationgroup + calculating other stuffs
|
# + operationgroup + calculating other stuffs
|
||||||
for operation in operations:
|
for operation in operations:
|
||||||
|
@ -1676,7 +1679,11 @@ def perform_transfers(request):
|
||||||
|
|
||||||
negative_accounts = []
|
negative_accounts = []
|
||||||
# Checking if ok on all accounts
|
# Checking if ok on all accounts
|
||||||
|
frozen = set()
|
||||||
for account in to_accounts_balances:
|
for account in to_accounts_balances:
|
||||||
|
if account.is_frozen:
|
||||||
|
frozen.add(account.trigramme)
|
||||||
|
|
||||||
(perms, stop) = account.perms_to_perform_operation(
|
(perms, stop) = account.perms_to_perform_operation(
|
||||||
amount=to_accounts_balances[account]
|
amount=to_accounts_balances[account]
|
||||||
)
|
)
|
||||||
|
@ -1685,6 +1692,11 @@ def perform_transfers(request):
|
||||||
if stop:
|
if stop:
|
||||||
negative_accounts.append(account.trigramme)
|
negative_accounts.append(account.trigramme)
|
||||||
|
|
||||||
|
print(frozen, len(frozen))
|
||||||
|
if len(frozen):
|
||||||
|
data["errors"]["frozen"] = list(frozen)
|
||||||
|
return JsonResponse(data, status=400)
|
||||||
|
|
||||||
if stop_all or not request.user.has_perms(required_perms):
|
if stop_all or not request.user.has_perms(required_perms):
|
||||||
missing_perms = get_missing_perms(required_perms, request.user)
|
missing_perms = get_missing_perms(required_perms, request.user)
|
||||||
if missing_perms:
|
if missing_perms:
|
||||||
|
|
Loading…
Reference in a new issue