Esempio n. 1
0
def patient_signup(request, a_id):
    ac = Account.objects.get(id=a_id)
    if request.method == 'POST':
        name = request.POST['name']
        phone = request.POST['phone']
        latitude = request.POST['latitude']
        longitude = request.POST['longitude']

        new_p = Patient(p_name=name,
                        p_phone=phone,
                        p_latitude=latitude,
                        p_longitude=longitude)
        new_p.save()
        ac.a_patient = new_p
        new_p.p_account = ac
        ac.save()
        new_p.save()
        return HttpResponseRedirect(
            reverse('patient:usermain', args=(new_p.id, )))

    return render(request, 'patient_signup.html', {'a': ac})
Esempio n. 2
0
from patient.models import Patient

f = open('customers.csv', 'r', encoding='utf-8')
info = []
rdr = csv.reader(f)
for row in rdr:
    name, phone, local, domain, passwd, payments, lat, lng = row
    tuple = (name, phone, local, domain, passwd, payments, lat, lng)
    info.append(tuple)
f.close()

count = 0
instancesa = []
instancesp = []
for (name, phone, local, domain, passwd, payments, lat, lng) in info:
    if name != 'name' and phone != 'phone':
        if count % 100 == 0:
            print(count)
        a = Account(a_local=local, a_domain=domain, a_password=passwd)
        p = Patient(p_name=name,
                    p_phone=phone,
                    p_latitude=lat,
                    p_longitude=lng)
        a.save()
        p.save()
        a.a_patient = p
        p.p_account = a
        a.save()
        p.save()
        count += 1