def signup(request): if not request.user.is_authenticated(): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save() user.save() password = form.cleaned_data.get('password1') user = authenticate(username=user.username, password=password) firstname = form.cleaned_data.get('firstname') lastname = form.cleaned_data.get('lastname') agentid = form.cleaned_data.get('agent') street = form.cleaned_data.get('street') city = form.cleaned_data.get('city') country = form.cleaned_data.get('country') customer = Customer() customer.customer_id = user customer.agent_id = agentid customer.first_name = firstname customer.last_name = lastname customer.street = street customer.city = city customer.country = country customer.save() auth_login(request, user) return HttpResponseRedirect(reverse('catalog:index')) else: return render(request, 'del3/signup.html', {'form': form}) else: form = SignUpForm() return render(request, 'del3/signup.html', {'form': form}) else: return HttpResponseRedirect(reverse('index'))
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}))
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)]) newws.city = "City" newws.email = "*****@*****.**"