From e9cbc8e62346d7676f71c251fecfa63c48701cd8 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 30 Jul 2020 15:53:23 +0200 Subject: [PATCH] Fix linters --- apps/member/admin.py | 2 +- apps/member/forms.py | 1 - apps/member/hashers.py | 3 +-- apps/note/admin.py | 1 - apps/permission/admin.py | 2 +- apps/permission/backends.py | 3 +-- apps/permission/signals.py | 5 +---- apps/treasury/admin.py | 2 +- apps/wei/admin.py | 1 + apps/wei/models.py | 2 +- 10 files changed, 8 insertions(+), 14 deletions(-) diff --git a/apps/member/admin.py b/apps/member/admin.py index 76edb762..d9075832 100644 --- a/apps/member/admin.py +++ b/apps/member/admin.py @@ -4,8 +4,8 @@ from django.contrib import admin from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User - from note_kfet.admin import admin_site + from .forms import ProfileForm from .models import Club, Membership, Profile diff --git a/apps/member/forms.py b/apps/member/forms.py index 49537838..a31acb80 100644 --- a/apps/member/forms.py +++ b/apps/member/forms.py @@ -32,7 +32,6 @@ class UserForm(forms.ModelForm): fields = ('first_name', 'last_name', 'username', 'email',) - class ProfileForm(forms.ModelForm): """ A form for the extras field provided by the :model:`member.Profile` model. diff --git a/apps/member/hashers.py b/apps/member/hashers.py index 9ebed95b..f7e4342f 100644 --- a/apps/member/hashers.py +++ b/apps/member/hashers.py @@ -4,9 +4,8 @@ import hashlib from django.conf import settings -from django.contrib.auth.hashers import PBKDF2PasswordHasher, BasePasswordHasher +from django.contrib.auth.hashers import PBKDF2PasswordHasher from django.utils.crypto import constant_time_compare - from note_kfet.middlewares import get_current_authenticated_user, get_current_session diff --git a/apps/note/admin.py b/apps/note/admin.py index 96823d2b..d2750bd8 100644 --- a/apps/note/admin.py +++ b/apps/note/admin.py @@ -5,7 +5,6 @@ from django.contrib import admin from django.utils.translation import gettext_lazy as _ from polymorphic.admin import PolymorphicChildModelAdmin, \ PolymorphicChildModelFilter, PolymorphicParentModelAdmin - from note_kfet.admin import admin_site from .models.notes import Alias, Note, NoteClub, NoteSpecial, NoteUser diff --git a/apps/permission/admin.py b/apps/permission/admin.py index 7d189c94..385cf198 100644 --- a/apps/permission/admin.py +++ b/apps/permission/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 Permission, PermissionMask, Role diff --git a/apps/permission/backends.py b/apps/permission/backends.py index c29419eb..c5a43b1e 100644 --- a/apps/permission/backends.py +++ b/apps/permission/backends.py @@ -36,7 +36,7 @@ class PermissionBackend(ModelBackend): return Permission.objects.none() memberships = Membership.objects.filter(user=user).all() - + perms = [] for membership in memberships: @@ -49,7 +49,6 @@ class PermissionBackend(ModelBackend): perms.append(perm) return perms - @staticmethod def permissions(user, model, type): """ diff --git a/apps/permission/signals.py b/apps/permission/signals.py index 167a22b0..ef21c36e 100644 --- a/apps/permission/signals.py +++ b/apps/permission/signals.py @@ -1,6 +1,6 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later -from django.contrib.auth.models import User + from django.core.exceptions import PermissionDenied from django.utils.translation import gettext_lazy as _ from note_kfet.middlewares import get_current_authenticated_user @@ -51,9 +51,6 @@ def pre_save_object(sender, instance, **kwargs): # In the other case, we check if he/she has the right to change one field previous = qs.get() - if isinstance(instance, User) and instance.last_login != previous.last_login: - pass #return - for field in instance._meta.fields: field_name = field.name old_value = getattr(previous, field.name) diff --git a/apps/treasury/admin.py b/apps/treasury/admin.py index e1b597b9..464816db 100644 --- a/apps/treasury/admin.py +++ b/apps/treasury/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 RemittanceType, Remittance, SogeCredit diff --git a/apps/wei/admin.py b/apps/wei/admin.py index a3e1d546..f928a313 100644 --- a/apps/wei/admin.py +++ b/apps/wei/admin.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later from note_kfet.admin import admin_site + from .models import WEIClub, WEIRegistration, WEIMembership, WEIRole, Bus, BusTeam admin_site.register(WEIClub) diff --git a/apps/wei/models.py b/apps/wei/models.py index 1b19a60a..df353338 100644 --- a/apps/wei/models.py +++ b/apps/wei/models.py @@ -202,7 +202,7 @@ class WEIRegistration(models.Model): clothing_size = models.CharField( max_length=4, choices=( - ('XS',"XS"), + ('XS', "XS"), ('S', "S"), ('M', "M"), ('L', "L"),