Make client groups optional

This commit is contained in:
Kumi 2020-06-22 06:15:09 +02:00
parent 7a1259a565
commit 68c0488462

View file

@ -1,4 +1,4 @@
from django.forms import ModelForm, CharField, BooleanField, ImageField, ModelChoiceField, ModelMultipleChoiceField, BooleanField
from django.forms import ModelForm, CharField, BooleanField, ImageField, ModelChoiceField, ModelMultipleChoiceField, BooleanField, ValidationError
from django.contrib.auth import get_user_model
from django.utils.translation import gettext_lazy as _
from django.contrib.auth import get_user_model
@ -45,7 +45,7 @@ class ClientEditForm(ModelForm):
company_id = CharField(label=_('Company Registration Number'), required=False)
default_currency = ModelChoiceField(Currency.objects.all(), label=_("Default Currency"))
brands = ModelMultipleChoiceField(Brand.objects.all(), label=_("Associated Brands"))
client_groups = ModelMultipleChoiceField(ClientGroup.objects.all(), label=_("Client Groups"))
client_groups = ModelMultipleChoiceField(ClientGroup.objects.all(), label=_("Client Groups"), required=False)
marketing_opt_in = BooleanField(label=_("Opted in to marketing messages"), required=False)
pgp_key = CharField(label=_("GPG encryption key"), required=False)
@ -66,11 +66,11 @@ class ClientCreateForm(ModelForm):
company_id = CharField(label=_('Company Registration Number'), required=False)
default_currency = ModelChoiceField(Currency.objects.all(), label=_("Default Currency"))
brands = ModelMultipleChoiceField(Brand.objects.all(), label=_("Associated Brands"))
client_groups = ModelMultipleChoiceField(ClientGroup.objects.all(), label=_("Client Groups"))
client_groups = ModelMultipleChoiceField(ClientGroup.objects.all(), label=_("Client Groups"), required=False)
marketing_opt_in = BooleanField(label=_("Opted in to marketing messages"), required=False)
pgp_key = CharField(label=_("GPG encryption key"), required=False)
send_password = BooleanField(label=_("Send password reset email now?"), required=False)
class Meta:
model = get_user_model()
fields = ('first_name', 'last_name', "company", "email", 'mobile', 'address1', 'address2', 'zip', 'city', 'state', 'country', 'vat_id', 'company_id', 'default_currency', 'brands', 'client_groups', 'marketing_opt_in', 'pgp_key', 'send_password')
fields = ('first_name', 'last_name', "company", "email", 'mobile', 'address1', 'address2', 'zip', 'city', 'state', 'country', 'vat_id', 'company_id', 'default_currency', 'brands', 'client_groups', 'marketing_opt_in', 'pgp_key', 'send_password')