Ejemplo n.º 1
0
def update(request, id):  
    contactData = Contacts.objects.get(id=id)  
    form = ContactForm(request.POST, instance = contactData)  
    if form.is_valid():  
        form.save()  
        return redirect("/show")  
    return render(request, 'edit.html', {'contactData': contactData})  
Ejemplo n.º 2
0
def add(request):
    if request.method == 'GET':
        form = ContactForm()
        return render_to_response('contacts/New_contact.html',
                                  context_instance=RequestContext(
                                      request, {'form': form}))
    else:
        cnt = Contact()
        form = ContactForm(request.POST, request.FILES, instance=cnt)
        if form.is_valid():
            form.save()
            send_mail('new contact', 'there is a new contact',
                      settings.EMAIL_HOST_USER, ['*****@*****.**'])
            return render_to_response('contacts/New_contact.html',
                                      context_instance=RequestContext(
                                          request, {
                                              'form': form,
                                              'status': 'saved'
                                          }))
        else:
            return render_to_response('contacts/New_contact.html',
                                      context_instance=RequestContext(
                                          request, {
                                              'form': form,
                                              'status': 'error'
                                          }))
def found_item_details(request, id):
    f_item = get_object_or_404(Item, id=id)
    related_found_item = Item.objects.filter(status__icontains='phone')[1:2]

    # Contact Models ---------------------#
    form = ContactForm(request.POST or None)
    errors = None
    if form.is_valid():
        form.save()
        messages.add_message(
            request, messages.SUCCESS,
            'Your message has been sent  successfully, We will cantact you in a short time'
        )
        return HttpResponseRedirect(request.META.get("HTTP_REFERER"))
    if form.errors:
        errors = form.errors
        messages.add_message(request, messages.ERROR,
                             'Please give the correct information')
    # End of contact -----------------------------------------------------------------------

    context = {
        'f_item': f_item,
        'related_found_item': related_found_item,
        'form': form,
        'errors': errors
    }

    return render(request, 'found-item-details.html', context)
Ejemplo n.º 4
0
 def post(self, request, *args, **kwargs):
     contact_form = ContactForm(request.POST)
     
     if contact_form.is_valid():
         contact_form.save()
         return redirect(reverse('contacts:contact_list'))
     else:
         return render(request, 'contacts/contact_new.html', status=422)
Ejemplo n.º 5
0
def contact_view(request):
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponse('Good Form', status=status.HTTP_201_CREATED)
    else:
        form = ContactForm()

    return render(request, 'contact.html', {'form': form})
Ejemplo n.º 6
0
def contacts(request):

    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            form.save()
            success = 'Pregunta enviada, Ponto te responderemos'
            products = Product.objects.all()

    return render(request=request, template_name='contacts/contacts.html')
Ejemplo n.º 7
0
def add_contact(request):
    if request.method == 'GET':
        form = ContactForm()
    else:
        form = ContactForm(data=request.POST)
        if form.is_valid():
            form.save()
            return redirect(to='list_contacts')

    return render(request, "contacts/add_contact.html", {"form": form})
Ejemplo n.º 8
0
def create_contact(request):
    if request.method == 'POST':
        createfor = ContactForm(request.POST)
        if createfor.is_valid():
                createfor.save()
                return redirect(reverse('list'))
        else:
    			return render(request, 'contacts/create_contact.html', {'createfor': createfor})
    createfor = ContactForm()
    return render(request, 'contacts/create_contact.html', {'createfor': createfor})
Ejemplo n.º 9
0
def create(request):  
    if request.method == "POST":
        form = ContactForm(request.POST)  
        if form.is_valid():  
            try:  
                form.save()  
                return redirect('/show')  
            except:  
                pass
    else:  
        form = ContactForm()  
    return render(request,'create.html',{'form':form})
Ejemplo n.º 10
0
def edit_contact(request , id_contact):
    contact = Contact.objects.get(id=id_contact)
    if request.method == 'POST':
        contactform = ContactForm(request.POST, instance=contact)
        if contactform.is_valid():
            contactform.save()
            return HttpResponse('Editado!')
        else:
            return render(request, 'contacts/edit_contact.html', {'contactform': contactform} )
    else:
		contactform = ContactForm(instance=contact)
		return render(request, 'contacts/edit_contact.html' , {'contactform': contactform} )
Ejemplo n.º 11
0
def update(request, id):
    contact = Contact.objects.get(id=id)
    form = ContactForm(request.POST, instance=contact)
    if form.is_valid():
        form.save()
        return redirect("/contacts?updated=true")
    else:
        err = form.errors
        return render(request, 'contacts/edit.html', {
            'contact': contact,
            'errors': err
        })
    return render(request, 'contacts/edit.html', {'contact': contact})
Ejemplo n.º 12
0
 def post(self, request, *args, **kwargs):
     contact = get_object_or_404(Contact, pk=kwargs['contact_id'])
     contact_form = ContactForm(request.POST, instance=contact)
     if contact_form.is_valid():
         contact_form.save()
         return redirect(
             reverse('contacts:contact_detail', args=(contact.id,))
         )
     else:
         context = {'contact': contact}
         return render(
             request, 'contacts/contact_edit.html', context, status=422
         )
Ejemplo n.º 13
0
def edit_contact(request, pk):
    contact = get_object_or_404(Contact, pk=pk)
    if request.method == 'GET':
        form = ContactForm(instance=contact)
    else:
        form = ContactForm(data=request.POST, instance=contact)
        if form.is_valid():
            form.save()
            return redirect(to='list_contacts')

    return render(request, "contacts/edit_contact.html", {
        "form": form,
        "contact": contact
    })
Ejemplo n.º 14
0
def compte_dormant_add(request):
    """
        Fonction Add new object
    """
    if request.method == 'POST':
        # create a form instance and populate it with data from the request:
        form = Compte_dormantForm(request.POST)

        # check whether it's valid:
        if form.is_valid():
            # process the data in form.cleaned_data as required
            compte_dormant = form.save(commit=False)
            compte_dormant.user = request.user
            compte_dormant.save()
            messages.success(request, "Compte dormant enregistrée!")
            # redirect to a new URL:
            return HttpResponseRedirect(
                reverse('compte_dormant:compte_dormant_list'))
    # if a GET (or any other method) we'll create a blank form
    else:
        form = Compte_dormantForm()

    if request.method == 'POST':
        if request.is_ajax():
            formContact = ContactForm(request.POST)
            if formContact.is_valid():
                formContact.cleaned_data
                formContact.user = request.user
                formContact.save()
                latest = Contact.objects.latest('id').id
                contact_object = model_to_dict(Contact.objects.get(pk=latest))

                return JsonResponse({'error': False, 'data': contact_object})
            else:
                print(formContact.errors)
                return JsonResponse({
                    'error': True,
                    'data': formContact.errors
                })
        else:
            error = {'message': 'Error, must be an Ajax call.'}
            return JsonResponse(error, content_type="application/json")
    else:
        formContact = ContactForm()

        context = {'form': form, 'formContact': formContact}
        template_name = 'pages/compte_dormant/compte_dormant_add.html'
        return render(request, template_name, context)
Ejemplo n.º 15
0
def add_contact(request):
    #organization = Organization.objects.filter()
    users = User.objects.filter(is_active=True).order_by('email')
    form = ContactForm(assigned_to=users)
    #form = ContactForm(assigned_to=users, orgnization=organization)
    address_form = BillingAddressForm()
    teams = Team.objects.all()
    assignedto_list = request.POST.getlist('assigned_to')
    teams_list = request.POST.getlist('teams')
    if request.method == 'POST':
        form = ContactForm(request.POST, assigned_to=users)
        #form = ContactForm(request.POST, assigned_to=users, orgnization=organization)
        address_form = BillingAddressForm(request.POST)
        if form.is_valid() and address_form.is_valid():
            address_obj = address_form.save()
            contact_obj = form.save(commit=False)
            contact_obj.address = address_obj
            contact_obj.created_by = request.user
            contact_obj.save()
            contact_obj.assigned_to.add(*assignedto_list)
            contact_obj.teams.add(*teams_list)
            if request.is_ajax():
                return JsonResponse({'error': False})
            if request.POST.get("savenewform"):
                return HttpResponseRedirect(reverse("contacts:add_contact"))
            else:
                return HttpResponseRedirect(reverse('contacts:list'))
        else:
            if request.is_ajax():
                return JsonResponse({
                    'error': True,
                    'contact_errors': form.errors
                })
            return render(
                request,
                'contacts/create_contact.html',
                {
                    'contact_form': form,
                    'address_form': address_form,
                    #'organization': organization,
                    'countries': COUNTRIES,
                    'teams': teams,
                    'users': users,
                    'assignedto_list': assignedto_list,
                    'teams_list': teams_list
                })
    else:
        return render(
            request,
            'contacts/create_contact.html',
            {
                'contact_form': form,
                'address_form': address_form,
                #'organization': organization,
                'countries': COUNTRIES,
                'teams': teams,
                'users': users,
                'assignedto_list': assignedto_list,
                'teams_list': teams_list
            })
Ejemplo n.º 16
0
def contact_list(request):

    # Contact creation
    form = ContactForm(request.POST or None)
    if '_create' in request.POST and form.is_valid():
        contact = form.save(commit=False)
        contact.user = request.user
        contact.save()
        msg = _('Your new contact was created')
        messages.success(request, msg)
        return redirect('contact_list')

    # Contact deletion
    qs = Contact.objects.filter(user=request.user)
    if '_delete' in request.POST:
        ids = request.POST.getlist('id')
        qs.filter(id__in=ids).delete()
        msg = _('Selected reminders were deleted')
        messages.success(request, msg)
        return redirect('contact_list')

    table = ContactTable(qs)
    return {
        'table': table,
        'form': form,
    }
Ejemplo n.º 17
0
def contact_view(request):

    # user = request.user
    contact = Contact.objects.all().order_by('-created_date')
    contact_count = Contact.objects.all().count()
    paginator = Paginator(contact, 10)
    page = request.GET.get('page')
    try:
        contact_list = paginator.page(page)
    except PageNotAnInteger:
        contact_list = paginator.page(1)
    except EmptyPage:
        contact_list = paginator.page(paginator.num_pages)

    form = ContactForm(request.POST)
    if request.method == 'POST':
        if form.is_valid():
            contact = form.save(commit=False)
            contact.user = request.user
            contact.save()
            messages.success(request, "Contact enregistrées!")
            # redirect to a new URL:
            return HttpResponseRedirect(reverse('contacts:contact_view'))
        else:
            form = ContactForm()
    context = {
        'form': form,
        'contact_list': contact_list,
        'contact_count': contact_count
    }
    template_name = 'pages/contacts/contact_view.html'
    return render(request, template_name, context)
Ejemplo n.º 18
0
def contact_list(request):

    # Contact creation
    form = ContactForm(request.POST or None)
    if '_create' in request.POST and form.is_valid():
        contact = form.save(commit=False)
        contact.user = request.user
        contact.save()
        msg = _('Your new contact was created')
        messages.success(request, msg)
        return redirect('contact_list')

    # Contact deletion
    qs = Contact.objects.filter(user=request.user)
    if '_delete' in request.POST:
        ids = request.POST.getlist('id')
        qs.filter(id__in=ids).delete()
        msg = _('Selected reminders were deleted')
        messages.success(request, msg)
        return redirect('contact_list')

    table = ContactTable(qs)
    return {
        'table': table,
        'form': form,
    }
Ejemplo n.º 19
0
def ContactEdit(request, pk):
    form = ContactForm(request.POST or None,
                       instance=Contact.objects.get(pk=pk))
    if form.is_valid():
        contact = form.save()
        messages.success(request, 'success')
        return redirect('contact_edit', pk=contact.pk)
    return render(request, 'contacts/contact_form.html', {'form': form})
Ejemplo n.º 20
0
def add(request):
    if request.method == "GET":
        form = ContactForm()
        return render_to_response("contacts/New_contact.html", context_instance=RequestContext(request, {"form": form}))
    else:
        cnt = Contact()
        form = ContactForm(request.POST, request.FILES, instance=cnt)
        if form.is_valid():
            form.save()
            send_mail("new contact", "there is a new contact", settings.EMAIL_HOST_USER, ["*****@*****.**"])
            return render_to_response(
                "contacts/New_contact.html", context_instance=RequestContext(request, {"form": form, "status": "saved"})
            )
        else:
            return render_to_response(
                "contacts/New_contact.html", context_instance=RequestContext(request, {"form": form, "status": "error"})
            )
Ejemplo n.º 21
0
def kyc_view(request):
    formContact = ContactForm(request.POST)
    if request.method == 'POST':
        if formContact.is_valid():
            contact = formContact.save(commit=False)
            contact.user = request.user
            contact.save()
            # messages.success(request, "Contact enregistrées!")
            return JsonResponse({'contact': 'success'})
Ejemplo n.º 22
0
def edit(request, contact_id):
    contact = get_object_or_404(Contact, pk=contact_id)
    if request.method == 'POST':
        form = ContactForm(request.POST, request.FILES, instance=contact)
        is_valid = form.is_valid()
        if request.is_ajax():
            if is_valid:
                form.save()
                # we need new form for ImageField to be displayed correctly
                form = ContactForm(instance=contact)
            return render(request, 'contacts/edit_form.html',
                          {'form': form, 'contact': contact})
        if is_valid:
            form.save()
            return redirect(detail, contact_id=contact_id)
    else:
        form = ContactForm(instance=contact)
    return render(request, 'contacts/edit.html',
                  {'form': form, 'contact': contact})
Ejemplo n.º 23
0
def edit_contact(request, pk):
    contact_obj = get_object_or_404(Contact, id=pk)
    address_obj = get_object_or_404(Address, id=contact_obj.address.id)
    organizations = Organization.objects.all()
    users = User.objects.filter(is_active=True).order_by('email')
    # form = ContactForm(instance=contact_obj, assigned_to=users)
    form = ContactForm(instance=contact_obj, assigned_to=users, organization=organizations)
    address_form = BillingAddressForm(instance=address_obj)
    teams = Team.objects.all()
    assignedto_list = request.POST.getlist('assigned_to')
    teams_list = request.POST.getlist('teams')
    if request.method == 'POST':
        form = ContactForm(request.POST, instance=contact_obj, assigned_to=users, organization=organizations)
        #form = ContactForm(request.POST, instance=contact_obj, assigned_to=users, organization=organization)
        address_form = BillingAddressForm(request.POST, instance=address_obj)
        if form.is_valid() and address_form.is_valid():
            addres_obj = address_form.save()
            contact_obj = form.save(commit=False)
            contact_obj.address = addres_obj
            contact_obj.created_by = request.user
            contact_obj.save()
            contact_obj.assigned_to.clear()
            contact_obj.assigned_to.add(*assignedto_list)
            contact_obj.teams.clear()
            contact_obj.teams.add(*teams_list)
            if request.is_ajax():
                return JsonResponse({'error': False})
            return HttpResponseRedirect(reverse('contacts:list'))
        else:
            if request.is_ajax():
                return JsonResponse({'error': True, 'contact_errors': form.errors})
            return render(request, 'crm/contacts/create_contact.html', {
                'contact_form': form,
                'address_form': address_form,
                'contact_obj': contact_obj,
                'organizations': organizations,
                'countries': COUNTRIES,
                'teams': teams,
                'users': users,
                'assignedto_list': assignedto_list,
                'teams_list': teams_list
            })
    else:
        return render(request, 'crm/contacts/create_contact.html', {
            'contact_form': form,
            'address_form': address_form,
            'contact_obj': contact_obj,
            'address_obj': address_obj,
            'organizations': organizations,
            'countries': COUNTRIES,
            'teams': teams,
            'users': users,
            'assignedto_list': assignedto_list,
            'teams_list': teams_list
        })
Ejemplo n.º 24
0
def new(request):
    if request.method == "POST":
        form = ContactForm(request.POST)
        if form.is_valid():
            try:
                form = form.save(commit=False)
                form.created_by = request.user
                form.save()
                return redirect('/contacts')
            except:
                pass
        else:
            err = form.errors
            return render(request, 'contacts/index.html', {
                'form': form,
                'error': err
            })
    else:
        form = ContactForm()
    return render(request, 'contacts/index.html', {'form': form})
Ejemplo n.º 25
0
def contacts_add(request):
    if request.method == 'POST':
        form = ContactForm(user=request.user, data=request.POST)
        if form.is_valid():
            new_contact = form.save()
            return HttpResponseRedirect("/contacts")
    else:
        form = ContactForm(user=request.user)

    return render_to_response("contacts/new.html", {
        'form': form
    }, RequestContext(request))
Ejemplo n.º 26
0
def sendMessage(request):
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            #save to the database
            instance = form.save(commit=False)
            instance.user = request.user
            instance.save()
            return redirect('contacts:sendMessage')
    else:
        form = ContactForm()
    return render(request, 'contacts/contact.html', {'form': form})
Ejemplo n.º 27
0
def lost_person_details(request, id):
    lp_detail = get_object_or_404(Person, id=id)
    related_lost_person = Person.objects.filter(body_color__icontains='white')[1:2]
    # Contact Models ---------------------#
    form = ContactForm(request.POST or None)
    errors = None
    if form.is_valid():
        form.save()
        messages.add_message(request, messages.SUCCESS,
                             'You message successfully send, please wait you will inform you')
        return HttpResponseRedirect(request.META.get("HTTP_REFERER"))
    if form.errors:
        errors = form.errors
        messages.add_message(request, messages.ERROR, 'Please give the correct information')
    # End of contact -----------------------------------------------------------------------
    context = {
        'lp_detail': lp_detail,
        'form': form,
        'errors': errors,
        'related_lost_person': related_lost_person
    }
    return render(request, 'lost/lost-person-details.html', context)
Ejemplo n.º 28
0
def create(request):
    """
    Create Contact view - takes posts
    """
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            contact = form.save(commit=False)
            contact.user = request.user
            contact.save()
            return redirect('index')
        else:
            return redirect('index')
Ejemplo n.º 29
0
def add_contact(request):
    form = ContactForm()
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            contact = form.save(commit=False)
            contact.full_name = '{0} {1}'.format(contact.first_name,
                                                 contact.last_name)
            contact.save()
            return HttpResponseRedirect(reverse('contacts:index'))
        else:
            print(form.errors)
    context = {'form': form}
    return render(request, 'contacts/add_contact.html', context)
Ejemplo n.º 30
0
def lead_edit(request, h_pk, pk):
    lead = Lead.objects.filter(sponsorship__hackathon__pk=h_pk, contact__pk=pk)
    lead = lead[0] if lead else None
    if not lead:
        return redirect(
            reverse("contacts:edit", args=(pk, )) + "?next=" +
            reverse("hackathons:leads:view", args=(
                h_pk,
                pk,
            )))
    if request.method == "POST":
        lead_form = LeadForm(request.hackathon,
                             lead.sponsorship.company,
                             request.POST,
                             instance=lead,
                             prefix="lead")
        if lead_form.is_valid():
            lead = lead_form.save(commit=True)
            lead.save()
            ok = True
        else:
            ok = False
        contact_form = ContactForm(request.POST,
                                   instance=lead.contact,
                                   prefix="contact")
        if contact_form.is_valid():
            contact = contact_form.save(commit=True)
            contact.save()
            ok = ok and True
        else:
            ok = False
        if ok:
            messages.success(request, f"Updated {lead.contact}")
            if request.GET.get("next"):
                return redirect(request.GET.get("next"))
            return redirect("hackathons:leads:view",
                            h_pk=h_pk,
                            pk=lead.contact.pk)
    else:
        lead_form = LeadForm(request.hackathon,
                             lead.sponsorship.company,
                             instance=lead,
                             prefix="lead")
        contact_form = ContactForm(instance=lead.contact, prefix="contact")
    lead_form.fields['sponsorship'].widget = forms.HiddenInput()
    lead_form.fields['contact'].widget = forms.HiddenInput()
    return render(request, "lead_edit.html", {
        "lead_form": lead_form,
        "contact_form": contact_form
    })
Ejemplo n.º 31
0
def landing(request):
    name = 'Foo Bar'
    context = RequestContext(request)
    t = get_template('landing.html')
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            temp = form.save(commit=True)
            return render_to_response('landing.html', context)
    else:
        if request.user.is_authenticated():
            return HttpResponseRedirect('/accounts/articles')
        else:
            form = ContactForm()
    return render_to_response('landing.html', {'form': form}, context)
Ejemplo n.º 32
0
def contact(request, listing_slug):
    listing = get_object_or_404(Listing, slug=listing_slug)
    contact = Contact(user=request.user, listing=listing)
    form = ContactForm(request.POST, user=request.user, instance=contact)
    if form.is_valid():
        form.save()
        # Send email
        # send_mail(
        #   'Property Listing Inquiry',
        #   'There has been an inquiry for ' + listing + '. Sign into the admin panel for more info',
        #   '*****@*****.**',
        #   [listing.realtor.email, '*****@*****.**'],
        #   fail_silently=False
        # )
        messages.success(
            request,
            'Your request has been submitted, a realtor will get back to you soon'
        )
        return redirect('listing', listing_slug)
    else:
        return render(request, 'listings/listing.html', {
            'listing': listing,
            'form': form
        })
Ejemplo n.º 33
0
def add_or_update_contact_details(request, template_name, contact, context):
    """
    Either create a new contact or update an existing contacts details.

    request:       the request object passed to the view
    template_name: template to be rendered by this function
    contact:       instance of contact to whom the avatar will be linked - it must exist, even for
                   new contacts
    context:       "create" or "update" depending on how the "template_name" is going to be rendered
    """
    contact_form = ContactForm(request.POST or None, instance=contact)

    if contact_form.is_valid():
        contact = contact_form.save()
        return redirect('contacts:update_contact_avatar', contact_id=contact.id)

    return render(request, template_name, {
        'action': context,
        'contact_form': contact_form
    })
Ejemplo n.º 34
0
def create_contact(request):

    form = ContactForm()

    if request.method == 'POST':
        
        form = ContactForm(request.POST, request.FILES)

        if form.is_valid():
            contact = form.save(commit=False)
            contact.user = request.user
            contact.save()
            messages.success(request, 'Contact created successfully!') 

            if contact is not None:
                return redirect('/contacts')
    else:
        form = ContactForm()

    context = {'form': form, 'date': date}

    return render(request, 'contacts/create_contact.html', context)
Ejemplo n.º 35
0
def landing(request):
    name = 'Foo Bar'
    context = RequestContext(request)
    t = get_template('landing.html')
    """if request.user.is_authenticated():
        #html = t.render(Context({'name': request.user.username}))
        return HttpResponseRedirect('/accounts/articles')
    else:
        return render_to_response('landing.html')"""
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            temp = form.save(commit=True)
            print temp
            return render_to_response('landing.html', context)
        else:
            print form.errors
    else:
        if request.user.is_authenticated():
            return HttpResponseRedirect('/accounts/articles')
        else:
            form = ContactForm()
    return render_to_response('landing.html', {'form': form}, context)
Ejemplo n.º 36
0
def edit_contact(request, pk):
    
    contact = Contact.objects.get(pk=pk)

    form = ContactForm()

    if request.method == 'POST':
        form = ContactForm(request.POST, request.FILES, instance=contact)

        if form.is_valid():
            contact = form.save(commit=False)
            contact.user = request.user
            contact.save()
            messages.success(request, 'Your contact has been updated successfully!')

            if contact is not None:
                return redirect('/contacts')
    else:
        # with this we put the data that has the old contact
        form = ContactForm(instance=contact)
    
    context = {'form': form, 'date': date}

    return render(request, 'contacts/edit_contact.html', context)
Ejemplo n.º 37
0
def leads_convert(request, pk):
    account_form = AccountForm()
    billing_form = BillingAddressForm()
    shipping_form = ShippingAddressForm(prefix='ship')
    lead_objects = Lead.objects.all()
    lead_obj = Lead.objects.get(id=pk)
    accounts = Account.objects.all()
    contact_form = ContactForm()
    opportunity_form = OpportunityForm()
    teams = Team.objects.all()
    if request.method == "POST":
        if request.POST.get('accountname') == "on":
            account_form = AccountForm(request.POST)
            billing_form = BillingAddressForm(request.POST)
            shipping_form = ShippingAddressForm(request.POST, prefix='ship')
            if account_form.is_valid() and billing_form.is_valid(
            ) and shipping_form.is_valid():
                billing_object = billing_form.save()
                shipping_object = shipping_form.save()
                account_object = account_form.save(commit=False)
                account_object.billing_address = billing_object
                account_object.shipping_address = shipping_object
                account_object.created_by = request.user
                account_object.save()
                lead_obj.delete()
                return HttpResponseRedirect(reverse('leads:list'))
            else:
                street1 = request.POST.get('street')
                city1 = request.POST.get('city')
                state1 = request.POST.get('state')
                postcode1 = request.POST.get('postcode')
                country1 = request.POST.get('country')
                shipdata = {
                    'street1': street1,
                    'city1': city1,
                    'state1': state1,
                    'postcode1': postcode1,
                    'country1': country1
                }
                return render(
                    request, 'checkbox.html', {
                        'account_form': account_form,
                        'form1': billing_form,
                        'form2': shipping_form,
                        'form5': COUNTRIES,
                        'stages': STAGES,
                        'acc_error': account_form.errors,
                        'shipdata': shipdata,
                        'sources': LEAD_SOURCE,
                        'industries': INDCHOICES,
                        'teams': teams,
                        'task': lead_objects,
                        'post': lead_obj,
                        'accounts': accounts,
                        'counties': COUNTRIES
                    })

        if request.POST.get('contactname') == "on":
            contact_form = ContactForm(request.POST)
            address_form = BillingAddressForm(request.POST)
            if contact_form.is_valid() and address_form.is_valid():
                address_obj = address_form.save()
                contact_obj = contact_form.save(commit=False)
                contact_obj.address = address_obj
                contact_obj.created_by = request.user
                contact_obj.save()
                return HttpResponseRedirect(reverse('contacts:list'))
            else:
                return render(
                    request, 'checkbox.html', {
                        'post': lead_obj,
                        'accounts': accounts,
                        'teams': teams,
                        'contact_form': contact_form,
                        'address_form': address_form
                    })
        if request.POST.get('opportunityname') == "on":
            opportunity_form = OpportunityForm(request.POST)
            if opportunity_form.is_valid():
                opportunity_form.save()
                return HttpResponseRedirect(reverse('opportunities:list'))
            else:
                return render(
                    request, 'checkbox.html', {
                        'post': lead_obj,
                        'accounts': accounts,
                        'sources': LEAD_SOURCE,
                        'teams': teams,
                        'stages': STAGES,
                        'opportunity_form': opportunity_form
                    })
    else:
        return render(
            request, 'checkbox.html', {
                'form': account_form,
                'form1': billing_form,
                'form2': shipping_form,
                'form5': COUNTRIES,
                'industries': INDCHOICES,
                'teams': teams,
                'task': lead_objects,
                'counties': COUNTRIES,
                'post': lead_obj,
                'accounts': accounts
            })