示例#1
0
def create(request):
    if request.method == 'POST':
        if request.POST['username'] and request.POST[
                'password'] and request.POST['fullname'] and request.POST[
                    'email'] and request.POST['phone']:
            try:
                customers = Customer.objects.get(
                    username=request.POST['username'])
                return render(request, 'customers/create.html',
                              {'error': 'Tên đăng nhập đã tồn tại'})
            except Customer.DoesNotExist:
                customer = Customer()
                customer.address = ""
                customer.avatar = ""
                customer.email = request.POST['email']
                customer.fullname = request.POST['fullname']
                customer.gender = ""
                customer.info = ""
                customer.password = request.POST['password']
                customer.phone = request.POST['phone']
                customer.status = 1
                customer.username = request.POST['username']
                customer.save()
                follow = Follow()
                follow.cusdetail_id = customer.id
                follow.customer_id = customer.id
                follow.save()
                request.session['username'] = customer.username
            return redirect('/customers/detail/' + str(customer.id))
        else:
            return render(request, 'customers/create.html',
                          {'error': 'All fields are required.'})
    else:
        return render(request, 'customers/create.html')
示例#2
0
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)
示例#3
0
文件: views.py 项目: wolfmc3/itmemory
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}))
示例#4
0
    def post(self, request):
        form = RegisterForm(request.POST or None)
        if form.is_valid():
            formdata = form.cleaned_data.copy()
            formdata.pop('password2')
            formdata.pop('password')
            tenant = Customer()
            tenant.username = form.cleaned_data['username']
            tenant.first_name = form.cleaned_data['first_name']
            tenant.last_name = form.cleaned_data['last_name']
            tenant.email = form.cleaned_data['email']
            tenant.phone = form.cleaned_data['phone']
            tenant.timezone = form.cleaned_data['timezone']
            ph = parse(form.cleaned_data['phone'])
            region_code = region_code_for_country_code(ph.country_code)
            tenant.region_code = region_code
            tenant.save()
            print(tenant.__dict__)

            user_manager = UserManager()
            user_manager.create_user(
                customer=tenant,
                username=form.cleaned_data['username'],
                email=form.cleaned_data['email'],
                password=form.cleaned_data['password'],
                first_name=form.cleaned_data['first_name'],
                last_name=form.cleaned_data['last_name'],
                phone=form.cleaned_data['phone'],
                is_owner=True,
                is_clinician=True,
                is_scheduler=True,
                is_biller=True,
                region_code=tenant.region_code,
                timezone=tenant.timezone,
            )
            ActivityStream(customer=tenant,
                           actor=form.cleaned_data['username'],
                           verb='signed up').save()
            return redirect('login')  # to be changed later
        context = {'form': form}
        return render(request, self.template, context)
示例#5
0
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
示例#6
0
文件: views.py 项目: wolfmc3/itmemory
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}))
示例#7
0
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 = "*****@*****.**"
        newws.reference_person = CUSTOMER_NAMES[random.randint(