8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-05 01:16:27 +00:00

Les champs d'identification pour le paiement ne sont requis que lorsque le moyen de paiement est activé.

This commit is contained in:
Hugo LEVY-FALK 2018-03-18 10:10:56 +01:00
parent 8ce44ee2af
commit 53ea7e08bb
3 changed files with 48 additions and 7 deletions

View file

@ -143,6 +143,25 @@ class EditAssoOptionForm(ModelForm):
self.fields['utilisateur_asso'].label = 'Compte utilisé pour\
faire les modifications depuis /admin'
def clean(self):
cleaned_data = super().clean()
payment = cleaned_data.get('payment')
if payment == 'NONE':
return cleaned_data
if not cleaned_data.get('payment_id', ''):
msg = forms.ValidationError("Vous devez spécifier un identifiant \
de paiement.")
self.add_error('payment_id', msg)
if not cleaned_data.get('payment_pass', ''):
msg = forms.ValidationError("Vous devez spécifier un mot de passe \
de paiement.")
self.add_error('payment_pass', msg)
return cleaned_data
class EditMailMessageOptionForm(ModelForm):
"""Formulaire d'edition des messages de bienvenue personnalisés"""

View file

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-03-18 09:05
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('preferences', '0028_assooption_description'),
]
operations = [
migrations.AlterField(
model_name='assooption',
name='payment_id',
field=models.CharField(blank=True, default='', max_length=255),
),
]

View file

@ -47,7 +47,7 @@ class PreferencesModel(models.Model):
def get_cached_value(cls, key):
instance = cache.get(cls().__class__.__name__.lower())
if instance == None:
instance = cls.set_in_cache()
instance = cls.set_in_cache()
return getattr(instance, key)
class Meta:
@ -158,7 +158,7 @@ class OptionalUser(PreferencesModel):
@receiver(post_save, sender=OptionalUser)
def optionaluser_post_save(sender, **kwargs):
"""Ecriture dans le cache"""
"""Ecriture dans le cache"""
user_pref = kwargs['instance']
user_pref.set_in_cache()
@ -255,7 +255,7 @@ class OptionalMachine(PreferencesModel):
@receiver(post_save, sender=OptionalMachine)
def optionalmachine_post_save(sender, **kwargs):
"""Synchronisation ipv6 et ecriture dans le cache"""
"""Synchronisation ipv6 et ecriture dans le cache"""
machine_pref = kwargs['instance']
machine_pref.set_in_cache()
if machine_pref.ipv6_mode != "DISABLED":
@ -355,7 +355,7 @@ class OptionalTopologie(PreferencesModel):
@receiver(post_save, sender=OptionalTopologie)
def optionaltopologie_post_save(sender, **kwargs):
"""Ecriture dans le cache"""
"""Ecriture dans le cache"""
topologie_pref = kwargs['instance']
topologie_pref.set_in_cache()
@ -448,7 +448,7 @@ class GeneralOption(PreferencesModel):
@receiver(post_save, sender=GeneralOption)
def generaloption_post_save(sender, **kwargs):
"""Ecriture dans le cache"""
"""Ecriture dans le cache"""
general_pref = kwargs['instance']
general_pref.set_in_cache()
@ -548,13 +548,15 @@ class AssoOption(PreferencesModel):
('NONE', 'NONE'),
('COMNPAY', 'COMNPAY'),
)
payment = models.CharField(max_length=255,
payment = models.CharField(
max_length=255,
choices=PAYMENT,
default='NONE',
)
payment_id = models.CharField(
max_length=255,
default='',
blank=True
)
payment_pass = AESEncryptedField(
max_length=255,
@ -623,7 +625,7 @@ class AssoOption(PreferencesModel):
@receiver(post_save, sender=AssoOption)
def assooption_post_save(sender, **kwargs):
"""Ecriture dans le cache"""
"""Ecriture dans le cache"""
asso_pref = kwargs['instance']
asso_pref.set_in_cache()