mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-12-03 13:46:58 +00:00
Handle payments from the Société Générale, closes #15
This commit is contained in:
parent
3516b1fa04
commit
f286f99ced
@ -26,7 +26,7 @@ class ProfileForm(forms.ModelForm):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = Profile
|
model = Profile
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
exclude = ('user', 'email_confirmed', 'registration_valid', )
|
exclude = ('user', 'email_confirmed', 'registration_valid', 'soge', )
|
||||||
|
|
||||||
|
|
||||||
class ClubForm(forms.ModelForm):
|
class ClubForm(forms.ModelForm):
|
||||||
|
@ -53,13 +53,19 @@ class Profile(models.Model):
|
|||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
email_confirmed = models.BooleanField(
|
||||||
|
verbose_name=_("email confirmed"),
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
|
||||||
registration_valid = models.BooleanField(
|
registration_valid = models.BooleanField(
|
||||||
verbose_name=_("registration valid"),
|
verbose_name=_("registration valid"),
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
email_confirmed = models.BooleanField(
|
soge = models.BooleanField(
|
||||||
verbose_name=_("email confirmed"),
|
verbose_name=_("Société générale"),
|
||||||
|
help_text=_("Has the user ever be paid by the Société générale?"),
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -25,6 +25,12 @@ class SignUpForm(UserCreationForm):
|
|||||||
|
|
||||||
|
|
||||||
class ValidationForm(forms.Form):
|
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(
|
credit_type = forms.ModelChoiceField(
|
||||||
queryset=NoteSpecial.objects,
|
queryset=NoteSpecial.objects,
|
||||||
label=_("Credit type"),
|
label=_("Credit type"),
|
||||||
@ -55,13 +61,13 @@ class ValidationForm(forms.Form):
|
|||||||
)
|
)
|
||||||
|
|
||||||
join_BDE = forms.BooleanField(
|
join_BDE = forms.BooleanField(
|
||||||
label=_("Join BDE"),
|
label=_("Join BDE Club"),
|
||||||
required=False,
|
required=False,
|
||||||
initial=True,
|
initial=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
join_Kfet = forms.BooleanField(
|
join_Kfet = forms.BooleanField(
|
||||||
label=_("Join Kfet"),
|
label=_("Join Kfet Club"),
|
||||||
required=False,
|
required=False,
|
||||||
initial=True,
|
initial=True,
|
||||||
)
|
)
|
||||||
|
@ -16,7 +16,7 @@ from django.views.generic import CreateView, TemplateView, DetailView, FormView
|
|||||||
from django_tables2 import SingleTableView
|
from django_tables2 import SingleTableView
|
||||||
from member.forms import ProfileForm
|
from member.forms import ProfileForm
|
||||||
from member.models import Membership, Club
|
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 note.templatetags.pretty_money import pretty_money
|
||||||
from permission.backends import PermissionBackend
|
from permission.backends import PermissionBackend
|
||||||
from permission.views import ProtectQuerysetMixin
|
from permission.views import ProtectQuerysetMixin
|
||||||
@ -66,7 +66,7 @@ class UserCreateView(CreateView):
|
|||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
|
||||||
class UserValidateView(LoginRequiredMixin, ProtectQuerysetMixin, TemplateView):
|
class UserValidateView(TemplateView):
|
||||||
title = _("Account Activation")
|
title = _("Account Activation")
|
||||||
template_name = 'registration/email_validation_complete.html'
|
template_name = 'registration/email_validation_complete.html'
|
||||||
|
|
||||||
@ -89,6 +89,7 @@ class UserValidateView(LoginRequiredMixin, ProtectQuerysetMixin, TemplateView):
|
|||||||
user.is_active = True
|
user.is_active = True
|
||||||
user.profile.email_confirmed = True
|
user.profile.email_confirmed = True
|
||||||
user.save()
|
user.save()
|
||||||
|
user.profile.save()
|
||||||
return super().dispatch(*args, **kwargs)
|
return super().dispatch(*args, **kwargs)
|
||||||
else:
|
else:
|
||||||
# Display the "Account Activation unsuccessful" page.
|
# Display the "Account Activation unsuccessful" page.
|
||||||
@ -116,7 +117,7 @@ class UserValidateView(LoginRequiredMixin, ProtectQuerysetMixin, TemplateView):
|
|||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class UserValidationEmailSentView(LoginRequiredMixin, ProtectQuerysetMixin, TemplateView):
|
class UserValidationEmailSentView(TemplateView):
|
||||||
template_name = 'registration/email_validation_email_sent.html'
|
template_name = 'registration/email_validation_email_sent.html'
|
||||||
title = _('Account activation email sent')
|
title = _('Account activation email sent')
|
||||||
|
|
||||||
@ -170,6 +171,19 @@ class FutureUserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView,
|
|||||||
"""
|
"""
|
||||||
return super().get_queryset().filter(profile__registration_valid=False)
|
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):
|
def get_form(self, form_class=None):
|
||||||
form = super().get_form(form_class)
|
form = super().get_form(form_class)
|
||||||
user = self.get_object()
|
user = self.get_object()
|
||||||
@ -180,7 +194,7 @@ class FutureUserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView,
|
|||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
user = self.object = self.get_object()
|
user = self.object = self.get_object()
|
||||||
|
|
||||||
print(form.cleaned_data)
|
soge = form.cleaned_data["soge"]
|
||||||
credit_type = form.cleaned_data["credit_type"]
|
credit_type = form.cleaned_data["credit_type"]
|
||||||
credit_amount = form.cleaned_data["credit_amount"]
|
credit_amount = form.cleaned_data["credit_amount"]
|
||||||
last_name = form.cleaned_data["last_name"]
|
last_name = form.cleaned_data["last_name"]
|
||||||
@ -189,6 +203,10 @@ class FutureUserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView,
|
|||||||
join_BDE = form.cleaned_data["join_BDE"]
|
join_BDE = form.cleaned_data["join_BDE"]
|
||||||
join_Kfet = form.cleaned_data["join_Kfet"]
|
join_Kfet = form.cleaned_data["join_Kfet"]
|
||||||
|
|
||||||
|
if soge:
|
||||||
|
join_BDE = True
|
||||||
|
join_Kfet = True
|
||||||
|
|
||||||
fee = 0
|
fee = 0
|
||||||
bde = Club.objects.get(name="BDE")
|
bde = Club.objects.get(name="BDE")
|
||||||
bde_fee = bde.membership_fee_paid if user.profile.paid else bde.membership_fee_unpaid
|
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:
|
if join_Kfet:
|
||||||
fee += kfet_fee
|
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:
|
if join_Kfet and not join_BDE:
|
||||||
form.add_error('join_Kfet', _("You must join BDE club before joining Kfet club."))
|
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)
|
ret = super().form_valid(form)
|
||||||
user.is_active = True
|
user.is_active = True
|
||||||
user.profile.registration_valid = True
|
user.profile.registration_valid = True
|
||||||
|
user.profile.soge = soge
|
||||||
user.save()
|
user.save()
|
||||||
user.profile.save()
|
user.profile.save()
|
||||||
|
|
||||||
@ -230,7 +254,7 @@ class FutureUserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView,
|
|||||||
destination=user.note,
|
destination=user.note,
|
||||||
quantity=1,
|
quantity=1,
|
||||||
amount=credit_amount,
|
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,
|
last_name=last_name,
|
||||||
first_name=first_name,
|
first_name=first_name,
|
||||||
bank=bank,
|
bank=bank,
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
{% load perms %}
|
{% load perms %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<div class="row mt-4">
|
||||||
|
<div class="col-md-3 mb-4">
|
||||||
<div class="card bg-light shadow">
|
<div class="card bg-light shadow">
|
||||||
<div class="card-header text-center" >
|
<div class="card-header text-center" >
|
||||||
<h4> {% trans "Account #" %} {{ object.pk }}</h4>
|
<h4> {% trans "Account #" %} {{ object.pk }}</h4>
|
||||||
@ -54,9 +56,8 @@
|
|||||||
<a class="btn btn-danger btn-sm" href="{% url 'registration:future_user_invalidate' object.pk %}">{% trans 'Delete registration' %}</a>
|
<a class="btn btn-danger btn-sm" href="{% url 'registration:future_user_invalidate' object.pk %}">{% trans 'Delete registration' %}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<hr>
|
<div class="col-md-9">
|
||||||
|
|
||||||
<div class="card bg-light shadow">
|
<div class="card bg-light shadow">
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="card-header text-center" >
|
<div class="card-header text-center" >
|
||||||
@ -71,4 +72,48 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block extrajavascript %}
|
||||||
|
<script>
|
||||||
|
soge_field = $("#id_soge");
|
||||||
|
|
||||||
|
function fillFields() {
|
||||||
|
let checked = soge_field.is(':checked');
|
||||||
|
if (!checked) {
|
||||||
|
$("input").attr('disabled', false);
|
||||||
|
$("select").attr('disabled', false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let credit_type = $("#id_credit_type");
|
||||||
|
credit_type.attr('disabled', true);
|
||||||
|
credit_type.val(4);
|
||||||
|
|
||||||
|
let credit_amount = $("#id_credit_amount");
|
||||||
|
credit_amount.attr('disabled', true);
|
||||||
|
credit_amount.val('{{ total_fee }}');
|
||||||
|
|
||||||
|
let bank = $("#id_bank");
|
||||||
|
bank.attr('disabled', true);
|
||||||
|
bank.val('Société générale');
|
||||||
|
|
||||||
|
let join_BDE = $("#id_join_BDE");
|
||||||
|
join_BDE.attr('disabled', true);
|
||||||
|
join_BDE.attr('checked', 'checked');
|
||||||
|
|
||||||
|
let join_Kfet = $("#id_join_Kfet");
|
||||||
|
join_Kfet.attr('disabled', true);
|
||||||
|
join_Kfet.attr('checked', 'checked');
|
||||||
|
}
|
||||||
|
|
||||||
|
soge_field.change(fillFields);
|
||||||
|
|
||||||
|
{% if object.profile.soge %}
|
||||||
|
soge_field.attr('checked', true);
|
||||||
|
fillFields();
|
||||||
|
{% endif %}
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user