mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-08-20 14:13:41 +00:00
Montant minimal de rechargement + refactor de la fonction payment + self adhesion
This commit is contained in:
parent
5319ed266c
commit
a71e01e18a
8 changed files with 80 additions and 7 deletions
|
@ -41,6 +41,8 @@ from django.db.models import Q
|
|||
from django.forms import ModelForm, Form
|
||||
from django.core.validators import MinValueValidator,MaxValueValidator
|
||||
from .models import Article, Paiement, Facture, Banque
|
||||
from preferences.models import OptionalUser
|
||||
from users.models import User
|
||||
|
||||
from re2o.field_permissions import FieldPermissionFormMixin
|
||||
|
||||
|
@ -287,3 +289,16 @@ class RechargeForm(Form):
|
|||
min_value=0.01,
|
||||
validators = []
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.user = kwargs.pop('user')
|
||||
super(RechargeForm, self).__init__(*args, **kwargs)
|
||||
|
||||
def clean_value(self):
|
||||
value = self.cleaned_data['value']
|
||||
options, _created = OptionalUser.objects.get_or_create()
|
||||
if value < options.min_online_payment:
|
||||
raise forms.ValidationError("Montant inférieur au montant minimal de paiement en ligne (%s) €" % options.min_online_payment)
|
||||
if value + self.user.solde > options.max_solde:
|
||||
raise forms.ValidationError("Le solde ne peux excéder %s " % options.max_solde)
|
||||
return value
|
||||
|
|
|
@ -76,7 +76,8 @@ def ipn(request):
|
|||
return HttpResponse("HTTP/1.0 200 OK")
|
||||
|
||||
|
||||
def comnpay(facture, host):
|
||||
def comnpay(facture, request):
|
||||
host = request.get_host()
|
||||
p = ComnpayPayment(
|
||||
"DEMO",
|
||||
"DEMO",
|
||||
|
|
|
@ -687,7 +687,7 @@ def new_facture_solde(request, userid):
|
|||
|
||||
@login_required
|
||||
def recharge(request):
|
||||
f = RechargeForm(request.POST or None)
|
||||
f = RechargeForm(request.POST or None, user=request.user)
|
||||
if f.is_valid():
|
||||
facture = Facture(user=request.user)
|
||||
paiement, _created = Paiement.objects.get_or_create(moyen='Rechargement en ligne')
|
||||
|
@ -702,6 +702,6 @@ def recharge(request):
|
|||
)
|
||||
v.save()
|
||||
options, _created = AssoOption.objects.get_or_create()
|
||||
content = payment.PAYMENT_SYSTEM[options.payment](facture, request.get_host())
|
||||
content = payment.PAYMENT_SYSTEM[options.payment](facture, request)
|
||||
return render(request, 'cotisations/payment.html', content)
|
||||
return form({'rechargeform':f}, 'cotisations/recharge.html', request)
|
||||
|
|
|
@ -49,6 +49,8 @@ class EditOptionalUserForm(ModelForm):
|
|||
self.fields['user_solde'].label = 'Activation du solde pour\
|
||||
les utilisateurs'
|
||||
self.fields['max_solde'].label = 'Solde maximum'
|
||||
self.fields['min_online_payment'].label = 'Montant de rechargement minimum en ligne'
|
||||
self.fields['self_adhesion'].label = 'Auto inscription'
|
||||
|
||||
|
||||
class EditOptionalMachineForm(ModelForm):
|
||||
|
|
20
preferences/migrations/0031_optionaluser_self_adhesion.py
Normal file
20
preferences/migrations/0031_optionaluser_self_adhesion.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.7 on 2018-01-12 11:34
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('preferences', '0030_auto_20180111_2346'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='optionaluser',
|
||||
name='self_adhesion',
|
||||
field=models.BooleanField(default=False, help_text='Un nouvel utilisateur peut se créer son compte sur re2o'),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.7 on 2018-01-13 16:43
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('preferences', '0031_optionaluser_self_adhesion'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='optionaluser',
|
||||
name='min_online_payment',
|
||||
field=models.DecimalField(decimal_places=2, default=10, max_digits=5),
|
||||
),
|
||||
]
|
|
@ -46,11 +46,20 @@ class OptionalUser(models.Model):
|
|||
decimal_places=2,
|
||||
default=50
|
||||
)
|
||||
min_online_payment = models.DecimalField(
|
||||
max_digits=5,
|
||||
decimal_places=2,
|
||||
default=10
|
||||
)
|
||||
gpg_fingerprint = models.BooleanField(default=True)
|
||||
all_can_create = models.BooleanField(
|
||||
default=False,
|
||||
help_text="Tous les users peuvent en créer d'autres",
|
||||
)
|
||||
self_adhesion = models.BooleanField(
|
||||
default=False,
|
||||
help_text="Un nouvel utilisateur peut se créer son compte sur re2o"
|
||||
)
|
||||
|
||||
class Meta:
|
||||
permissions = (
|
||||
|
|
|
@ -54,11 +54,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<tr>
|
||||
<th>Creations d'users par tous</th>
|
||||
<td>{{ useroptions.all_can_create }}</td>
|
||||
{% if useroptions.user_solde %}
|
||||
<th>Solde maximum</th>
|
||||
<td>{{ useroptions.max_solde }}</td>
|
||||
{% endif %}
|
||||
<th>Auto inscription</th>
|
||||
<td>{{ useroptions.self_adhesion }}</td>
|
||||
</tr>
|
||||
{% if useroptions.user_solde %}
|
||||
<tr>
|
||||
<th>Solde maximum</th>
|
||||
<td>{{ useroptions.max_solde }}</td>
|
||||
<th>Montant minimal de rechargement en ligne</th>
|
||||
<td>{{ useroptions.min_online_payment }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
<h4>Préférences machines</h4>
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'preferences:edit-options' 'OptionalMachine' %}">
|
||||
|
|
Loading…
Reference in a new issue