mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-20 17:41:55 +02:00
Handle payments from the Société Générale, closes #15
This commit is contained in:
@ -26,7 +26,7 @@ class ProfileForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Profile
|
||||
fields = '__all__'
|
||||
exclude = ('user', 'email_confirmed', 'registration_valid', )
|
||||
exclude = ('user', 'email_confirmed', 'registration_valid', 'soge', )
|
||||
|
||||
|
||||
class ClubForm(forms.ModelForm):
|
||||
|
@ -53,13 +53,19 @@ class Profile(models.Model):
|
||||
default=False,
|
||||
)
|
||||
|
||||
email_confirmed = models.BooleanField(
|
||||
verbose_name=_("email confirmed"),
|
||||
default=False,
|
||||
)
|
||||
|
||||
registration_valid = models.BooleanField(
|
||||
verbose_name=_("registration valid"),
|
||||
default=False,
|
||||
)
|
||||
|
||||
email_confirmed = models.BooleanField(
|
||||
verbose_name=_("email confirmed"),
|
||||
soge = models.BooleanField(
|
||||
verbose_name=_("Société générale"),
|
||||
help_text=_("Has the user ever be paid by the Société générale?"),
|
||||
default=False,
|
||||
)
|
||||
|
||||
|
@ -25,6 +25,12 @@ class SignUpForm(UserCreationForm):
|
||||
|
||||
|
||||
class ValidationForm(forms.Form):
|
||||
soge = forms.BooleanField(
|
||||
label=_("Inscription paid by Société Générale"),
|
||||
required=False,
|
||||
help_text=_("Check this case is the Société Générale paid the inscription."),
|
||||
)
|
||||
|
||||
credit_type = forms.ModelChoiceField(
|
||||
queryset=NoteSpecial.objects,
|
||||
label=_("Credit type"),
|
||||
@ -55,13 +61,13 @@ class ValidationForm(forms.Form):
|
||||
)
|
||||
|
||||
join_BDE = forms.BooleanField(
|
||||
label=_("Join BDE"),
|
||||
label=_("Join BDE Club"),
|
||||
required=False,
|
||||
initial=True,
|
||||
)
|
||||
|
||||
join_Kfet = forms.BooleanField(
|
||||
label=_("Join Kfet"),
|
||||
label=_("Join Kfet Club"),
|
||||
required=False,
|
||||
initial=True,
|
||||
)
|
||||
|
@ -16,7 +16,7 @@ from django.views.generic import CreateView, TemplateView, DetailView, FormView
|
||||
from django_tables2 import SingleTableView
|
||||
from member.forms import ProfileForm
|
||||
from member.models import Membership, Club
|
||||
from note.models import SpecialTransaction, Transaction
|
||||
from note.models import SpecialTransaction, NoteSpecial
|
||||
from note.templatetags.pretty_money import pretty_money
|
||||
from permission.backends import PermissionBackend
|
||||
from permission.views import ProtectQuerysetMixin
|
||||
@ -66,7 +66,7 @@ class UserCreateView(CreateView):
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
class UserValidateView(LoginRequiredMixin, ProtectQuerysetMixin, TemplateView):
|
||||
class UserValidateView(TemplateView):
|
||||
title = _("Account Activation")
|
||||
template_name = 'registration/email_validation_complete.html'
|
||||
|
||||
@ -89,6 +89,7 @@ class UserValidateView(LoginRequiredMixin, ProtectQuerysetMixin, TemplateView):
|
||||
user.is_active = True
|
||||
user.profile.email_confirmed = True
|
||||
user.save()
|
||||
user.profile.save()
|
||||
return super().dispatch(*args, **kwargs)
|
||||
else:
|
||||
# Display the "Account Activation unsuccessful" page.
|
||||
@ -116,7 +117,7 @@ class UserValidateView(LoginRequiredMixin, ProtectQuerysetMixin, TemplateView):
|
||||
return context
|
||||
|
||||
|
||||
class UserValidationEmailSentView(LoginRequiredMixin, ProtectQuerysetMixin, TemplateView):
|
||||
class UserValidationEmailSentView(TemplateView):
|
||||
template_name = 'registration/email_validation_email_sent.html'
|
||||
title = _('Account activation email sent')
|
||||
|
||||
@ -170,6 +171,19 @@ class FutureUserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView,
|
||||
"""
|
||||
return super().get_queryset().filter(profile__registration_valid=False)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
ctx = super().get_context_data(**kwargs)
|
||||
|
||||
user = self.get_object()
|
||||
fee = 0
|
||||
bde = Club.objects.get(name="BDE")
|
||||
fee += bde.membership_fee_paid if user.profile.paid else bde.membership_fee_unpaid
|
||||
kfet = Club.objects.get(name="Kfet")
|
||||
fee += kfet.membership_fee_paid if user.profile.paid else kfet.membership_fee_unpaid
|
||||
ctx["total_fee"] = "{:.02f}".format(fee / 100, )
|
||||
|
||||
return ctx
|
||||
|
||||
def get_form(self, form_class=None):
|
||||
form = super().get_form(form_class)
|
||||
user = self.get_object()
|
||||
@ -180,7 +194,7 @@ class FutureUserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView,
|
||||
def form_valid(self, form):
|
||||
user = self.object = self.get_object()
|
||||
|
||||
print(form.cleaned_data)
|
||||
soge = form.cleaned_data["soge"]
|
||||
credit_type = form.cleaned_data["credit_type"]
|
||||
credit_amount = form.cleaned_data["credit_amount"]
|
||||
last_name = form.cleaned_data["last_name"]
|
||||
@ -189,6 +203,10 @@ class FutureUserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView,
|
||||
join_BDE = form.cleaned_data["join_BDE"]
|
||||
join_Kfet = form.cleaned_data["join_Kfet"]
|
||||
|
||||
if soge:
|
||||
join_BDE = True
|
||||
join_Kfet = True
|
||||
|
||||
fee = 0
|
||||
bde = Club.objects.get(name="BDE")
|
||||
bde_fee = bde.membership_fee_paid if user.profile.paid else bde.membership_fee_unpaid
|
||||
@ -199,6 +217,11 @@ class FutureUserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView,
|
||||
if join_Kfet:
|
||||
fee += kfet_fee
|
||||
|
||||
if soge:
|
||||
credit_type = NoteSpecial.objects.get(special_type="Virement bancaire")
|
||||
credit_amount = fee
|
||||
bank = "Société générale"
|
||||
|
||||
if join_Kfet and not join_BDE:
|
||||
form.add_error('join_Kfet', _("You must join BDE club before joining Kfet club."))
|
||||
|
||||
@ -221,6 +244,7 @@ class FutureUserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView,
|
||||
ret = super().form_valid(form)
|
||||
user.is_active = True
|
||||
user.profile.registration_valid = True
|
||||
user.profile.soge = soge
|
||||
user.save()
|
||||
user.profile.save()
|
||||
|
||||
@ -230,7 +254,7 @@ class FutureUserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView,
|
||||
destination=user.note,
|
||||
quantity=1,
|
||||
amount=credit_amount,
|
||||
reason="Crédit " + 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,
|
||||
first_name=first_name,
|
||||
bank=bank,
|
||||
|
Reference in New Issue
Block a user