From 68c04884622e8a2196ae53fb7aef4ab86d963cd4 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Mon, 22 Jun 2020 06:15:09 +0200 Subject: [PATCH] Make client groups optional --- core/forms/profiles.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/forms/profiles.py b/core/forms/profiles.py index aa06dea..407b3e5 100644 --- a/core/forms/profiles.py +++ b/core/forms/profiles.py @@ -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') \ No newline at end of file + 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')