Esempio n. 1
0
	def do_registration(self, form_values):
		client_form = ClientForm(form_values)
		user_form = UserCreationForm(form_values)
		subscriber_form = SubscriberCreationForm(form_values)
		if client_form.is_valid() and user_form.is_valid() and subscriber_form.is_valid():
			client = client_form.save(commit=False)
			client.payment_status = 0 # no payment, not so far.
			client.save()
			user = user_form.save(commit=False)
			user.email = subscriber_form.cleaned_data['email']
			user.first_name = subscriber_form.cleaned_data['first_name']
			user.last_name = subscriber_form.cleaned_data['last_name']
			user.is_active = True
			user.is_staff = False
			user.save()
			user_groups = [Group.objects.get(name__exact=GROUP_NAME_MAP['COMPANY_ADMIN'])]
			user.groups.add(*user_groups)
			subscriber = Subscriber(
				user=user,
				client=client
			)
			subscriber.save()
			return self.respond(is_saved=True)
		return self.respond(
			is_saved=False, 
			client_form_errors=client_form.errors,
			user_form_errors=user_form.errors,
			subscriber_form_errors=subscriber_form.errors
		)
Esempio n. 2
0
def client_new(request, template_name="client/client_new.html"):
    client_form = ClientForm(request.POST or None)
    contact_inlineformset = inlineformset_factory(Client, ClientContact, form=ClientContactForm, extra=1)

    if request.method == "POST":
        if request.POST['action'] == "save":

            if client_form.is_valid():
                client = client_form.save(commit=False)
                client.save()

                contacts = contact_inlineformset(request.POST, instance=client)
                if contacts.is_valid():
                    contacts.save()

                messages.success(request, _('Customer created successfully.'))
                redirect_url = reverse("client_view", args=(client.id,))
                return HttpResponseRedirect(redirect_url)

            else:
                messages.warning(request, _('Information not saved.'))

        else:
            messages.warning(request, _('Action not available.'))

    context = {"client_form": client_form,
               "contact_inlineformset": contact_inlineformset,
               "creating": True}

    return render(request, template_name, context)
Esempio n. 3
0
def create_client(request):
    client_form = ClientForm(request.POST, request.FILES)
    address_form = AddressForm(request.POST)

    if request.method == 'POST':
        if address_form.is_valid() and client_form.is_valid():
            client = client_form.save(commit=False)
            address = address_form.save(commit=False)

            # Verifica se usuário já existe
            if not User.objects.filter(username=client.email).exists():
                # Cria usuário para acessar o sistema
                User.objects.create_user(username=client.email, email=client.email,
                                         password=request.POST.get('password'),
                                         first_name=client.first_name)

                # Insere o cliente e endereço no banco
                client.save()
                address.client = client
                address.save()

                messages.success(request, _(u'Usuário criado com sucesso !'))
                return redirect('home_page')

            messages.add_message(request, messages.ERROR,
                                 _(u'Já existe usuário cadastrado com esse e-mail !'), extra_tags='danger')
    else:
        client_form = ClientForm()
        address_form = AddressForm()

    return render(request, 'client/client_form.html', {
        'client_form': client_form,
        'address_form': address_form,
        'login_form': LoginForm()
    })
Esempio n. 4
0
def client_edit(request):
    id_edit = request.GET.get('id')
    clientobj = Client.objects.get(id=id_edit)
    form = ClientForm(initial={'name': clientobj.name,
                               'description': clientobj.description, 'address': clientobj.address,
                               'email': clientobj.email, 'phone': clientobj.phone, 'website': clientobj.website, 'fax': clientobj.fax})
    if request.method == 'POST':
        form = ClientForm(request.POST)
        if form.is_valid():
            name = request.POST.get('name', '')
            description = request.POST.get('description', '')
            address = request.POST.get('address', '')
            email = request.POST.get('email', '')
            phone = request.POST.get('phone', '')
            website = request.POST.get('website', '')
            fax = request.POST.get('fax', '')
            clientobj.name = name
            clientobj.description = description
            clientobj.address = address
            clientobj.email = email
            clientobj.phone = phone
            clientobj.website = website
            clientobj.fax = fax
            clientobj.save()
            edit_done = True
            success = True
            msg = 'Client Edited Successfully'
            return HttpResponseRedirect("/clients/")
            return render(request, "client/client.html", locals())
Esempio n. 5
0
def newClient(request):
    my_client = Client(username=request.user)
    ContactFormSet = inlineformset_factory(Client, Contact, form=ContactForm, can_delete=False, extra=1)
    DetailsFormSet = inlineformset_factory(Client, Details, form=DetailsForm, can_delete=False, max_num=1)
    NegotiationResultFormSet = inlineformset_factory(Client, NegotiationResult, form=NegotiationResultForm, can_delete=False, extra=1)
    BrandFormSet = inlineformset_factory(Client, Brand, form=BrandForm, can_delete=True, extra=1)
    PayerFormSet = inlineformset_factory(Client, Payer, form=PayerForm, can_delete=True, extra=1)
    formClient = ClientForm(request.POST or None, request.FILES or None, instance=my_client)
    formContactSet = ContactFormSet(request.POST or None, instance=my_client)
    formDetailsSet = DetailsFormSet(request.POST or None, instance=my_client)
    formNegotiationResultSet = NegotiationResultFormSet(request.POST or None, instance=my_client)
    formBrandSet = BrandFormSet(request.POST or None, instance=my_client)
    formPayerSet = PayerFormSet(request.POST or None, instance=my_client)
    if formClient.is_valid() and formContactSet.is_valid() and formDetailsSet.is_valid() and formNegotiationResultSet.is_valid() and formBrandSet.is_valid() and formPayerSet.is_valid():
        formClient.save()
        formContactSet.save()
        formDetailsSet.save()
        formNegotiationResultSet.save()
        formBrandSet.save()
        formPayerSet.save()
        error(request, 'Информация о клиенте успешно добавлена.')
        return redirect('client-index')
    var = {'formClient': formClient, 'formContactSet': formContactSet, 'formDetailsSet': formDetailsSet, 'formNegotiationResultSet': formNegotiationResultSet, 'formBrandSet': formBrandSet, 'formPayerSet': formPayerSet}

    return render_to_response('client/client/edit.html', var, context_instance=RequestContext(request))
Esempio n. 6
0
 def test_invalid_client_form(self):
     """
     Using an invalid email
     """
     client = Client.objects.create(name='Eduardo', email='edu')
     data = {'name': client.name, 'email': client.email}
     form = ClientForm(data=data)
     self.assertFalse(form.is_valid())
Esempio n. 7
0
    def post(self, request, *args, **kwargs):
        context = self.get_context()
        logger.debug('SINGUP POST - BODY')
        logger.debug(request.body)
        form = ClientForm(request.POST)
        context.update({'form': form})

        if not form.is_valid():
            logger.debug('SINGUP FORM INVALID')
            logger.debug(form.errors.as_text)
            context.update({'is_singup': True})
            return render(request, self._template, context)

        logger.debug(u'SINGUP FORM VALID')
        logger.debug(u'name: {}'.format(form.data.get('name')))
        logger.debug(u'email: {}'.format(form.data.get('email')))
        logger.debug(u'cargo: {}'.format(form.data.get('cargo')))
        logger.debug(u'political_party: {}'.format(
            form.data.get('political_party')))
        logger.debug(u'proposal: {}'.format(form.data.get('proposal')))
        logger.debug(u'password: {}'.format(form.data.get('password')))

        # user
        password = form.data.get('password')
        email = form.data.get('email')
        # check
        has_user = User.objects.filter(username=email)
        if has_user:
            logger.info(u'Email: {} already exists'.format(email))
            context.update({'email_exist': True})
            return render(request, self._template, context)

        has_email = Client.objects.filter(email=email)
        if has_email:
            logger.info(u'Email: {} already exists'.format(email))
            context.update({'email_exist': True})
            return render(request, self._template, context)

        with transaction.atomic():
            user = User(username=email)
            user.set_password(password)
            user.save()
            # Get politicatl Party

            client = Client(
                user=user,
                name=form.data.get('name'),
                email=email,
                cargo=form.data.get('cargo'),
                political_party=PoliticalParty(
                    id=form.data.get('political_party')),
                proposal=form.data.get('proposal'),
            )
            client.save()
            request.session['client'] = client

        return render(request, self._template, context)
Esempio n. 8
0
def edit_client(request, id):
    c = Client.objects.get(id=id)
    if request.method == 'POST':
        form = ClientForm(request.POST, instance=c)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/')
    else:
        form = ClientForm(instance=c)
    return {'form': form, 'action': '/client/edit/'+id+'/', 'button': 'Editar'}
Esempio n. 9
0
 def post(self, request):
     """Save client and redirect to index."""
     form = ClientForm(request.POST)
     if form.is_valid():
         new_client = form.save()
         return redirect('client:measurment_add', client_id=new_client.id)
     else:
         return render(request, 'client/add-client.html', {
             'form': form,
             'func': 'Add'
         })
Esempio n. 10
0
    def get_context_data(self, **kwargs):
        if 'form' not in kwargs:
            kwargs['form'] = self.get_form()

        context = super(OrderRaiseCreateView, self).get_context_data(**kwargs)
        if self.request.POST:
            context['client_form'] = ClientForm(self.request.POST)
            context['blinds_formset'] = BlindOrderFormset(self.request.POST)
        else:
            context['client_form'] = ClientForm()
            context['blinds_formset'] = BlindOrderFormset()
        return context
Esempio n. 11
0
def create_client(request):
    if request.method == 'POST':
        form = ClientForm(request.POST)
        if form.is_valid():
            c = form.save()
            for i in range(2):
                p = 'phone'+i.__str__()
                c.phone_set.create(number=request.POST[p])
            c.save()
            return HttpResponseRedirect('/')
    else:
        form = ClientForm()
    return {'form': form, 'action': '/client/', 'button': 'Salvar'}
Esempio n. 12
0
 def post(self,request):
     submitted_form = ClientForm(request.POST)
     if submitted_form.is_valid():
         name = submitted_form.cleaned_data.get('name')
         payload = {'name':name}
         submitted_password = submitted_form.cleaned_data.get('password')
         password = make_password(submitted_password)
         new_client = Client(name = name, password = password)
         new_client.save()
         request.session.flush()
         request.session['id'] = new_client.id
         return redirect('/gvd/index')
     return render(request,self.template,{'error':'Invalid input, please try again', 'client_form':self.empty_form})
Esempio n. 13
0
def client_view(request, client_id, template_name="client/client_tabs.html"):
    client = get_object_or_404(Client, pk=client_id)
    client_form = ClientForm(request.POST or None, instance=client)
    contact_inlineformset = inlineformset_factory(Client, ClientContact, form=ClientContactForm, extra=1)
    contact_inlineformset = contact_inlineformset(instance=client)

    for field in client_form.fields:
        client_form.fields[field].widget.attrs['disabled'] = True

    for form in contact_inlineformset:
        for field in form.fields:
            form.fields[field].widget.attrs['disabled'] = True

    if request.method == "POST":
        if request.POST['action'] == "remove":

            try:
                client.delete()
                messages.success(request, _('Customer removed successfully.'))
                return redirect('client_list')
            except ProtectedError:
                messages.error(request, _("Error trying to delete the client."))
                redirect_url = reverse("client_view", args=(client_id,))
                return HttpResponseRedirect(redirect_url)

    context = {"viewing": True,
               "client": client,
               "client_form": client_form,
               "contact_inlineformset": contact_inlineformset,
               "tab": "1"
               }

    return render(request, template_name, context)
Esempio n. 14
0
 def get(self, request):
     """Return add new client form."""
     form = ClientForm()
     return render(request, 'client/add-client.html', {
         'form': form,
         'func': 'Add'
     })
Esempio n. 15
0
def add_client(request):
  return_to = request.GET.get('return_to', '')

  context_vars = dict()
  context_vars['header'] = capfirst(_('add new client'))
  client_form = ClientForm(prefix='client')
#  contact_form = ContactForm(prefix='contact')
  address_form = AddressForm(prefix='address')
  postal_address_form = AddressForm(prefix='post_address')
  if request.method == "POST":
    client_form = ClientForm(request.POST, request.FILES, prefix='client')
    address_form = AddressForm(request.POST, request.FILES, prefix='address')
    postal_address_form = AddressForm(request.POST, request.FILES, prefix='post_address')
    try:
      if client_form.is_valid() and address_form.is_valid():
        client = client_form.save()
        address_form = AddressForm(request.POST, request.FILES, prefix='address', instance=client.address)
        if not address_form.is_valid():
          raise InvalidForm()
        address_form.save()
        postal_address_form = AddressForm(request.POST, request.FILES, prefix='post_address', instance=client.postal_address)
        if postal_address_form.is_valid():
          postal_address_form.save()
        else:
          client.postal_address.postcode = client.address.postcode
          client.postal_address.address = client.address.address
          client.postal_address.city = client.address.city
          client.postal_address.county = client.address.county
          client.postal_address.country = client.address.country
          client.postal_address.latitude = client.address.latitude
          client.postal_address.longitude = client.address.longitude
          client.postal_address.save()
        if settings.WORKFLOWMAX_APIKEY and settings.WORKFLOWMAX_ACCOUNTKEY:
          client.wm_sync()
        if not return_to:
          return_to = reverse('client-view', args=[client.id])
        messages.success(request, capfirst(_('client was created successfully')), fail_silently=True)
        return HttpResponseRedirect(return_to)
    except InvalidForm:
      pass
  
  context_vars['client_form'] = client_form
  context_vars['address_form'] = address_form
  context_vars['postal_address_form'] = postal_address_form
  return direct_to_template(request, template='client/form.html', extra_context=context_vars)
Esempio n. 16
0
def client_update(request, client_id, template_name="client/client_tabs.html"):
    client = get_object_or_404(Client, pk=client_id)
    client_form = ClientForm(request.POST or None, instance=client)
    contact_inlineformset = inlineformset_factory(Client, ClientContact, form=ClientContactForm, extra=1)
    contacts = contact_inlineformset(request.POST, instance=client)

    if request.method == "POST":
        if request.POST['action'] == "save":
            if client_form.is_valid() and contacts.is_valid():

                if client_form.has_changed():
                    client_form.save()

                if contacts.has_changed():
                    contacts.save()

                if client_form.has_changed() or contacts.has_changed():
                    messages.success(request, _('Customer updated successfully.'))
                else:
                    messages.warning(request, _('There is no changes to save.'))

                redirect_url = reverse("client_view", args=(client.id,))
                return HttpResponseRedirect(redirect_url)

    else:
        contact_inlineformset = contact_inlineformset(instance=client)

    context = {"client": client,
               "client_form": client_form,
               "contact_inlineformset": contact_inlineformset,
               "editing": True,
               "tab": "1"}

    return render(request, template_name, context)
Esempio n. 17
0
 def get(self, request, pk):
     """Return update client form."""
     client = get_object_or_404(Client, id=pk)
     form = ClientForm(instance=client)
     return render(request, 'client/add-client.html', {
         'form': form,
         'func': 'Update',
         'client': client
     })
Esempio n. 18
0
def add_client(request):
    if request.method == "POST":
        cform = ClientForm(request.POST, instance=Client())
        caform = ClientAdditionalForm(request.POST, instance=Client_Additional())

        if cform.is_valid() and caform.is_valid():
            client = cform.save(commit=False)
            client.awb_assigned_from = request.POST['client_code'] + '0000001'
            client.awb_assigned_to = request.POST['client_code'] + '0010000'
            client.awb_left = 10000
            client.save()
            instance = caform.save(commit=False)
            instance.client_id = client.pk
            instance.save()
            return HttpResponseRedirect('/client/')
    else:
        cform = ClientForm()
        caform = ClientAdditionalForm()
    return render(request, 'client/addclient.html', {'cform': cform, 'caform': caform})
Esempio n. 19
0
def clientsignup(request):
    er=''
    registered = False

    if request.method == 'POST':

        # Get info from "both" forms
        # It appears as one form to the user on the .html page
        user_form = UserForm(data=request.POST)
        client_form = ClientForm(data=request.POST)

        # Check to see both forms are valid
        if user_form.is_valid() and client_form.is_valid():

            # Save User Form to Database
            user = user_form.save(commit=False)
            user.is_client = True

            # Hash the password
            user.set_password(user.password)

            # Update with Hashed password
            user.save()

            # Now we deal with the extra info!
            client = client_form.save(commit=False)
            # Can't commit yet because we still need to manipulate
            client.user = user
            client.save()
            # Registration Successful!
            registered = True

        else:
            # One of the forms was invalid if this else gets called.
            # raise client_form.errors
            user_form = UserForm()
            client_form = ClientForm()
            er = 'Registration Failed'
    else:
        # Was not an HTTP post so we just render the forms as blank.
        user_form= UserForm()
        client_form = ClientForm()

    # This is the render and context dictionary to feed
    # back to the registration.html file page.
    return render(request,'client/signup.html',
                          {'user_form':user_form,
                            'client_form':client_form,
                           'registered':registered,
                           'insertme':'Client SignUp',
                           'er':er})
Esempio n. 20
0
 def post(self, request, pk):
     """Update client by id ."""
     client = get_object_or_404(Client, id=pk)
     measurements_exist = False
     if client.gender == 'M':
         measurements_exist = MaleMeasurements.objects.filter(
             client=client).exists()
     else:
         measurements_exist = FemaleMeasurements.objects.filter(
             client=client).exists()
     form = ClientForm(request.POST, instance=client)
     if form.is_valid():
         form.save()
         if measurements_exist:
             return redirect('client:measurment_update',
                             client_id=client.id)
         else:
             return redirect('client:measurment_add', client_id=client.id)
     else:
         return render(request, 'client/add-client.html', {
             'form': form,
             'client': client
         })
Esempio n. 21
0
def editClient(request, id):
    director_group = Group.objects.get(name='Руководство').user_set.all()
    my_client = Client.objects.get(id=id)
    neg_results = NegotiationResult.objects.filter(client=my_client)
    ContactFormSet = inlineformset_factory(Client, Contact, form=ContactForm, can_delete=False, extra=1)
    DetailsFormSet = inlineformset_factory(Client, Details, form=DetailsForm, can_delete=False, max_num=1)
    NegotiationResultFormSet = inlineformset_factory(Client, NegotiationResult, form=NegotiationResultForm, can_delete=False, extra=1)
    if Brand.objects.filter(client=my_client):
        BrandFormSet = inlineformset_factory(Client, Brand, form=BrandForm, can_delete=True, extra=0)
    else:
        BrandFormSet = inlineformset_factory(Client, Brand, form=BrandForm, can_delete=True, extra=1)
    if Payer.objects.filter(client=my_client):
        PayerFormSet = inlineformset_factory(Client, Payer, form=PayerForm, can_delete=True, extra=0)
    else:
        PayerFormSet = inlineformset_factory(Client, Payer, form=PayerForm, can_delete=True, extra=1)
    formClient = ClientForm(request.POST or None, request.FILES or None, instance=my_client)
    formContactSet = ContactFormSet(request.POST or None, instance=my_client)
    formDetailsSet = DetailsFormSet(request.POST or None, instance=my_client)
    formNegotiationResultSet = NegotiationResultFormSet(request.POST or None, instance=my_client)
    formBrandSet = BrandFormSet(request.POST or None, instance=my_client)
    formPayerSet = PayerFormSet(request.POST or None, instance=my_client)
    if formClient.is_valid() and formContactSet.is_valid() and formDetailsSet.is_valid() and formNegotiationResultSet.is_valid() and formBrandSet.is_valid() and formPayerSet.is_valid():
        formClient.save()
        formContactSet.save()
        formDetailsSet.save()
        formNegotiationResultSet.save()
        formBrandSet.save()
        formPayerSet.save()
        error(request, 'Информация о клиенте успешно изменена.')
        return redirect('client-index')
    var = {'client': my_client, 'neg_results': neg_results, 'formClient': formClient, 'formContactSet': formContactSet, 'formDetailsSet': formDetailsSet, 'formNegotiationResultSet': formNegotiationResultSet, 'formBrandSet': formBrandSet, 'formPayerSet': formPayerSet}

    if request.user == my_client.username or request.user in director_group:
        return render_to_response('client/client/edit.html', var, context_instance=RequestContext(request))
    else:
        return redirect('client-index')
Esempio n. 22
0
def client_details(request, task=None, id=None):
    """ Client Details Add """
    response = {}
    check = ''
    msg = ''
    Success = False
    if task == 'add':
        id = None
        form = ClientForm()
        if request.method == "POST":
            form = ClientForm(request.POST)
            name = request.POST.get('name', '')
            description = request.POST.get('description', '')
            address = request.POST.get('address', '')
            email = request.POST.get('email', '')
            phone = request.POST.get('phone', '')
            website = request.POST.get('website', '')
            fax = request.POST.get('fax', '')
            if form.is_valid():
                check = Client.objects.filter(email=email)
                check1 = Client.objects.filter(name=name)
                print "email", email
                if not check:
                    if not check1:
                        client_obj = Client.objects.create(
                            name=name, description=description, address=address, email=email, phone=phone, website=website, fax=fax)
                        added = True
                        success = True
                        return HttpResponseRedirect("/clients/")
                    else:
                        msg = " Name already Exists "
                else:
                    msg = "Email Already Exists"
            else:
                msg = "Error Occured"
    elif task == "edit":
        id_edit = id
        clientobj = Client.objects.get(id=id_edit)
        form = ClientForm(initial={'name': clientobj.name,
                                   'description': clientobj.description, 'address': clientobj.address,
                                   'email': clientobj.email, 'phone': clientobj.phone,
                                   'website': clientobj.website, 'fax': clientobj.fax})
        if request.method == 'POST':
            form = ClientForm(request.POST)
            if form.is_valid():
                name = request.POST.get('name', '')
                description = request.POST.get('description', '')
                address = request.POST.get('address', '')
                email = request.POST.get('email', '')
                phone = request.POST.get('phone', '')
                website = request.POST.get('website', '')
                fax = request.POST.get('fax', '')
                clientobj.name = name
                clientobj.description = description
                clientobj.address = address
                clientobj.email = email
                clientobj.phone = phone
                clientobj.website = website
                clientobj.fax = fax
                clientobj.save()
                edit_done = True
                success = True
                msg = 'Client Edited Successfully'
                return HttpResponseRedirect("/clients/")
            else:
                msg = 'Invalid Data'
#           response = {'msg':msg, 'success':success}
    elif task == "delete":
        id_delete = id
        clientobj = Client.objects.get(id=id_delete)
        clientobj.status = 1
        clientobj.save()
        success = True
        msg = "Client Deactivated Successfully"
        return HttpResponseRedirect("/clients/")
    elif task == "active":
        active = id
        clientobj = Client.objects.get(id=active)
        clientobj.status = 2
        clientobj.save()
        success = True
        msg = "Client Activated Successfully"
        return HttpResponseRedirect("/clients/")
    return render(request, "client/client.html", locals())
Esempio n. 23
0
 def test_valid_client_form(self):
     client = Client.objects.create(name='Carlos')
     data = {'name': client.name}
     form = ClientForm(data=data)
     self.assertTrue(form.is_valid())
Esempio n. 24
0
 def get_context(self):
     form = ClientForm()
     context = {'form': form, 'client': self.client}
     return context
Esempio n. 25
0
def client_form(request, id=0):
    if request.method == "GET":
        if id == 0:
            form = ClientForm()
        else:
            client = Client.objects.get(pk=id)
            form = ClientForm(instance=client)
        return render(request, "clients/client_form.html", {'form': form})
    else:
        if id == 0:
            form = ClientForm(request.POST, request.FILES)
        else:
            client = Client.objects.get(pk=id)
            form = ClientForm(request.POST, instance=client)
        if form.is_valid():
            form.save()
        return redirect('/clients/list')
Esempio n. 26
0
  context_vars['postal_address_form'] = postal_address_form
  return direct_to_template(request, template='client/form.html', extra_context=context_vars)

@login_required
def edit_client(request, object_id):
  return_to = request.GET.get('return_to', '')

  context_vars = dict()
  try:
    object_id = int(object_id)
    client = Client.objects.get(id=object_id)
  except ValueError, ObjectDoesNotExist:
    return HttpResponseRedirect(reverse('client-list'))
  
  context_vars['header'] = capfirst(_('edit client %s') % client.name)
  client_form = ClientForm(prefix='client', instance=client)
  address_form = AddressForm(prefix='address', instance=client.address)
  postal_address_form = AddressForm(prefix='post_address', instance=client.postal_address)
  if request.method == "POST":
    client_form = ClientForm(request.POST, request.FILES, prefix='client', instance=client)
    address_form = AddressForm(request.POST, request.FILES, prefix='address', instance=client.address)
    postal_address_form = AddressForm(request.POST, request.FILES, prefix='post_address', instance=client.postal_address)
    if client_form.is_valid() and address_form.is_valid() and postal_address_form.is_valid():
      client = client_form.save()
      address_form.save()
      postal_address_form.save()
      if settings.WORKFLOWMAX_APIKEY and settings.WORKFLOWMAX_ACCOUNTKEY:
        client.wm_sync()
      if not return_to:
        return_to = reverse('client-view', args=[client.id])
      messages.success(request, capfirst(_('client was modified successfully')), fail_silently=True)