def test_customer_integration(self): """ This is a placeholder for a test :return: """ customer = Customer() customer.name = 'John Doe' customer.save() customers = Customer.objects.all() print customers.count()
def save(self): customers_csv = csv.reader(self.cleaned_data["file"]) Customer.objects.all().delete() for customer_csv in customers_csv: customer = Customer() customer.customer_id = customer_csv[0] customer.name = customer_csv[1] customer.adress = customer_csv[2] customer.phone_number = customer_csv[3] customer.contact = customer_csv[4] customer.save()
def assign_customer_select_customer(request, id): """ Have user decide if site exists from list and reassign all rma to selected site and delete site :param request: :param id: :return: """ site = Customer.objects.get(pk=id) site_rmas = Rma.objects.filter(customer=site) if request.method == 'GET': data = { 'name': site_rmas[0].customer.name, } customer_name_site_form = CustomerCompanyAndSiteNameForm(initial=data) return render(request, 'operations/assign_customer_select_customer.html', { 'site': site, 'form': customer_name_site_form, 'site_rmas': site_rmas }, context_instance=RequestContext(request)) if request.method == 'POST': customer_name_site_form = CustomerCompanyAndSiteNameForm(request.POST) if customer_name_site_form.is_valid(): new_site_name = customer_name_site_form.cleaned_data['name'] existing_customer_id = int( customer_name_site_form.cleaned_data['customer']) existing_customer = CustomerCompany.objects.get( pk=existing_customer_id) new_site = Customer() new_site.customer = existing_customer new_site.name = new_site_name new_site.save() for s in site_rmas: s.customer = new_site s.save() site.delete() return HttpResponseRedirect( reverse('reassign_customers_to_customer_sites')) else: return render(request, 'operations/assign_customer_select_customer.html', { 'site': site, 'form': customer_name_site_form, 'site_rmas': site_rmas }, context_instance=RequestContext(request))
def assign_customer_to_site_new_customer(request, id): if request.method == 'GET': site = Customer.objects.get(pk=id) site_rmas = Rma.objects.filter(customer=site) customer_name_form = CustomerForm() site_form = CustomerSiteIdNameForm(instance=site) return render(request, 'operations/edit_site_new_customer.html', { 'site': site, 'customer_name_form': customer_name_form, 'site_form': site_form, 'site_rmas': site_rmas }, context_instance=RequestContext(request)) if request.method == 'POST': site = Customer.objects.get(pk=id) error_count = 0 customer_name_form = CustomerForm(request.POST) site_form = CustomerSiteIdNameForm(request.POST, instance=site) site_rmas = Rma.objects.filter(customer=site) if site_form.is_valid() is not True: error_count += 1 if customer_name_form.is_valid() is not True: error_count += 1 if error_count > 0: return render(request, 'operations/edit_site_new_customer.html', { 'site': site, 'customer_name_form': customer_name_form, 'site_form': site_form, 'site_rmas': site_rmas, }, context_instance=RequestContext(request)) else: new_customer = customer_name_form.save() new_customer_site = Customer() new_customer_site.name = site_form.cleaned_data['name'] new_customer_site.customer = new_customer new_customer_site.save() return HttpResponseRedirect( reverse('view_customer_site_to_reassign', kwargs={'id': new_customer_site.id}))
def import_data(): # Initial Imports # Processing model: customers.models.Customer from customers.models import Customer customers_customer_1 = Customer() customers_customer_1.created = dateutil.parser.parse("2017-03-31T13:27:37.470821+00:00") customers_customer_1.modified = dateutil.parser.parse("2017-03-31T13:27:37.470881+00:00") customers_customer_1.name = 'Nickel Pro' customers_customer_1.email = '' customers_customer_1.phone = '' customers_customer_1.description = '' customers_customer_1.financial_year_end_day = 31 customers_customer_1.financial_year_end_month = 12 customers_customer_1.review_rounds = 2 customers_customer_1.active = True customers_customer_1 = importer.save_or_locate(customers_customer_1)
def import_add(request): from magonet.connector import MagoNet conn = MagoNet() conn.connect() rows = conn.getcustomer_byid(str(request.GET['code'])) conn.disconnect() row = rows[0] cust_list = Customer.objects.filter(origin_code=row['CustSupp']) if cust_list: newcust = cust_list[0] else: newcust = Customer() newcust.address = row['Address'] newcust.city = row['City'] newcust.email = row['EMail'] newcust.name = row['CompanyName'] newcust.origin_code = row['CustSupp'] newcust.telephone = row['Telephone1'] + " " + row['Telephone2'] + " " + row['Fax'] newcust.save() return HttpResponseRedirect(reverse("customers:detail", kwargs={"pk": newcust.id}))
def cliente(): with open('/maladireta/database/clientes.csv') as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') line_count = 0 for row in csv_reader: if line_count == 0: print(f'{", ".join(row)}') line_count += 1 elif line_count == 1: customer = Customer() customer.name = row[0] if row[1]: customer.birth = to_datetime_inverted(row[1].split(' ')[0]) customer.nickname = row[2] customer.reference = row[3] customer.state = row[4] customer.cep = row[5] customer.old_id = row[10] customer.note = row[11] customer.cpf = row[12] customer.rg = row[13] customer.phone_home = row[14] customer.phone_number = row[15] customer.cellphone = row[16] customer.complement = row[17] customer.street = row[18] customer.leadership = row[20] customer.location_reference = row[21] customer.number = row[26] customer.email = row[27] customer.profession = row[28] customer.neighborhood = row[29] customer.city = row[30] customer.recurrence = row[32] customer.subscription = row[38] customer.zone = row[39] customer.section = row[40] customer.save() else: break
def import_add(request): from magonet.connector import MagoNet conn = MagoNet() conn.connect() rows = conn.getcustomer_byid(str(request.GET['code'])) conn.disconnect() row = rows[0] cust_list = Customer.objects.filter(origin_code=row['CustSupp']) if cust_list: newcust = cust_list[0] else: newcust = Customer() newcust.address = row['Address'] newcust.city = row['City'] newcust.email = row['EMail'] newcust.name = row['CompanyName'] newcust.origin_code = row['CustSupp'] newcust.telephone = row['Telephone1'] + " " + row[ 'Telephone2'] + " " + row['Fax'] newcust.save() return HttpResponseRedirect( reverse("customers:detail", kwargs={"pk": newcust.id}))
from customers.models import Customer, WorkSite import random CUSTOMER_NAMES = [ "abc", "pippo", "pluto", "paperino", "paperone", "consulting", "dollar", "information", "fast", "good" ] CUSTOMER_NAMES_TITLE = ["Srl", "Snc", "Sas", "Spa"] for x in range(25): newcust = Customer() newcust.name = CUSTOMER_NAMES[random.randint(0, len(CUSTOMER_NAMES) - 1)].title() + ' ' + \ CUSTOMER_NAMES[random.randint(0, len(CUSTOMER_NAMES) - 1)] + ' ' + \ CUSTOMER_NAMES_TITLE[random.randint(0, len(CUSTOMER_NAMES_TITLE) - 1)] newcust.address = 'via {0}'.format(CUSTOMER_NAMES[random.randint( 0, len(CUSTOMER_NAMES) - 1)]) newcust.city = "City" newcust.email = "*****@*****.**" newcust.reference_person = CUSTOMER_NAMES[random.randint( 0, len(CUSTOMER_NAMES) - 1)] newcust.origin_code = "sample" newcust.telephone = "008881123456" newcust.save() for sx in range(3): newws = WorkSite(customer=newcust) newws.name = "Branch {0} {1}".format(str(sx), newcust.name) newws.address = "via {0}".format(CUSTOMER_NAMES[random.randint( 0, len(CUSTOMER_NAMES) - 1)])
def test_customer_slow(self): customer = Customer() customer.name = 'John Doe' customer.save() customers = Customer.objects.all() print customers.count()
def test_customer(self): customer = Customer() customer.name = 'John Doe' customer.save()
def handle(self, *args, **options): customer = Customer() customer.name = 'sample' customer.save()