From 374e6ed7f81165fbb317643fa6682d062fc27515 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sun, 30 Aug 2020 11:59:10 +0200 Subject: [PATCH] :green_heart: Fix CI --- apps/activity/views.py | 1 - apps/member/forms.py | 1 + apps/member/views.py | 9 ++++----- apps/note/forms.py | 1 - apps/permission/tests/test_permission_denied.py | 5 +++-- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/apps/activity/views.py b/apps/activity/views.py index 97ae1375..d5dcc497 100644 --- a/apps/activity/views.py +++ b/apps/activity/views.py @@ -11,7 +11,6 @@ from django.utils import timezone from django.utils.translation import gettext_lazy as _ from django.views.generic import DetailView, TemplateView, UpdateView from django_tables2.views import SingleTableView - from note.models import Alias, NoteSpecial, NoteUser from permission.backends import PermissionBackend from permission.views import ProtectQuerysetMixin, ProtectedCreateView diff --git a/apps/member/forms.py b/apps/member/forms.py index 60819db6..a5d571b6 100644 --- a/apps/member/forms.py +++ b/apps/member/forms.py @@ -77,6 +77,7 @@ class ImageForm(forms.Form): width = forms.FloatField(widget=forms.HiddenInput()) height = forms.FloatField(widget=forms.HiddenInput()) + class ClubForm(forms.ModelForm): def clean(self): cleaned_data = super().clean() diff --git a/apps/member/views.py b/apps/member/views.py index e7dc9925..2a16168e 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -3,8 +3,8 @@ import io from datetime import timedelta, date -from PIL import Image +from PIL import Image from django.conf import settings from django.contrib.auth import logout from django.contrib.auth.mixins import LoginRequiredMixin @@ -18,7 +18,6 @@ from django.utils.translation import gettext_lazy as _ from django.views.generic import DetailView, UpdateView, TemplateView from django.views.generic.edit import FormMixin from django_tables2.views import SingleTableView - from rest_framework.authtoken.models import Token from note.models import Alias, NoteUser from note.models.transactions import Transaction, SpecialTransaction @@ -576,11 +575,11 @@ class ClubAddMemberView(ProtectQuerysetMixin, ProtectedCreateView): Create membership, check that all is good, make transactions """ # Get the club that is concerned by the membership - if "club_pk" in self.kwargs: # get from url of new membership + if "club_pk" in self.kwargs: # get from url of new membership club = Club.objects.filter(PermissionBackend.filter_queryset(self.request.user, Club, "view")) \ .get(pk=self.kwargs["club_pk"]) user = form.instance.user - else: # get from url for renewal + else: # get from url for renewal old_membership = self.get_queryset().get(pk=self.kwargs["pk"]) club = old_membership.club user = old_membership.user @@ -589,7 +588,7 @@ class ClubAddMemberView(ProtectQuerysetMixin, ProtectedCreateView): # Get form data credit_type = form.cleaned_data["credit_type"] - # but with this way users can customize their section as they want. + # but with this way users can customize their section as they want. credit_amount = form.cleaned_data["credit_amount"] last_name = form.cleaned_data["last_name"] first_name = form.cleaned_data["first_name"] diff --git a/apps/note/forms.py b/apps/note/forms.py index 2c468706..1e3d092b 100644 --- a/apps/note/forms.py +++ b/apps/note/forms.py @@ -10,7 +10,6 @@ from note_kfet.inputs import Autocomplete, AmountInput, DateTimePickerInput from .models import TransactionTemplate, NoteClub, Alias - class TransactionTemplateForm(forms.ModelForm): class Meta: model = TransactionTemplate diff --git a/apps/permission/tests/test_permission_denied.py b/apps/permission/tests/test_permission_denied.py index ebeaa133..6dc8b888 100644 --- a/apps/permission/tests/test_permission_denied.py +++ b/apps/permission/tests/test_permission_denied.py @@ -7,6 +7,7 @@ from django.contrib.auth.models import User from django.test import TestCase from django.urls import reverse from django.utils import timezone +from django.utils.crypto import get_random_string from activity.models import Activity from member.models import Club, Membership from note.models import NoteUser @@ -68,12 +69,12 @@ class TestPermissionDenied(TestCase): self.assertEqual(response.status_code, 403) def test_add_member_club(self): - club = Club.objects.create() + club = Club.objects.create(name=get_random_string(127)) response = self.client.get(reverse("member:club_add_member", kwargs=dict(club_pk=club.pk))) self.assertEqual(response.status_code, 403) def test_renew_membership(self): - club = Club.objects.create() + club = Club.objects.create(name=get_random_string(127)) membership = Membership.objects.create(user=self.user, club=club) response = self.client.get(reverse("member:club_renew_membership", kwargs=dict(pk=membership.pk))) self.assertEqual(response.status_code, 403)