mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-11-26 18:37:12 +00:00
linters
This commit is contained in:
parent
96784aee3b
commit
201a179947
@ -1,5 +1,5 @@
|
|||||||
from rest_framework.pagination import PageNumberPagination
|
from rest_framework.pagination import PageNumberPagination
|
||||||
|
|
||||||
|
|
||||||
class CustomPagination(PageNumberPagination):
|
class CustomPagination(PageNumberPagination):
|
||||||
page_size_query_param = 'page_size'
|
page_size_query_param = 'page_size'
|
||||||
|
|
||||||
|
@ -325,8 +325,8 @@ class SpecialTransaction(Transaction):
|
|||||||
def clean(self):
|
def clean(self):
|
||||||
# SpecialTransaction are only possible with NoteSpecial object
|
# SpecialTransaction are only possible with NoteSpecial object
|
||||||
if self.is_credit() == self.is_debit():
|
if self.is_credit() == self.is_debit():
|
||||||
raise(ValidationError(_("A special transaction is only possible between a"
|
raise ValidationError(_("A special transaction is only possible between a"
|
||||||
" Note associated to a payment method and a User or a Club")))
|
" Note associated to a payment method and a User or a Club"))
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
|
@ -9,6 +9,7 @@ from member.models import Club
|
|||||||
from note.models import NoteSpecial, Alias
|
from note.models import NoteSpecial, Alias
|
||||||
from note_kfet.inputs import AmountInput
|
from note_kfet.inputs import AmountInput
|
||||||
|
|
||||||
|
|
||||||
class SignUpForm(UserCreationForm):
|
class SignUpForm(UserCreationForm):
|
||||||
"""
|
"""
|
||||||
Pre-register users with all information
|
Pre-register users with all information
|
||||||
@ -44,14 +45,14 @@ class SignUpForm(UserCreationForm):
|
|||||||
fields = ('first_name', 'last_name', 'username', 'email', )
|
fields = ('first_name', 'last_name', 'username', 'email', )
|
||||||
|
|
||||||
|
|
||||||
#class DeclareSogeAccountOpenedForm(forms.Form):
|
# class DeclareSogeAccountOpenedForm(forms.Form):
|
||||||
# soge_account = forms.BooleanField(
|
# soge_account = forms.BooleanField(
|
||||||
# label=_("I declare that I opened or I will open soon a bank account in the Société générale with the BDE "
|
# label=_("I declare that I opened or I will open soon a bank account in the Société générale with the BDE "
|
||||||
# "partnership."),
|
# "partnership."),
|
||||||
# help_text=_("Warning: this engages you to open your bank account. If you finally decides to don't open your "
|
# help_text=_("Warning: this engages you to open your bank account. If you finally decides to don't open your "
|
||||||
# "account, you will have to pay the BDE membership."),
|
# "account, you will have to pay the BDE membership."),
|
||||||
# required=False,
|
# required=False,
|
||||||
# )
|
# )
|
||||||
|
|
||||||
|
|
||||||
class WEISignupForm(forms.Form):
|
class WEISignupForm(forms.Form):
|
||||||
@ -117,10 +118,9 @@ class ValidationForm(forms.Form):
|
|||||||
|
|
||||||
# If the bda exists
|
# If the bda exists
|
||||||
if Club.objects.filter(name__iexact="bda").exists():
|
if Club.objects.filter(name__iexact="bda").exists():
|
||||||
# The user can join the bda club at the inscription
|
# The user can join the bda club at the inscription
|
||||||
join_bda = forms.BooleanField(
|
join_bda = forms.BooleanField(
|
||||||
label=_("Join BDA Club"),
|
label=_("Join BDA Club"),
|
||||||
required=False,
|
required=False,
|
||||||
initial=False,
|
initial=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
# Copyright (C) 2018-2021 by BDE ENS Paris-Saclay
|
# Copyright (C) 2018-2021 by BDE ENS Paris-Saclay
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from datetime import date, timedelta
|
|
||||||
|
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
@ -192,7 +190,7 @@ class TestValidateRegistration(TestCase):
|
|||||||
|
|
||||||
# BDE Membership is mandatory
|
# BDE Membership is mandatory
|
||||||
response = self.client.post(reverse("registration:future_user_detail", args=(self.user.pk,)), data=dict(
|
response = self.client.post(reverse("registration:future_user_detail", args=(self.user.pk,)), data=dict(
|
||||||
# soge=False,
|
# soge=False,
|
||||||
credit_type=NoteSpecial.objects.get(special_type="Chèque").id,
|
credit_type=NoteSpecial.objects.get(special_type="Chèque").id,
|
||||||
credit_amount=4200,
|
credit_amount=4200,
|
||||||
last_name="TOTO",
|
last_name="TOTO",
|
||||||
@ -206,7 +204,7 @@ class TestValidateRegistration(TestCase):
|
|||||||
|
|
||||||
# Same
|
# Same
|
||||||
response = self.client.post(reverse("registration:future_user_detail", args=(self.user.pk,)), data=dict(
|
response = self.client.post(reverse("registration:future_user_detail", args=(self.user.pk,)), data=dict(
|
||||||
# soge=False,
|
# soge=False,
|
||||||
credit_type="",
|
credit_type="",
|
||||||
credit_amount=0,
|
credit_amount=0,
|
||||||
last_name="TOTO",
|
last_name="TOTO",
|
||||||
@ -220,7 +218,7 @@ class TestValidateRegistration(TestCase):
|
|||||||
|
|
||||||
# The BDE membership is not free
|
# The BDE membership is not free
|
||||||
response = self.client.post(reverse("registration:future_user_detail", args=(self.user.pk,)), data=dict(
|
response = self.client.post(reverse("registration:future_user_detail", args=(self.user.pk,)), data=dict(
|
||||||
# soge=False,
|
# soge=False,
|
||||||
credit_type=NoteSpecial.objects.get(special_type="Espèces").id,
|
credit_type=NoteSpecial.objects.get(special_type="Espèces").id,
|
||||||
credit_amount=0,
|
credit_amount=0,
|
||||||
last_name="TOTO",
|
last_name="TOTO",
|
||||||
@ -234,7 +232,7 @@ class TestValidateRegistration(TestCase):
|
|||||||
|
|
||||||
# Last and first names are required for a credit
|
# Last and first names are required for a credit
|
||||||
response = self.client.post(reverse("registration:future_user_detail", args=(self.user.pk,)), data=dict(
|
response = self.client.post(reverse("registration:future_user_detail", args=(self.user.pk,)), data=dict(
|
||||||
# soge=False,
|
# soge=False,
|
||||||
credit_type=NoteSpecial.objects.get(special_type="Chèque").id,
|
credit_type=NoteSpecial.objects.get(special_type="Chèque").id,
|
||||||
credit_amount=4000,
|
credit_amount=4000,
|
||||||
last_name="",
|
last_name="",
|
||||||
@ -251,7 +249,7 @@ class TestValidateRegistration(TestCase):
|
|||||||
self.user.username = "admïntoto"
|
self.user.username = "admïntoto"
|
||||||
self.user.save()
|
self.user.save()
|
||||||
response = self.client.post(reverse("registration:future_user_detail", args=(self.user.pk,)), data=dict(
|
response = self.client.post(reverse("registration:future_user_detail", args=(self.user.pk,)), data=dict(
|
||||||
# soge=False,
|
# soge=False,
|
||||||
credit_type=NoteSpecial.objects.get(special_type="Chèque").id,
|
credit_type=NoteSpecial.objects.get(special_type="Chèque").id,
|
||||||
credit_amount=500,
|
credit_amount=500,
|
||||||
last_name="TOTO",
|
last_name="TOTO",
|
||||||
@ -277,7 +275,7 @@ class TestValidateRegistration(TestCase):
|
|||||||
self.user.profile.save()
|
self.user.profile.save()
|
||||||
|
|
||||||
response = self.client.post(reverse("registration:future_user_detail", args=(self.user.pk,)), data=dict(
|
response = self.client.post(reverse("registration:future_user_detail", args=(self.user.pk,)), data=dict(
|
||||||
# soge=False,
|
# soge=False,
|
||||||
credit_type=NoteSpecial.objects.get(special_type="Chèque").id,
|
credit_type=NoteSpecial.objects.get(special_type="Chèque").id,
|
||||||
credit_amount=500,
|
credit_amount=500,
|
||||||
last_name="TOTO",
|
last_name="TOTO",
|
||||||
@ -314,7 +312,7 @@ class TestValidateRegistration(TestCase):
|
|||||||
self.user.profile.save()
|
self.user.profile.save()
|
||||||
|
|
||||||
response = self.client.post(reverse("registration:future_user_detail", args=(self.user.pk,)), data=dict(
|
response = self.client.post(reverse("registration:future_user_detail", args=(self.user.pk,)), data=dict(
|
||||||
# soge=False,
|
# soge=False,
|
||||||
credit_type=NoteSpecial.objects.get(special_type="Espèces").id,
|
credit_type=NoteSpecial.objects.get(special_type="Espèces").id,
|
||||||
credit_amount=4000,
|
credit_amount=4000,
|
||||||
last_name="TOTO",
|
last_name="TOTO",
|
||||||
|
@ -24,7 +24,7 @@ from permission.models import Role
|
|||||||
from permission.views import ProtectQuerysetMixin
|
from permission.views import ProtectQuerysetMixin
|
||||||
from treasury.models import SogeCredit
|
from treasury.models import SogeCredit
|
||||||
|
|
||||||
#from .forms import SignUpForm, ValidationForm, DeclareSogeAccountOpenedForm
|
# from .forms import SignUpForm, ValidationForm, DeclareSogeAccountOpenedForm
|
||||||
from .forms import SignUpForm, ValidationForm
|
from .forms import SignUpForm, ValidationForm
|
||||||
from .tables import FutureUserTable
|
from .tables import FutureUserTable
|
||||||
from .tokens import email_validation_token
|
from .tokens import email_validation_token
|
||||||
@ -316,8 +316,8 @@ class FutureUserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, FormMixin,
|
|||||||
# If the user does not select any payment method, then no credit will be performed.
|
# If the user does not select any payment method, then no credit will be performed.
|
||||||
credit_amount = 0 if credit_type is None else credit_amount
|
credit_amount = 0 if credit_type is None else credit_amount
|
||||||
|
|
||||||
if fee > credit_amount:
|
|
||||||
# if fee > credit_amount and not soge:
|
# if fee > credit_amount and not soge:
|
||||||
|
if fee > credit_amount:
|
||||||
# Check if the user credits enough money
|
# Check if the user credits enough money
|
||||||
form.add_error('credit_type',
|
form.add_error('credit_type',
|
||||||
_("The entered amount is not enough for the memberships, should be at least {}")
|
_("The entered amount is not enough for the memberships, should be at least {}")
|
||||||
@ -352,7 +352,7 @@ class FutureUserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, FormMixin,
|
|||||||
quantity=1,
|
quantity=1,
|
||||||
amount=credit_amount,
|
amount=credit_amount,
|
||||||
reason="Crédit " + credit_type.special_type + " (Inscription)",
|
reason="Crédit " + credit_type.special_type + " (Inscription)",
|
||||||
# reason="Crédit " + ("Société générale" if soge else credit_type.special_type) + " (Inscription)",
|
# reason="Crédit " + ("Société générale" if soge else credit_type.special_type) + " (Inscription)",
|
||||||
last_name=last_name,
|
last_name=last_name,
|
||||||
first_name=first_name,
|
first_name=first_name,
|
||||||
bank=bank,
|
bank=bank,
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
# Copyright (C) 2018-2021 by BDE ENS Paris-Saclay
|
# Copyright (C) 2018-2021 by BDE ENS Paris-Saclay
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
import datetime
|
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@ -12,7 +11,8 @@ from django.db.models import Q
|
|||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from member.models import Club, Membership
|
# from member.models import Club, Membership # Club unused because of disabled soge
|
||||||
|
from member.models import Membership
|
||||||
from note.models import NoteSpecial, SpecialTransaction, MembershipTransaction, NoteUser
|
from note.models import NoteSpecial, SpecialTransaction, MembershipTransaction, NoteUser
|
||||||
|
|
||||||
|
|
||||||
@ -326,12 +326,12 @@ class SogeCredit(models.Model):
|
|||||||
if self.valid or not self.pk:
|
if self.valid or not self.pk:
|
||||||
return
|
return
|
||||||
|
|
||||||
bde = Club.objects.get(name="BDE")
|
# Soge do not pay BDE and kfet memberships this year (2022-2023)
|
||||||
kfet = Club.objects.get(name="Kfet")
|
# bde = Club.objects.get(name="BDE")
|
||||||
bde_qs = Membership.objects.filter(user=self.user, club=bde, date_start__gte=bde.membership_start)
|
# kfet = Club.objects.get(name="Kfet")
|
||||||
kfet_qs = Membership.objects.filter(user=self.user, club=kfet, date_start__gte=kfet.membership_start)
|
# 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)
|
||||||
|
|
||||||
## Soge do not pay BDE and kfet memberships this year (2022-2023)
|
|
||||||
# if bde_qs.exists():
|
# if bde_qs.exists():
|
||||||
# m = bde_qs.get()
|
# m = bde_qs.get()
|
||||||
# if MembershipTransaction.objects.filter(membership=m).exists(): # non-free membership
|
# if MembershipTransaction.objects.filter(membership=m).exists(): # non-free membership
|
||||||
|
@ -148,7 +148,7 @@ class WEISurvey2021(WEISurvey):
|
|||||||
buses = cls.get_algorithm_class().get_buses()
|
buses = cls.get_algorithm_class().get_buses()
|
||||||
return sum([cls.get_algorithm_class().get_bus_information(bus).scores[word] for bus in buses]) / buses.count()
|
return sum([cls.get_algorithm_class().get_bus_information(bus).scores[word] for bus in buses]) / buses.count()
|
||||||
|
|
||||||
@lru_cache()
|
# @lru_cache
|
||||||
def score(self, bus):
|
def score(self, bus):
|
||||||
if not self.is_complete():
|
if not self.is_complete():
|
||||||
raise ValueError("Survey is not ended, can't calculate score")
|
raise ValueError("Survey is not ended, can't calculate score")
|
||||||
@ -159,11 +159,11 @@ class WEISurvey2021(WEISurvey):
|
|||||||
- self.word_mean(getattr(self.information, 'word' + str(i))) for i in range(1, 21)) / 20
|
- self.word_mean(getattr(self.information, 'word' + str(i))) for i in range(1, 21)) / 20
|
||||||
return s
|
return s
|
||||||
|
|
||||||
@lru_cache()
|
# @lru_cache()
|
||||||
def scores_per_bus(self):
|
def scores_per_bus(self):
|
||||||
return {bus: self.score(bus) for bus in self.get_algorithm_class().get_buses()}
|
return {bus: self.score(bus) for bus in self.get_algorithm_class().get_buses()}
|
||||||
|
|
||||||
@lru_cache()
|
# @lru_cache()
|
||||||
def ordered_buses(self):
|
def ordered_buses(self):
|
||||||
values = list(self.scores_per_bus().items())
|
values = list(self.scores_per_bus().items())
|
||||||
values.sort(key=lambda item: -item[1])
|
values.sort(key=lambda item: -item[1])
|
||||||
|
@ -14,17 +14,17 @@ from .base import WEISurvey, WEISurveyInformation, WEISurveyAlgorithm, WEIBusInf
|
|||||||
from ...models import WEIMembership
|
from ...models import WEIMembership
|
||||||
|
|
||||||
WORDS = [
|
WORDS = [
|
||||||
'ABBA', 'After', 'Alcoolique anonyme', 'Ambiance festive', 'Années 2000', 'Apéro', 'Art',
|
'ABBA', 'After', 'Alcoolique anonyme', 'Ambiance festive', 'Années 2000', 'Apéro', 'Art',
|
||||||
'Baby foot billard biere pong', 'BBQ', 'Before', 'Bière pong', 'Bon enfant', 'Calme', 'Canapé',
|
'Baby foot billard biere pong', 'BBQ', 'Before', 'Bière pong', 'Bon enfant', 'Calme', 'Canapé',
|
||||||
'Chanson paillarde', 'Chanson populaire', 'Chartreuse', 'Cheerleader', 'Chill', 'Choré',
|
'Chanson paillarde', 'Chanson populaire', 'Chartreuse', 'Cheerleader', 'Chill', 'Choré',
|
||||||
'Cinéma', 'Cocktail', 'Comédie musicle', 'Commercial', 'Copaing', 'Danse', 'Dancefloor',
|
'Cinéma', 'Cocktail', 'Comédie musicle', 'Commercial', 'Copaing', 'Danse', 'Dancefloor',
|
||||||
'Electro', 'Fanfare', 'Gin tonic', 'Inclusif', 'Jazz', "Jeux d'alcool", 'Jeux de carte',
|
'Electro', 'Fanfare', 'Gin tonic', 'Inclusif', 'Jazz', "Jeux d'alcool", 'Jeux de carte',
|
||||||
'Jeux de rôle', 'Jeux de société', 'JUL', 'Jus de fruit', 'Kfet', 'Kleptomanie assurée',
|
'Jeux de rôle', 'Jeux de société', 'JUL', 'Jus de fruit', 'Kfet', 'Kleptomanie assurée',
|
||||||
'LGBTQ+', 'Livre', 'Morning beer', 'Musique', 'NAPS', 'Paillettes', 'Pastis', 'Paté Hénaff',
|
'LGBTQ+', 'Livre', 'Morning beer', 'Musique', 'NAPS', 'Paillettes', 'Pastis', 'Paté Hénaff',
|
||||||
'Peluche', 'Pena baiona', "Peu d'alcool", 'Pilier de bar', 'PMU', 'Poulpe', 'Punch', 'Rap',
|
'Peluche', 'Pena baiona', "Peu d'alcool", 'Pilier de bar', 'PMU', 'Poulpe', 'Punch', 'Rap',
|
||||||
'Réveil', 'Rock', 'Rugby', 'Sandwich', 'Serge', 'Shot', 'Sociable', 'Spectacle', 'Techno',
|
'Réveil', 'Rock', 'Rugby', 'Sandwich', 'Serge', 'Shot', 'Sociable', 'Spectacle', 'Techno',
|
||||||
'Techno house', 'Thérapie Taxi', 'Tradition kchanaises', 'Troisième mi-temps', 'Turn up',
|
'Techno house', 'Thérapie Taxi', 'Tradition kchanaises', 'Troisième mi-temps', 'Turn up',
|
||||||
'Vodka', 'Vodka pomme', 'Volley', 'Vomi stratégique'
|
'Vodka', 'Vodka pomme', 'Volley', 'Vomi stratégique'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ class WEISurvey2022(WEISurvey):
|
|||||||
buses = cls.get_algorithm_class().get_buses()
|
buses = cls.get_algorithm_class().get_buses()
|
||||||
return sum([cls.get_algorithm_class().get_bus_information(bus).scores[word] for bus in buses]) / buses.count()
|
return sum([cls.get_algorithm_class().get_bus_information(bus).scores[word] for bus in buses]) / buses.count()
|
||||||
|
|
||||||
@lru_cache()
|
# @lru_cache()
|
||||||
def score(self, bus):
|
def score(self, bus):
|
||||||
if not self.is_complete():
|
if not self.is_complete():
|
||||||
raise ValueError("Survey is not ended, can't calculate score")
|
raise ValueError("Survey is not ended, can't calculate score")
|
||||||
@ -162,11 +162,11 @@ class WEISurvey2022(WEISurvey):
|
|||||||
- self.word_mean(getattr(self.information, 'word' + str(i))) for i in range(1, 21)) / 20
|
- self.word_mean(getattr(self.information, 'word' + str(i))) for i in range(1, 21)) / 20
|
||||||
return s
|
return s
|
||||||
|
|
||||||
@lru_cache()
|
# @lru_cache()
|
||||||
def scores_per_bus(self):
|
def scores_per_bus(self):
|
||||||
return {bus: self.score(bus) for bus in self.get_algorithm_class().get_buses()}
|
return {bus: self.score(bus) for bus in self.get_algorithm_class().get_buses()}
|
||||||
|
|
||||||
@lru_cache()
|
# @lru_cache()
|
||||||
def ordered_buses(self):
|
def ordered_buses(self):
|
||||||
values = list(self.scores_per_bus().items())
|
values = list(self.scores_per_bus().items())
|
||||||
values.sort(key=lambda item: -item[1])
|
values.sort(key=lambda item: -item[1])
|
||||||
|
Loading…
Reference in New Issue
Block a user