From 0dd3da5c0197ba985481b7fa308f636d309cb418 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 9 Sep 2021 10:45:36 +0200 Subject: [PATCH] Linting Signed-off-by: Yohann D'ANELLO --- apps/member/hashers.py | 8 ++++---- apps/treasury/models.py | 17 +++++++++-------- apps/wei/views.py | 6 +++--- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/apps/member/hashers.py b/apps/member/hashers.py index a72ed94b..32f8c63e 100644 --- a/apps/member/hashers.py +++ b/apps/member/hashers.py @@ -54,10 +54,10 @@ class CustomNK15Hasher(PBKDF2PasswordHasher): if '|' in encoded: salt, db_hashed_pass = encoded.split('$')[2].split('|') return OrderedDict([ - (_('algorithm'), 'custom_nk15'), - (_('iterations'), '1'), - (_('salt'), mask_hash(salt)), - (_('hash'), mask_hash(db_hashed_pass)), + (_('algorithm'), 'custom_nk15'), + (_('iterations'), '1'), + (_('salt'), mask_hash(salt)), + (_('hash'), mask_hash(db_hashed_pass)), ]) return super().safe_summary(encoded) diff --git a/apps/treasury/models.py b/apps/treasury/models.py index c1089bb8..7e4e1566 100644 --- a/apps/treasury/models.py +++ b/apps/treasury/models.py @@ -3,6 +3,7 @@ from datetime import date +from django.conf import settings from django.contrib.auth.models import User from django.core.exceptions import ValidationError from django.core.validators import MinValueValidator @@ -11,10 +12,8 @@ from django.db.models import Q from django.template.loader import render_to_string from django.utils import timezone from django.utils.translation import gettext_lazy as _ - from member.models import Club, Membership from note.models import NoteSpecial, SpecialTransaction, MembershipTransaction, NoteUser -from wei.models import WEIClub class Invoice(models.Model): @@ -319,10 +318,8 @@ class SogeCredit(models.Model): bde = Club.objects.get(name="BDE") kfet = Club.objects.get(name="Kfet") - wei = WEIClub.objects.order_by('-year').first() bde_qs = Membership.objects.filter(user=self.user, club=bde, date_start__gte=bde.membership_start) kfet_qs = Membership.objects.filter(user=self.user, club=kfet, date_start__gte=kfet.membership_start) - wei_qs = Membership.objects.filter(user=self.user, club=wei, date_start__gte=wei.membership_start) if bde_qs.exists(): m = bde_qs.get() @@ -334,10 +331,14 @@ class SogeCredit(models.Model): if m.transaction not in self.transactions.all(): self.transactions.add(m.transaction) - if wei_qs.exists(): - m = wei_qs.get() - if m.transaction not in self.transactions.all(): - self.transactions.add(m.transaction) + if 'wei' in settings.INSTALLED_APPS: + from wei.models import WEIClub + wei = WEIClub.objects.order_by('-year').first() + wei_qs = Membership.objects.filter(user=self.user, club=wei, date_start__gte=wei.membership_start) + if wei_qs.exists(): + m = wei_qs.get() + if m.transaction not in self.transactions.all(): + self.transactions.add(m.transaction) for tr in self.transactions.all(): tr.valid = False diff --git a/apps/wei/views.py b/apps/wei/views.py index 20243c40..348ac751 100644 --- a/apps/wei/views.py +++ b/apps/wei/views.py @@ -693,9 +693,9 @@ class WEIUpdateRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, Update self.request, "wei.change_weiregistration_information_json", self.object): information = self.object.information d = dict( - bus=Bus.objects.filter(pk__in=information["preferred_bus_pk"]).all(), - team=BusTeam.objects.filter(pk__in=information["preferred_team_pk"]).all(), - roles=WEIRole.objects.filter(pk__in=information["preferred_roles_pk"]).all(), + bus=Bus.objects.filter(pk__in=information["preferred_bus_pk"]).all(), + team=BusTeam.objects.filter(pk__in=information["preferred_team_pk"]).all(), + roles=WEIRole.objects.filter(pk__in=information["preferred_roles_pk"]).all(), ) if 'preferred_bus_pk' in information else dict() choose_bus_form = WEIChooseBusForm( self.request.POST if self.request.POST else d