mirror of
				https://gitlab.crans.org/bde/nk20-scripts
				synced 2025-11-04 08:32:10 +01:00 
			
		
		
		
	Prevent also club owners when the note balance is negative
This commit is contained in:
		@@ -102,7 +102,7 @@ class Command(ImportCommand):
 | 
				
			|||||||
                "pk": pk_note,
 | 
					                "pk": pk_note,
 | 
				
			||||||
                "balance": row['solde'],
 | 
					                "balance": row['solde'],
 | 
				
			||||||
                "last_negative": None,
 | 
					                "last_negative": None,
 | 
				
			||||||
                "is_active": True,
 | 
					                "is_active": not row["bloque"],
 | 
				
			||||||
                "display_image": "pic/default.png",
 | 
					                "display_image": "pic/default.png",
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if row["last_negatif"] is not None:
 | 
					            if row["last_negatif"] is not None:
 | 
				
			||||||
@@ -126,7 +126,7 @@ class Command(ImportCommand):
 | 
				
			|||||||
                    "first_name": row["prenom"],
 | 
					                    "first_name": row["prenom"],
 | 
				
			||||||
                    "last_name": row["nom"],
 | 
					                    "last_name": row["nom"],
 | 
				
			||||||
                    "email": row["mail"],
 | 
					                    "email": row["mail"],
 | 
				
			||||||
                    "is_active": True,  # temporary
 | 
					                    "is_active": not row["bloque"],
 | 
				
			||||||
                    "date_joined": make_aware(MAP_IDBDE_PROMOTION[row["idbde"]]["created_at"]),
 | 
					                    "date_joined": make_aware(MAP_IDBDE_PROMOTION[row["idbde"]]["created_at"]),
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                profile_dict = {
 | 
					                profile_dict = {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,10 +5,11 @@ from datetime import date
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
from django.core.mail import send_mail
 | 
					from django.core.mail import send_mail
 | 
				
			||||||
from django.core.management import BaseCommand
 | 
					from django.core.management import BaseCommand
 | 
				
			||||||
 | 
					from django.db.models import Q
 | 
				
			||||||
from django.template.loader import render_to_string
 | 
					from django.template.loader import render_to_string
 | 
				
			||||||
from django.utils.translation import activate
 | 
					from django.utils.translation import activate
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from note.models import NoteUser
 | 
					from note.models import NoteUser, Note
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Command(BaseCommand):
 | 
					class Command(BaseCommand):
 | 
				
			||||||
@@ -20,9 +21,10 @@ class Command(BaseCommand):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def handle(self, *args, **options):
 | 
					    def handle(self, *args, **options):
 | 
				
			||||||
        activate('fr')
 | 
					        activate('fr')
 | 
				
			||||||
        notes = NoteUser.objects.filter(
 | 
					        notes = Note.objects.filter(
 | 
				
			||||||
 | 
					            Q(noteuser__user__memberships__date_end__gte=date.today()) | Q(noteclub__isnull=False),
 | 
				
			||||||
            balance__lte=-options["negative_amount"],
 | 
					            balance__lte=-options["negative_amount"],
 | 
				
			||||||
            user__memberships__date_end__gte=date.today(),
 | 
					            is_active=True,
 | 
				
			||||||
        ).order_by('balance').distinct().all()
 | 
					        ).order_by('balance').distinct().all()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if options["spam"]:
 | 
					        if options["spam"]:
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user