Esempio n. 1
0
 def two_users(self):
     TESTAPI_resetFixture()
     r = add('name1','pass1')
     self.assertTrue(r==1)
     r = add('name2','pass2')
     self.assertTrue(r==1)
     r = login('name1', 'pass1')
     self.assertTrue(r==2)
     r = login('name1', 'pass1')
     self.assertTrue(r==3)
     r = login('name2', 'pass2')
     self.assertTrue(r==2)
Esempio n. 2
0
def login_passwd(request):
    u = user().get_user_by_id(request.session['userid'])
    if request.POST:
        origin = request.POST['origin']
        new = request.POST['new']
        repeat = request.POST['repeat']
        if new != repeat:
            rtu = {
                'status': False,
                'message': "两次输入的密码不相同!"
            }
            return HttpResponse(simplejson.dumps(rtu))
        result, mess = login().passwd_alter(u.id, new, origin)
        if result == 0:
            rtu = {
                'status': False,
                'message': mess
            }
            return HttpResponse(simplejson.dumps(rtu))
        else:
            rtu = {
                'status': True,
                'message': 'success'
            }
            return HttpResponse(simplejson.dumps(rtu))

    return render_mako_context(request, 'root/passwd.html', {'users': u})
Esempio n. 3
0
def user_login(request):
    request.encoding = 'utf-8'
    if request.POST:
        username = request.POST['username']
        password = request.POST['password']
        rtu, message = login().verification(username, password)
        if rtu > 0:
            type = user().get_type_by_id(rtu)
            request.session['userid'] = user().get_user_by_id(rtu).id
            if type == 1:  # 系统管理员
                return HttpResponseRedirect('/root/')
            elif type == 2:  # 高级运维人员
                return HttpResponseRedirect('/employee/')
            elif type == 3:  # 一般运维人员
                return HttpResponseRedirect('/sysadm/')
            else:
                return HttpResponse("Error")
        else:
            render = {
                'message': '用户名或密码错误!'
            }
            return render_mako_context(request, 'login.html', render)
    else:
        render = {
            'message': ''
        }
        return render_mako_context(request, 'login.html', render)
Esempio n. 4
0
def createUser(name,password,dob,location,gender,email,contactNo,flags,fbUserName):
	try:
		user = users(userId = uuid.uuid4(), name = name, password = password, location = location, dob = dob, gender = gender, email = email, contactNo = contactNo, flags = flags,fbUserName = fbUserName)
		loginUser = login(email=email, contactNo = contactNo, password = password)
		user.save()
		loginUser.save()		
	except ValidationError, e:
		print "Exception "+str(e)
		RESPONSE_CODE = "RESPONSE_CODE_VALIDATION_ERROR"
Esempio n. 5
0
def main(request):
	if request.user.is_authenticated():
		try:
			Login = login.objects.get(user=request.user)
		except:
			Login = login(user=request.user,money=100000)
			Login.save()
		request.session['login_id'] = Login.id
		
	temp = settings.STATIC_URL
	return render_to_response('home.html', {'temp':temp} , context_instance=RequestContext(request))
Esempio n. 6
0
def login(request):
    d = json.loads(request.body)
    user = d['user']
    password = d['password']
    r = models.login(user,password)
    s = ''
    if r > 0:
        s = json.dumps({'errCode' : 1,'count' : r})
    else:
        s = json.dumps({'errCode' : r})
    return HttpResponse(s,content_type=m)
Esempio n. 7
0
def createUser(name, password, dob, location, gender, email, contactNo, flags):
    try:
        user = users(userId=uuid.uuid4(),
                     name=name,
                     password=password,
                     location=location,
                     dob=dob,
                     gender=gender,
                     email=email,
                     contactNo=contactNo,
                     flags=flags)
        loginUser = login(email=email, contactNo=contactNo, password=password)
        user.save()
        loginUser.save()
    except ValidationError, e:
        print "Exception " + str(e)
        RESPONSE_CODE = "RESPONSE_CODE_VALIDATION_ERROR"
Esempio n. 8
0
def login_passwd(request):
    u = user().get_user_by_id(request.session['userid'])
    if request.POST:
        origin = request.POST['origin']
        new = request.POST['new']
        repeat = request.POST['repeat']
        if new != repeat:
            rtu = {'status': False, 'message': "两次输入的密码不相同!"}
            return HttpResponse(simplejson.dumps(rtu))
        result, mess = login().passwd_alter(u.id, new, origin)
        if result == 0:
            rtu = {'status': False, 'message': mess}
            return HttpResponse(simplejson.dumps(rtu))
        else:
            rtu = {'status': True, 'message': 'success'}
            return HttpResponse(simplejson.dumps(rtu))

    return render_mako_context(request, 'root/passwd.html', {'users': u})
Esempio n. 9
0
def user_login(request):
    request.encoding = 'utf-8'
    if request.POST:
        username = request.POST['username']
        password = request.POST['password']
        rtu, message = login().verification(username, password)
        if rtu > 0:
            type = user().get_type_by_id(rtu)
            request.session['userid'] = user().get_user_by_id(rtu).id
            if type == 1:  # 系统管理员
                return HttpResponseRedirect('/root/')
            elif type == 2:  # 高级运维人员
                return HttpResponseRedirect('/employee/')
            elif type == 3:  # 一般运维人员
                return HttpResponseRedirect('/sysadm/')
            else:
                return HttpResponse("Error")
        else:
            render = {'message': '用户名或密码错误!'}
            return render_mako_context(request, 'login.html', render)
    else:
        render = {'message': ''}
        return render_mako_context(request, 'login.html', render)
Esempio n. 10
0
 def wrong_user(self):
     TESTAPI_resetFixture()
     r = add('name','pass')
     self.assertTrue(r==1)
     r = login('wrong','pass')
     self.assertTrue(r==-1)
Esempio n. 11
0
 def simple_login(self):
     TESTAPI_resetFixture()
     r = add('name','pass')
     self.assertTrue(r==1)
     r = login('name','pass')
     self.assertTrue(r==2)
Esempio n. 12
0
def createDoctor(request):
    try:
        doc_name = request.GET.get('Name1')
        doc_mob_no = request.GET.get('mob_no')
        doc_age = request.GET.get('age')
        doc_email = request.GET.get('email')
        doc_address = request.GET.get('address')
        doc_sex = request.GET.get('sex')
        doc_lic_no = request.GET.get('')
        hos_id = request.GET.get('')
        doc_design = request.GET.get('design')
        doc_dep = request.GET.get('department')
        doc_exp = request.GET.get('year_exp')
        sex = 'No value set'
        if (doc_sex == '1'):
            sex = 'Male'
        elif (doc_sex == '0'):
            sex = 'Female'
        try:
            user_exists = False
            posts = login.objects.all()
            for post in posts:
                if (doc_mob_no == post.loginId):
                    print("mobile already exist")
                    user_exists = True
            if (not user_exists):
                doc = Doctor()
                doc.doc_name = doc_name
                doc.doc_id = '1234'
                doc.hos_id = 'pune4321'
                doc.doc_email = doc_email
                doc.doc_mob_no = doc_mob_no
                doc.doc_address = doc_address
                doc.doc_age = doc_age
                doc.doc_sex = doc_sex
                doc.doc_dep = doc_dep
                doc.doc_exp = doc_exp
                doc.save()

                alphabet = string.ascii_letters + string.digits
                password = ''.join(
                    secrets.choice(alphabet)
                    for i in range(10))  # for a 20-character password

                print(password)
                '''
                        send_mail('Subject here', 'Here is the message.', settings.EMAIL_HOST_USER,
                        [''+emailID], fail_silently=False)
                        '''

                try:
                    subject = 'Thank you for registering to our site'
                    message = ' The private key is ' + password
                    email_from = settings.EMAIL_HOST_USER
                    recipient_list = [
                        '' + doc_email,
                    ]
                    send_mail(subject, message, email_from, recipient_list)
                except Exception as e:
                    print(e)
                enc_uname1 = hashlib.sha256(
                    doc_mob_no.encode("utf-8")).hexdigest()
                enc_passs1 = hashlib.sha256(
                    password.encode("utf-8")).hexdigest()

                log = login()
                log.loginId = enc_uname1
                log.passWord = enc_passs1
                log.userType = 'doctor'
                log.save()
                '''
                        posts = patient1.objects.all()
                        for post in posts:
                            print(post.pat_name)
                        '''
                return render(request, 'administration/index.html')
        except Exception as e:
            print(e)
    except Exception as e:
        print(e)
    return HttpResponse("done with the file")
Esempio n. 13
0
def createReceptionist(request):
    try:
        rec_name = request.GET.get('Name1')
        rec_mob_no = request.GET.get('mob_no')
        rec_age = request.GET.get('age')
        rec_email = request.GET.get('email')
        rec_address = request.GET.get('address')
        rec_exp = request.GET.get('year_exp')
        rec_id = request.GET.get('rec_id')
        sex = 'No value set'
        '''if(rec_sex == '1'):
            sex = 'Male'
        elif(rec_sex == '0'):
            sex = 'Female' '''

        try:
            user_exists = False
            posts = login.objects.all()
            for post in posts:
                if (rec_mob_no == post.loginId):
                    print("mobile already exist")
                    user_exists = True
            if (not user_exists):
                recp = Receptionist()
                recp.rec_name = rec_name
                recp.rec_mob_no = rec_mob_no
                recp.rec_age = rec_age
                recp.rec_email = rec_email
                recp.rec_address = rec_address
                '''recp.rec_sex = rec_sex'''

                alphabet = string.ascii_letters + string.digits
                password = ''.join(
                    secrets.choice(alphabet)
                    for i in range(10))  # for a 20-character password

                print(password)
                '''
                        send_mail('Subject here', 'Here is the message.', settings.EMAIL_HOST_USER,
                        [''+emailID], fail_silently=False)
                        '''

                try:
                    subject = 'Thank you for registering to our site'
                    message = ' The private key is ' + password
                    email_from = settings.EMAIL_HOST_USER
                    recipient_list = [
                        '' + rec_email,
                    ]
                    send_mail(subject, message, email_from, recipient_list)
                except Exception as e:
                    print(e)

                enc_uname2 = hashlib.sha256(
                    rec_mob_no.encode("utf-8")).hexdigest()
                enc_passs2 = hashlib.sha256(
                    password.encode("utf-8")).hexdigest()

                log = login()
                log.loginId = enc_uname2
                log.passWord = enc_passs2
                log.userType = 'reception'
                log.save()
                '''
                        posts = patient1.objects.all()
                        for post in posts:
                            print(post.pat_name)
                        '''
                return render(request, 'administration/forms_basic_recep.html')
        except Exception as e:
            print(e)
    except Exception as e:
        print(e)
    return HttpResponse("" + rec_name + "\n" + rec_mob_no + "\n" + rec_age +
                        "\n" + rec_email + "\n" + rec_address + "\n" +
                        '''rec_sex +'''
                        "\n" + rec_id)
Esempio n. 14
0
def createPatient(request):
    try:
        firstName = request.GET.get('firstName')
        lastName = request.GET.get('lastName')
        mobile = request.GET.get('mobile')
        caseNumber = request.GET.get('caseNumber')
        doctorID = request.GET.get('doctorID')
        age = request.GET.get('age')
        emailID = request.GET.get('emailID')
        weight = request.GET.get('weight')
        bodyMassIndex = request.GET.get('bodyMassIndex')
        dateOfBirth = request.GET.get('dateOfBirth')
        address = request.GET.get('address')
        getsex = request.GET.get('sex')
        sex = 'No value set'
        if (getsex == '1'):
            sex = 'Male'
        elif (getsex == '0'):
            sex = 'Female'
        try:
            user_exists = False
            posts = login.objects.all()
            for post in posts:
                if (mobile == post.loginId):
                    print("mobile already exist")
                    user_exists = True
            if (not user_exists):
                pat = patient()
                pat.pat_name = firstName + " " + lastName
                pat.pat_id = '1234'
                pat.hos_id = 'pune4321'
                pat.pat_email_id = emailID
                pat.pat_mon_no = mobile
                pat.pat_address = address
                pat.pat_age = age
                pat.save()

                alphabet = string.ascii_letters + string.digits
                password = ''.join(
                    secrets.choice(alphabet)
                    for i in range(10))  # for a 20-character password

                print(password)
                '''
                        send_mail('Subject here', 'Here is the message.', settings.EMAIL_HOST_USER,
                        [''+emailID], fail_silently=False)
                        '''

                try:
                    subject = 'Thank you for registering to our site'
                    message = ' The private key is ' + password
                    email_from = settings.EMAIL_HOST_USER
                    recipient_list = [
                        '' + emailID,
                    ]
                    send_mail(subject, message, email_from, recipient_list)
                except Exception as e:
                    print(e)
                enc_uname = hashlib.sha256(mobile.encode("utf-8")).hexdigest()
                enc_passs = hashlib.sha256(
                    password.encode("utf-8")).hexdigest()

                log = login()
                log.loginId = enc_uname
                log.passWord = enc_passs
                log.userType = 'patient1'
                log.save()
                '''
                        posts = patient1.objects.all()
                        for post in posts:
                            print(post.pat_name)
                        '''
                return render(request, 'reception/reception.html')
        except Exception as e:
            print(e)
    except Exception as e:
        print(e)
    return HttpResponse("" + firstName + "\n" + lastName + "\n" + mobile +
                        "\n" + caseNumber + "\n" + doctorID + "\n" + age +
                        "\n" + emailID + "\n" + weight + "\n" + bodyMassIndex +
                        "\n" + dateOfBirth + " " + address + " " + " " + sex)