1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-03-15 02:07:36 +00:00

modify tox.ini to use complex script for make wrapped (bypass C901 in linters)

This commit is contained in:
quark 2025-02-24 18:57:07 +01:00
parent 333f7aa284
commit 30d27459dd
2 changed files with 15 additions and 14 deletions

View File

@ -211,50 +211,50 @@ class Command(BaseCommand):
return return
def convert_to_note(self, change, create, bde=None, user=None, club=None, verb=1): def convert_to_note(self, change, create, bde=None, user=None, club=None, verb=1):
n = [] notes = []
for b in bde: for b in bde:
note = Note.objects.filter(pk__lte=-1) note_for_bde = Note.objects.filter(pk__lte=-1)
if user: if user:
if 'custom' in user[0]: if 'custom' in user[0]:
for u in user[1]: for u in user[1]:
query = Q(noteuser__user=u) query = Q(noteuser__user=u)
note |= Note.objects.filter(query) note_for_bde |= Note.objects.filter(query)
elif user[0] == 'all': elif user[0] == 'all':
query = Q(noteuser__user__pk__gte=-1) query = Q(noteuser__user__pk__gte=-1)
note |= Note.objects.filter(query) note_for_bde |= Note.objects.filter(query)
elif user[0] == 'adh': elif user[0] == 'adh':
m = Membership.objects.filter(club=1, m = Membership.objects.filter(club=1,
date_start__lt=b.date_end, date_start__lt=b.date_end,
date_end__gt=b.date_start, date_end__gt=b.date_start,
).distinct('user') ).distinct('user')
for membership in m: for membership in m:
note |= Note.objects.filter(noteuser__user=membership.user) note_for_bde |= Note.objects.filter(noteuser__user=membership.user)
elif user[0] == 'superuser': elif user[0] == 'superuser':
query |= Q(noteuser__user__is_superuser=True) query |= Q(noteuser__user__is_superuser=True)
note |= Note.objects.filter(query) note_for_bde |= Note.objects.filter(query)
if club: if club:
if 'custom' in club[0]: if 'custom' in club[0]:
for c in club[1]: for c in club[1]:
query = Q(noteclub__club=c) query = Q(noteclub__club=c)
note |= Note.objects.filter(query) note_for_bde |= Note.objects.filter(query)
elif club[0] == 'all': elif club[0] == 'all':
query = Q(noteclub__club__pk__gte=-1) query = Q(noteclub__club__pk__gte=-1)
note |= Note.objects.filter(query) note_for_bde |= Note.objects.filter(query)
elif club[0] == 'active': elif club[0] == 'active':
nc = Note.objects.filter(noteclub__club__pk__gte=-1) nc = Note.objects.filter(noteclub__club__pk__gte=-1)
for noteclub in nc: for noteclub in nc:
if Transaction.objects.filter( if Transaction.objects.filter(
Q(created_at__gte=b.date_start, Q(created_at__gte=b.date_start,
created_at__lte=b.date_end) & (Q(source=noteclub) | Q(destination=noteclub))): created_at__lte=b.date_end) & (Q(source=noteclub) | Q(destination=noteclub))):
note |= Note.objects.filter(pk=n.pk) note_for_bde |= Note.objects.filter(pk=noteclub.pk)
note = self.filter_note(b, note, change, create, verb=verb) note_for_bde = self.filter_note(b, note_for_bde, change, create, verb=verb)
n.append(note) notes.append(note_for_bde)
if verb >= 2: if verb >= 2:
print("\033[m{nb} note selectionned for bde {bde}".format(nb=len(note), bde=b.name)) print("\033[m{nb} note selectionned for bde {bde}".format(nb=len(note_for_bde), bde=b.name))
return n return notes
def global_data(self, bde, verb=1): def global_data(self, bde, verb=1):
data = {} data = {}

View File

@ -32,7 +32,8 @@ deps =
pep8-naming pep8-naming
pyflakes pyflakes
commands = commands =
flake8 apps --extend-exclude apps/scripts flake8 apps --extend-exclude apps/scripts,apps/wrapped/management/commands
flake8 apps/wrapped/management/commands --extend-ignore=C901
[flake8] [flake8]
ignore = W503, I100, I101, B019 ignore = W503, I100, I101, B019