From 0de69cbfaf95d960f8eb4288d5dbad4795307c5c Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 6 Aug 2020 12:50:24 +0200 Subject: [PATCH] :green_heart: Fix linters --- apps/activity/admin.py | 2 +- apps/activity/models.py | 2 +- apps/member/models.py | 18 ++++++++---------- apps/member/views.py | 4 ++-- apps/note/api/serializers.py | 6 ++---- apps/note/api/views.py | 2 +- apps/note/models/transactions.py | 2 +- apps/note/views.py | 1 - apps/permission/models.py | 1 - apps/permission/tables.py | 1 - apps/wei/forms/registration.py | 1 - apps/wei/models.py | 1 - apps/wei/tables.py | 2 +- apps/wei/views.py | 1 - 14 files changed, 17 insertions(+), 27 deletions(-) diff --git a/apps/activity/admin.py b/apps/activity/admin.py index 27cabd4e..7f40b421 100644 --- a/apps/activity/admin.py +++ b/apps/activity/admin.py @@ -2,8 +2,8 @@ # SPDX-License-Identifier: GPL-3.0-or-later from django.contrib import admin - from note_kfet.admin import admin_site + from .models import Activity, ActivityType, Guest, Entry diff --git a/apps/activity/models.py b/apps/activity/models.py index 93942720..3ad0aa29 100644 --- a/apps/activity/models.py +++ b/apps/activity/models.py @@ -1,11 +1,11 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later + from datetime import timedelta, datetime from threading import Thread from django.conf import settings from django.contrib.auth.models import User -from django.core.management import call_command from django.db import models from django.db.models import Q from django.utils import timezone diff --git a/apps/member/models.py b/apps/member/models.py index 70745f08..90117f35 100644 --- a/apps/member/models.py +++ b/apps/member/models.py @@ -16,7 +16,6 @@ from django.utils.encoding import force_bytes from django.utils.http import urlsafe_base64_encode from django.utils.translation import gettext_lazy as _ from phonenumber_field.modelfields import PhoneNumberField - from permission.models import Role from registration.tokens import email_validation_token from note.models import MembershipTransaction @@ -155,12 +154,12 @@ class Profile(models.Model): 'uid': urlsafe_base64_encode(force_bytes(self.user.pk)), }) html = loader.render_to_string('registration/mails/email_validation_email.html', - { - 'user': self.user, - 'domain': os.getenv("NOTE_URL", "note.example.com"), - 'token': email_validation_token.make_token(self.user), - 'uid': urlsafe_base64_encode(force_bytes(self.user.pk)), - }) + { + 'user': self.user, + 'domain': os.getenv("NOTE_URL", "note.example.com"), + 'token': email_validation_token.make_token(self.user), + 'uid': urlsafe_base64_encode(force_bytes(self.user.pk)), + }) self.user.email_user(subject, message, html_message=html) @@ -329,7 +328,6 @@ class Membership(models.Model): club=self.club, date_start=max(self.date_end + datetime.timedelta(days=1), self.club.membership_start), ) - from django.forms import model_to_dict if hasattr(self, '_force_renew_parent') and self._force_renew_parent: new_membership._force_renew_parent = True if hasattr(self, '_soge') and self._soge: @@ -445,8 +443,8 @@ class Membership(models.Model): ) transaction._force_save = True if hasattr(self, '_soge') and "treasury" in settings.INSTALLED_APPS\ - and (self.club.name == "BDE" or self.club.name == "Kfet" or - ("wei" in settings.INSTALLED_APPS and hasattr(self.club, "weiclub") and self.club.weiclub)): + and (self.club.name == "BDE" or self.club.name == "Kfet" + or ("wei" in settings.INSTALLED_APPS and hasattr(self.club, "weiclub") and self.club.weiclub)): # If the soge pays, then the transaction is unvalidated in a first time, then submitted for control # to treasurers. transaction.valid = False diff --git a/apps/member/views.py b/apps/member/views.py index 7720c097..3caf5a84 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -455,7 +455,7 @@ class ClubAddMemberView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): while c.parent_club is not None: c = c.parent_club clubs_renewal.append(c) - additional_fee_renewal += c.membership_fee_paid if user.profile.paid else c.membership_fee_unpaid + additional_fee_renewal += c.membership_fee_paid context["clubs_renewal"] = clubs_renewal context["additional_fee_renewal"] = additional_fee_renewal @@ -496,7 +496,7 @@ class ClubAddMemberView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): form.fields['user'].disabled = True form.fields['date_start'].initial = old_membership.date_end + timedelta(days=1) form.fields['credit_amount'].initial = (club.membership_fee_paid if user.profile.paid - else club.membership_fee_unpaid) + additional_fee_renewal + else club.membership_fee_unpaid) + additional_fee_renewal form.fields['last_name'].initial = user.last_name form.fields['first_name'].initial = user.first_name diff --git a/apps/note/api/serializers.py b/apps/note/api/serializers.py index b4fceeda..4b2ed0a6 100644 --- a/apps/note/api/serializers.py +++ b/apps/note/api/serializers.py @@ -1,10 +1,8 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later -from django.utils import timezone -from rest_framework import serializers -from rest_framework.serializers import ListSerializer -from rest_polymorphic.serializers import PolymorphicSerializer +from rest_framework import serializers +from rest_polymorphic.serializers import PolymorphicSerializer from member.api.serializers import MembershipSerializer from member.models import Membership from note_kfet.middlewares import get_current_authenticated_user diff --git a/apps/note/api/views.py b/apps/note/api/views.py index be11aa7f..0821ab48 100644 --- a/apps/note/api/views.py +++ b/apps/note/api/views.py @@ -9,7 +9,7 @@ from rest_framework import viewsets from rest_framework.response import Response from rest_framework import status from api.viewsets import ReadProtectedModelViewSet, ReadOnlyProtectedModelViewSet -from note_kfet.middlewares import get_current_session +from note_kfet.middlewares import get_current_session from permission.backends import PermissionBackend from .serializers import NotePolymorphicSerializer, AliasSerializer, ConsumerSerializer,\ diff --git a/apps/note/models/transactions.py b/apps/note/models/transactions.py index 677e0fa8..df64d80d 100644 --- a/apps/note/models/transactions.py +++ b/apps/note/models/transactions.py @@ -7,7 +7,7 @@ from django.utils import timezone from django.utils.translation import gettext_lazy as _ from polymorphic.models import PolymorphicModel -from .notes import Note, NoteClub, NoteSpecial, NoteUser +from .notes import Note, NoteClub, NoteSpecial from ..templatetags.pretty_money import pretty_money """ diff --git a/apps/note/views.py b/apps/note/views.py index d08dd2ec..bdc450fe 100644 --- a/apps/note/views.py +++ b/apps/note/views.py @@ -10,7 +10,6 @@ from django.utils.translation import gettext_lazy as _ from django.views.generic import CreateView, UpdateView, DetailView from django_tables2 import SingleTableView from django.urls import reverse_lazy - from activity.models import Entry from note_kfet.inputs import AmountInput from permission.backends import PermissionBackend diff --git a/apps/permission/models.py b/apps/permission/models.py index a7e178b3..d49afdab 100644 --- a/apps/permission/models.py +++ b/apps/permission/models.py @@ -5,7 +5,6 @@ import functools import json import operator from copy import copy -from time import sleep from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ValidationError diff --git a/apps/permission/tables.py b/apps/permission/tables.py index 7a07bd6a..2ba80505 100644 --- a/apps/permission/tables.py +++ b/apps/permission/tables.py @@ -4,7 +4,6 @@ import django_tables2 as tables from django.urls import reverse_lazy from django.utils.html import format_html - from member.models import Membership from note_kfet.middlewares import get_current_authenticated_user from permission.backends import PermissionBackend diff --git a/apps/wei/forms/registration.py b/apps/wei/forms/registration.py index 98215f4b..1645f60c 100644 --- a/apps/wei/forms/registration.py +++ b/apps/wei/forms/registration.py @@ -6,7 +6,6 @@ from django.contrib.auth.models import User from django.db.models import Q from django.forms import CheckboxSelectMultiple from django.utils.translation import gettext_lazy as _ - from note.models import NoteSpecial from note_kfet.inputs import AmountInput, DatePickerInput, Autocomplete, ColorWidget diff --git a/apps/wei/models.py b/apps/wei/models.py index e500715a..b72208ed 100644 --- a/apps/wei/models.py +++ b/apps/wei/models.py @@ -9,7 +9,6 @@ from django.contrib.auth.models import User from django.db import models from django.utils.translation import gettext_lazy as _ from phonenumber_field.modelfields import PhoneNumberField - from member.models import Club, Membership from note.models import MembershipTransaction from permission.models import Role diff --git a/apps/wei/tables.py b/apps/wei/tables.py index 0fae6848..a1d982cd 100644 --- a/apps/wei/tables.py +++ b/apps/wei/tables.py @@ -7,9 +7,9 @@ from django.utils import timezone from django.utils.html import format_html from django.utils.translation import gettext_lazy as _ from django_tables2 import A - from note_kfet.middlewares import get_current_authenticated_user from permission.backends import PermissionBackend + from .models import WEIClub, WEIRegistration, Bus, BusTeam, WEIMembership diff --git a/apps/wei/views.py b/apps/wei/views.py index fe2a47a5..3d96ed9f 100644 --- a/apps/wei/views.py +++ b/apps/wei/views.py @@ -28,7 +28,6 @@ from note.models import Transaction, NoteClub, Alias, SpecialTransaction, NoteSp from note.tables import HistoryTable from note_kfet.settings import BASE_DIR from permission.backends import PermissionBackend -from permission.models import Role from permission.views import ProtectQuerysetMixin from .forms.registration import WEIChooseBusForm