💚 Fix CI

This commit is contained in:
Yohann D'ANELLO 2020-08-30 11:59:10 +02:00
parent c5f40e0952
commit 374e6ed7f8
5 changed files with 8 additions and 9 deletions

View File

@ -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

View File

@ -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()

View File

@ -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"]

View File

@ -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

View File

@ -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)