New frozen function

This commit is contained in:
Ludovic Stephan 2021-02-24 00:25:48 +01:00
parent 4136cb6868
commit 1e44550e12
2 changed files with 15 additions and 0 deletions

View file

@ -2,6 +2,9 @@ from django.contrib.auth.decorators import user_passes_test
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")

View file

@ -1055,6 +1055,9 @@ def kpsul_perform_operations(request):
)
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
# + operationgroup + calculating other stuffs
for operation in operations:
@ -1676,7 +1679,11 @@ def perform_transfers(request):
negative_accounts = []
# Checking if ok on all accounts
frozen = set()
for account in to_accounts_balances:
if account.is_frozen:
frozen.add(account.trigramme)
(perms, stop) = account.perms_to_perform_operation(
amount=to_accounts_balances[account]
)
@ -1685,6 +1692,11 @@ def perform_transfers(request):
if stop:
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):
missing_perms = get_missing_perms(required_perms, request.user)
if missing_perms: