コード例 #1
0
ファイル: views.py プロジェクト: kedark3/clrms
def complaint(request):
    try:
        u=request.session['user']
        code = read('/home/kedark7893/clrms/templates/complaint.html')
        t= Template(code)
        c = Context({'user':u})
        return HttpResponse(t.render(c))
    except Exception as e:
        error='Please login first!'
        code = read('/home/kedark7893/clrms/templates/login.html')
        t= Template(code)
        c = Context({'error': error})
        return HttpResponse(t.render(c))
コード例 #2
0
ファイル: views.py プロジェクト: kedark3/SMSpoll
def like_category(request):
    context = RequestContext(request)

    likes = "I like it"+request.GET['category_id']
    code = read('/home/ssdiprojectfall2015/SMSpoll/templates/login.html')
    t= Template(code)
    context =Context({'likes':likes})
    return HttpResponse(likes)
コード例 #3
0
ファイル: views.py プロジェクト: kedark3/SMSpoll
def attendace_string(request):
    random_string=''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(5))
    request.session['random_string']=random_string
    #request.session['time1']= datetime.now().replace(microsecond=0)
    request.session['count']=request.GET['count']
    code = read('/home/ssdiprojectfall2015/SMSpoll/templates/AttendaceCounter.html')
    t= Template(code)
    c = Context({'string':random_string,'count':request.GET['count']})
    return HttpResponse(t.render(c))
コード例 #4
0
ファイル: views.py プロジェクト: kedark3/healthapp
def home(request):
    #g = geocoders.GoogleV3()
    #place, (lat, lng) = g.geocode('Charlotte')
    #g = geocoder.google([32.23, -80.8433], method='reverse')

    code = read('/home/sairam/Desktop/healthapp/findhospital/templates/index.html')
    t= Template(code)
    c = Context()
    return HttpResponse(t.render(c))
コード例 #5
0
ファイル: views.py プロジェクト: kedark3/SMSpoll
def create_test(request):
    conn=connect()
    cur= conn.cursor()
    cur.execute("select c_id from login_course where id=(select c_id_id from login_instcourse where crn="+request.GET['crn']+")")
    cid=cur.fetchone()[0]
    conn.close()
    code = read('/home/ssdiprojectfall2015/SMSpoll/templates/CreateTest.html')
    t= Template(code)
    c = Context({'TestName':request.GET['test_id'], 'crn': request.GET['crn'], 'cid':cid,'qid':request.GET['qid']})
    return HttpResponse(t.render(c))
コード例 #6
0
ファイル: views.py プロジェクト: kedark3/SMSpoll
def contact_us(request):
    cname=request.POST['cname']
    cmail=request.POST['cmail']
    message=request.POST['message']
    send_mail('Message from'+ cname , 'Here is message:'+ message, cmail,['*****@*****.**'], fail_silently=False)
    error="Thank you for Contacting us, we will get back to you shortly!"
    code = read('/home/ssdiprojectfall2015/SMSpoll/templates/login.html')
    t= Template(code)
    c = Context({'error': error})
    return HttpResponse(t.render(c))
コード例 #7
0
ファイル: views.py プロジェクト: kedark3/clrms
def stats(request):

    code = read('/home/kedark7893/clrms/templates/stats.html')
    t= Template(code)
    conn = connect()
    cur = conn.cursor()
    cur.execute ("select id,lab_id,computer_name_id,date,status,complaint_id from account_complaint")
    complaints = []
    for row in cur.fetchall ():
        l=Lab.objects.get(id=row[1])
        c=Computer.objects.get(id=row[2])
        complaint=CommonComplaints.objects.get(id=row[5])
        complaints.append (ComplaintList (row[0],l.name,c.computer_name,row[3],row[4],complaint.complaint))

    cur.execute ("select id,lab_id,computer_name_id,date,status,complaint_id from account_complaint where date=CURDATE()")
    daily = []
    for row in cur.fetchall ():
        l=Lab.objects.get(id=row[1])
        c=Computer.objects.get(id=row[2])
        complaint=CommonComplaints.objects.get(id=row[5])
        daily.append (ComplaintList (row[0],l.name,c.computer_name,row[3],row[4],complaint.complaint))


    cur.execute ("select id,lab_id,computer_name_id,date,status,complaint_id from account_complaint")
    hardware = []
    software=[]
    for row in cur.fetchall ():
        l=Lab.objects.get(id=row[1])
        c=Computer.objects.get(id=row[2])
        complaint=CommonComplaints.objects.get(id=row[5])
        if complaint.complaint_type_id==1:
            hardware.append (ComplaintList (row[0],l.name,c.computer_name,row[3],row[4],complaint.complaint))
        else:
            software.append (ComplaintList (row[0],l.name,c.computer_name,row[3],row[4],complaint.complaint))

    cur.execute ("select id,lab_id,computer_name_id,date,status,complaint_id from account_complaint where status='pending'")
    pending = []
    for row in cur.fetchall ():
        l=Lab.objects.get(id=row[1])
        c=Computer.objects.get(id=row[2])
        complaint=CommonComplaints.objects.get(id=row[5])
        pending.append (ComplaintList (row[0],l.name,c.computer_name,row[3],row[4],complaint.complaint))

    cur.execute("select computer_name_id from account_complaint group by computer_name_id limit 1;")
    mfc=Computer.objects.get(id=row[2])
    cur.execute("select complaint_id from account_complaint group by complaint_id order by count(*) desc limit 1;")
    mfctype=cur.fetchone()[0]
    mfctype=CommonComplaints.objects.get(id=mfctype)
    c = Context({'complaints':complaints,'daily':daily,'hardware':hardware,'software':software,'pending':pending,\
    'mfc':mfc.computer_name,'mfctype':mfctype,'range':ranges})

    conn.close()


    return HttpResponse(t.render(c))
コード例 #8
0
ファイル: views.py プロジェクト: kedark3/clrms
def signup_check(request):
    conn = connect()
    cur = conn.cursor()
    uname= request.POST['uname']
    password = request.POST['password']
    try:
        unumber=int(uname.rstrip('@mitcoe.ac.in'))
    except Exception as e:
        error='Use valid ERP number for username'
        conn.close()
        code = read('/home/kedark7893/clrms/templates/login.html')
        t= Template(code)
        c = Context({'error': error})
        return HttpResponse(t.render(c))


    if uname.find('@mitcoe.ac.in') !=-1 or uname.find('@mitcoe.edu.in') !=-1 :

        try:
            cur.execute("insert into account_account values('%s','%s')"%(uname,password))
            error = 'Signup successful'
            conn.commit ()
            conn.close()
            #code = read('/home/kedark7893/clrms/templates/welcome.html')
            #t= Template(code)
            #c = Context({'error': error})
            request.session['user'] = uname
            return HttpResponseRedirect("http://kedark7893.pythonanywhere.com/welcome")
        except msdb.IntegrityError:
            error = 'Username already exists'
            conn.close()
            code = read('/home/kedark7893/clrms/templates/login.html')
            t= Template(code)
            c = Context({'error': error})
            return HttpResponse(t.render(c))
    else:
        error='Use valid ERP number for username'
        conn.close()
        code = read('/home/kedark7893/clrms/templates/login.html')
        t= Template(code)
        c = Context({'error': error})
        return HttpResponse(t.render(c))
コード例 #9
0
ファイル: views.py プロジェクト: kedark3/SMSpoll
def show_stats(request):
    request.session['time4']= datetime.now(timezone.utc).replace(microsecond=0)
    messages = client.messages.list()
    messages.sort()
    numbers=[]
    A=[]
    B=[]
    C=[]
    D=[]
    for m in messages:
        #==================================Change or to and in statement below later====================================================================
        if len(m.body)==7:
	        if m.status == "received" and ((request.session['time4']-parser.parse(m.date_sent)).seconds)<=request.session['timer']:
	            if m.body[0:5]== request.session['random_string']:
	                if m.body[6]=='A':
	                    A.append(m.from_)
    	            if m.body[6]=='B':
	    		        B.append(m.from_)
                    if m.body[6]=='C':
			            C.append(m.from_)
                    if m.body[6]=='D':
			            D.append(m.from_)
                    if m.body[6]==request.session['ans']:
                    	numbers.append(m.from_)


    numbers=list(set(numbers))

    csv_write(numbers,str(request.GET['qid']),str(request.session['test_id']),str(request.GET['crn'])) #Writing to csv file

    count=len(A)+len(B)+len(C)+len(D)
    totalStudents= []
    totalStudents.append(A)
    totalStudents.append(B)
    totalStudents.append(C)
    totalStudents.append(D)
    totalStudents= [item for sublist in totalStudents for item in sublist]
    total= len(list(set(totalStudents)))

    percentA=0
    percentB=0
    percentC=0
    percentD=0
    if count>0:
        percentA=(len(A)*100/count)
        percentB=(len(B)*100/count)
        percentC=(len(C)*100/count)
        percentD=(len(D)*100/count)
    code = read('/home/ssdiprojectfall2015/SMSpoll/templates/Stats.html')
    t= Template(code)
    c = Context({'numbers':numbers,'countA':percentA,'countB':percentB,'countC':percentC,'countD':percentD,'count':total,
    'crn':request.GET['crn'],'qid':int(request.GET['qid'])+1,'test_id':request.session['test_id']})
    return HttpResponse(t.render(c))
コード例 #10
0
ファイル: views.py プロジェクト: kedark3/SMSpoll
def home(request):
    try:
        mail=request.session['email2']
        conn=connect()
        cur=conn.cursor()
        cur.execute("select i.crn,c.c_id,c.course_name from login_instcourse as i, login_course as c  where i.c_id_id=c.id and email_id='%s'"%mail)
        results=[]
        for row in cur.fetchall():
            results.append(CourseList(row[0],row[1],row[2]))
        conn.close()
        code = read('/home/ssdiprojectfall2015/SMSpoll/templates/InstructorHome.html')
        t= Template(code)
        #form = NameForm()
        c = Context({'courses':results})
        return HttpResponse(t.render(c))
    except Exception as e:
        error='Please login first!'
        code = read('/home/ssdiprojectfall2015/SMSpoll/templates/login.html')
        t= Template(code)
        c = Context({'error':error,'questions':questions})
        return HttpResponse(t.render(c))
コード例 #11
0
ファイル: views.py プロジェクト: kedark3/SMSpoll
def recover_pswd(request):
    pname=request.POST['pname']
    pmail=request.POST['pmail']
    l=InstReg.objects.get(email=pmail)
    if pname == (l.fname+" "+l.lname):
        send_mail('Your Password for SMS Poll' , 'Here is your password for your account on SMSpoll:'+ l.password, '*****@*****.**',[pmail], fail_silently=False)
        error="Please Check your email for Password."
    else:
        error="Please check your name or email you entered."
    code = read('/home/ssdiprojectfall2015/SMSpoll/templates/login.html')
    t= Template(code)
    c = Context({'error': error})
    return HttpResponse(t.render(c))
コード例 #12
0
ファイル: views.py プロジェクト: kedark3/clrms
def LabSelect(request):
    u=request.session['user']
    conn = connect()
    cur = conn.cursor()
    cur.execute ("select * from account_lab")
    results=[]
    for row in cur.fetchall ():
            results.append (Labs (row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],row[9],row[10],row[11],row[12],row[13],row[14]))
    code = read('/home/kedark7893/clrms/templates/LabSelect.html')
    t= Template(code)
    c = Context({'results': results,'user':u})
    conn.close()
    return HttpResponse(t.render(c))
コード例 #13
0
ファイル: views.py プロジェクト: kedark3/clrms
def overview(request):
    code = read('/home/kedark7893/clrms/templates/overview.html')
    t= Template(code)
    conn = connect()
    cur = conn.cursor()

    cur.execute ("select computer_name,dead_stock_no,ip_address,status,description,processor,ram,hdd,graphics,cost from account_computer")
    results = []
    for row in cur.fetchall ():
        if row[3]=="ON":
            results.append (Result (row[0],row[1],row[2],"Working",row[4],row[5],row[6],row[7],row[8],row[9]))
        else:
            results.append (Result (row[0],row[1],row[2],"Not Working",row[4],row[5],row[6],row[7],row[8],row[9]))

    cur.execute ("select dead_stock_no,toner_date,status,computer_id,cost,mfg_desc from account_printers")
    printers = []
    for row in cur.fetchall ():
        c=Computer.objects.get(id=row[3])
        printers.append (PrinterList (row[0],row[1],row[2],c.computer_name,row[4],row[5]))

    cur.execute ("select dead_stock_no,mfg_desc,status,computer_id,cost from account_scanners")
    scanner = []
    for row in cur.fetchall ():
        c=Computer.objects.get(id=row[3])
        scanner.append (ScannerList (row[0],row[1],row[2],c.computer_name,row[4]))

    total_cost=0
    cur.execute("select sum(cost) from account_computer")
    total_cost=total_cost+int(cur.fetchone()[0])
    cur.execute("select sum(cost) from account_printers")
    try:
        total_cost=total_cost+int(cur.fetchone()[0])
    except Exception as e:
        total_cost=total_cost+0
    cur.execute("select sum(cost) from account_scanners")
    try:
        total_cost=total_cost+int(cur.fetchone()[0])
    except Exception as e:
        total_cost=total_cost+0

    cur.execute ("select * from account_lab")
    labDetails=[]
    for row in cur.fetchall ():
        labDetails.append (Labs (row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],row[9],row[10],row[11],row[12],row[13],row[14]))
        total_cost=total_cost+row[7]+row[9]

    c = Context({'results': results,'printers':printers,'details':labDetails,'cost':total_cost,'scanners':scanner})
    conn.close()
    return HttpResponse(t.render(c))
コード例 #14
0
ファイル: views.py プロジェクト: kedark3/clrms
def welcome(request):
    global error
    try:
        u=request.session['user']
        conn = connect()
        cur = conn.cursor()

        cur.execute ("select * from account_lab")
        results=[]
        for row in cur.fetchall ():
            results.append (Labs (row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],row[9],row[10],row[11],row[12],row[13],row[14]))


        code = read('/home/kedark7893/clrms/templates/welcome.html')
        t= Template(code)
        c = Context({'user':u,'results': results})
        conn.close()
        return HttpResponse(t.render(c))
    except Exception as e:
        error='Please login first!'
        code = read('/home/kedark7893/clrms/templates/login.html')
        t= Template(code)
        c = Context({'error': error})
        return HttpResponse(t.render(c))
コード例 #15
0
ファイル: views.py プロジェクト: kedark3/SMSpoll
def login_check(request):

    mail= request.POST['email2']
    pswd = request.POST['pswd2']
    try:
        l=InstReg.objects.get(email=mail)

        if l.password==pswd:
            request.session['email2']=mail
            return HttpResponseRedirect("/auth")
    except Exception:
        code = read('/home/ssdiprojectfall2015/SMSpoll/templates/login.html')
        t= Template(code)
        error="Wrong email or password"
        c = Context({'error':error})
        return HttpResponse(t.render(c))
コード例 #16
0
ファイル: views.py プロジェクト: kedark3/clrms
def update(request):
    code = read('/home/kedark7893/clrms/templates/update.html')
    t= Template(code)
    c = Context()
    conn = connect()
    cur = conn.cursor()
    cur.execute ("select id,lab_id,computer_name_id,date,status,complaint_id from account_complaint where status='pending'")
    complaints = []
    for row in cur.fetchall ():
        l=Lab.objects.get(id=row[1])
        c=Computer.objects.get(id=row[2])
        complaint=CommonComplaints.objects.get(id=row[5])
        complaints.append (ComplaintList (row[0],l.name,c.computer_name,row[3],row[4],complaint.complaint))

    c = Context({'complaints':complaints})
    conn.close()
    return HttpResponse(t.render(c))
コード例 #17
0
ファイル: views.py プロジェクト: kedark3/SMSpoll
def show_attendance(request):
    request.session['time2']= datetime.now(timezone.utc).replace(microsecond=0)
    messages = client.messages.list()
    numbers=[]
    for m in messages:
        #==================================Change or to and in statement below later====================================================================
	    if m.status == "received" and ((request.session['time2']-parser.parse(m.date_sent)).seconds)\
	    <=request.session['count'] and m.body==request.session['random_string']:
		        numbers.append(m.from_)


    numbers=list(set(numbers)) # remove duplicates

    code = read('/home/ssdiprojectfall2015/SMSpoll/templates/Attendance.html')
    t= Template(code)
    c = Context({'numbers':numbers})
    return HttpResponse(t.render(c))
コード例 #18
0
ファイル: views.py プロジェクト: kedark3/SMSpoll
def signup(request):
    global error
    fname= request.POST['fname']
    lname= request.POST['lname']
    email= request.POST['email']
    password = request.POST['pswd']
    cnfm_pswd=request.POST['cnfm_pswd']

    if password == cnfm_pswd:
        i = InstReg(fname,lname,email,password)
        i.save()
        error="Signed up Successfully,You may login now!!"
        return HttpResponseRedirect('/auth/login')
    else:
        error="Password and Confirm password didn't match!!"
    code = read('/home/ssdiprojectfall2015/SMSpoll/templates/login.html')
    t= Template(code)
    c = Context({'error': error})
    return HttpResponse(t.render(c))
コード例 #19
0
ファイル: views.py プロジェクト: kedark3/clrms
def login_check(request):
    global error
    conn = connect()
    cur = conn.cursor()
    uname= request.POST['uname']
    password = request.POST['password']

    cur.execute("select password from account_account where username = '******'"%uname)
    for row in cur.fetchall():
        if row[0] == password:
            request.session['user'] = uname
            conn.close()
            return HttpResponseRedirect('http://kedark7893.pythonanywhere.com/welcome')

    error = 'Wrong Password'
    conn.close()
    code = read('/home/kedark7893/clrms/templates/login.html')
    t= Template(code)
    c = Context({'error': error})
    return HttpResponse(t.render(c))
コード例 #20
0
ファイル: views.py プロジェクト: kedark3/healthapp
def hospital(request):
    g = geocoders.GoogleV3()
    place, (lat, lng) = g.geocode('Charlotte')
    g = geocoder.google([request.GET['latitude'], request.GET['longitude']], method='reverse')
    zcdb = ZipCodeDatabase()


    conn=connect()
    cur=conn.cursor()
    zip_list = zcdb.get_zipcodes_around_radius(g.postal, 35)    
    results=[]
    
    for z in zip_list:
#    	print z.zip

    	cur.execute("select f1.provider_id,f1.hospital_name,f2.score from (select * from findhospital_hospitalgeneralinformation where hospital_type='"+ request.GET['type']+" ' and zip_code = '"+ z.zip +"') as f1, findhospital_hospitalperformance f2  where f1.provider_id=f2.provider_id");

	for row in cur.fetchall():
		results.append(hospitals(row[0],row[1],row[2]))
		
    conn.close()


    for i in range( 1, len( results ) ):
    	obj = results[i]
    	tmp = results[i].score
    	print results[i].score
	k = i
	while k > 0 and tmp > results[k - 1].score:
        	results[k] = results[k - 1]
        	k -= 1
	results[k]=obj
    #for z in zip_list:
    #	print z.zip
       																																																							
    

    code = read('/home/sairam/Desktop/healthapp/findhospital/templates/results.html')
    t= Template(code)
    c = Context({'results':results})
    return HttpResponse(t.render(c))
コード例 #21
0
ファイル: views.py プロジェクト: kedark3/SMSpoll
def after_course(request):
    conn=connect()
    cur=conn.cursor()
    crn=request.GET['crn']
    cid=request.GET['c-id']

    course_details=list(Course.objects.filter(c_id=cid))
    cur.execute("select s_id, phone_no from login_studreg as s, login_instcourse as c where s.crn_id=c.crn and crn="+crn)
    students=[]
    for row in cur.fetchall():
        students.append(StudList(row[0],row[1]))
    tests=[]
    cur.execute("select distinct crn_id,test_id from login_classtest where crn_id="+ crn)
    for row in cur.fetchall():
        tests.append(TestNameList(row[0],row[1]))
    conn.close()

    code = read('/home/ssdiprojectfall2015/SMSpoll/templates/AfterCourseSelection.html')
    t= Template(code)
    c = Context({'course':course_details,'students':students,'count':len(students), 'crn':crn, 'tests':tests})
    return HttpResponse(t.render(c))
コード例 #22
0
ファイル: views.py プロジェクト: kedark3/clrms
def ComplaintForm(request):
    u=request.session['user']
    lab=request.POST['selection']
    request.session['lab'] = lab
    conn = connect()
    cur = conn.cursor()
    cur.execute ("select id from account_lab where name='%s'"%lab)
    for row in cur.fetchall ():
            lab=int(row[0])
    cur.execute ("select computer_name from account_computer where lab_id=%d"%lab)
    results=[]
    for row in cur.fetchall ():
            results.append (CompList (row[0]))
    cur.execute ("select name from account_complainttype")
    complaint_types=[]
    for row in cur.fetchall ():
            complaint_types.append (ComplaintTypes (row[0]))

    conn.close()
    code = read('/home/kedark7893/clrms/templates/ComplaintForm.html')
    t= Template(code)
    c = Context({'result':results,'user':u,'complaint_types':complaint_types})
    return HttpResponse(t.render(c))
コード例 #23
0
ファイル: views.py プロジェクト: kedark3/clrms
def complaint_final(request):
    u=request.session['user']
    type_of_complaint=request.POST['type_of_complaint']
    computer=request.POST['selection']
    request.session['computer']=computer
    request.session['type_of_complaint']=type_of_complaint

    if type_of_complaint == "Hardware" or type_of_complaint=="Software":
        var = "software"
    else:
        var = "other"

    conn = connect()
    cur = conn.cursor()
    cur.execute ("select * from account_commoncomplaints where complaint_type_id=(select id from account_complainttype where name='%s')"%type_of_complaint)
    complaint_types=[]
    for row in cur.fetchall ():
       complaint_types.append (ComplaintTypes (row[2]))

    conn.close()
    code = read('/home/kedark7893/clrms/templates/ComplaintFinal.html')
    t= Template(code)
    c = Context({'user':u,'complaint_types':complaint_types, 'var':var})
    return HttpResponse(t.render(c))
コード例 #24
0
ファイル: views.py プロジェクト: kedark3/SMSpoll
def conduct_test(request):
    request.session['time3']= datetime.now(timezone.utc).replace(microsecond=0)
    code = read('/home/ssdiprojectfall2015/SMSpoll/templates/Test.html')

    try:
        request.sesssion['random_string']
    except Exception:
        random_string=''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(5))
        request.session['random_string']=random_string
    qid=str(int(request.GET['qid']))
    conn=connect()
    cur=conn.cursor()


    try:
        cur.execute("SELECT * FROM login_classtest WHERE qid='"+qid+"' AND test_id='"+request.GET['test_id']+"' AND crn_id='"+request.GET['crn']+"'")
        question_data=cur.fetchone()

        request.session['test_id']=request.GET['test_id']
        request.session['timer']=question_data[10]
        request.session['ans']=question_data[9]
        conn.close()
        t= Template(code)
        c = Context({'question':question_data[4],'A':question_data[5],'B':question_data[6],
        'C':question_data[7],'D':question_data[8],
        'timer':question_data[10], 'qid':qid, 'crn':request.GET['crn'],
        'random':request.session['random_string']})


        return HttpResponse(t.render(c))
    except Exception:

        cur.execute("select c_id from login_course where id=(select c_id_id from login_instcourse where crn="+request.GET['crn']+")")
        cid=cur.fetchone()[0]
        conn.close()
        return HttpResponseRedirect("/auth/after-course/?crn="+request.GET['crn']+"&c-id="+str(cid))
コード例 #25
0
ファイル: views.py プロジェクト: kedark3/SMSpoll
def addrem(request):
    courses=Course.objects.all()
    code = read('/home/ssdiprojectfall2015/SMSpoll/templates/AddRemove.html')
    t= Template(code)
    c = Context({'courses':courses,'email':request.session['email2']})
    return HttpResponse(t.render(c))
コード例 #26
0
ファイル: views.py プロジェクト: kedark3/clrms
def love(request):
    code = read('/home/kedark7893/clrms/templates/love.html')
    t= Template(code)
    c = Context()
    return HttpResponse(t.render(c))
コード例 #27
0
ファイル: views.py プロジェクト: kedark3/clrms
def Dlab(request):
    lab=request.GET['name']
    code = read('/home/kedark7893/clrms/templates/dlab.html')
    t= Template(code)
    conn = connect()
    cur = conn.cursor()

    #if lab_choice==1:
    try:
        cur.execute ("select computer_name,dead_stock_no,ip_address,status,description,processor,ram,hdd,graphics,cost from account_computer where lab_id=(select id from account_lab where name='%s')"%lab)
        results = []
        for row in cur.fetchall ():
            if row[3]=="ON":
                results.append (Result (row[0],row[1],row[2],"Working",row[4],row[5],row[6],row[7],row[8],row[9]))
            else:
                results.append (Result (row[0],row[1],row[2],"Not Working",row[4],row[5],row[6],row[7],row[8],row[9]))
        cur.execute ("select dead_stock_no,toner_date,status,computer_id,cost,mfg_desc from account_printers where lab_id=(select id from account_lab where name='%s')"%lab)
        printers = []
        for row in cur.fetchall ():
            c=Computer.objects.get(id=row[3])
            printers.append (PrinterList (row[0],row[1],row[2],c.computer_name,row[4],row[5]))

        cur.execute ("select dead_stock_no,mfg_desc,status,computer_id,cost from account_scanners where lab_id=(select id from account_lab where name='%s')"%lab)
        scanner = []
        for row in cur.fetchall ():
            c=Computer.objects.get(id=row[3])
            scanner.append (ScannerList (row[0],row[1],row[2],c.computer_name,row[4]))

        total_cost=0
        cur.execute("select sum(cost) from account_computer where lab_id=(select id from account_lab where name='%s') and cost_flag=1"%lab)
        try:
            total_cost=total_cost+int(cur.fetchone()[0])
        except Exception as e:
            total_cost=total_cost+0
        cur.execute("select sum(cost) from account_printers where lab_id=(select id from account_lab where name='%s' and cost_flag=1)"%lab)
        try:
            total_cost=total_cost+int(cur.fetchone()[0])
        except Exception as e:
            total_cost=total_cost+0
        cur.execute("select sum(cost) from account_scanners where lab_id=(select id from account_lab where name='%s' and cost_flag=1)"%lab)
        try:
            total_cost=total_cost+int(cur.fetchone()[0])
        except Exception as e:
            total_cost=total_cost+0
        cur.execute ("select * from account_lab where name='%s'"%lab)
        labDetails=[]
        for row in cur.fetchall ():
            labDetails.append (Labs (row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],row[9],row[10],row[11],row[12],row[13],row[14]))
            total_cost=total_cost+row[7]+row[9]

        lab_cost_update=Lab.objects.get(name=lab)
        lab_cost_update.cost=total_cost
        lab_cost_update.save()
        c = Context({'results': results,'printers':printers,'name':lab,'details':labDetails,'cost':total_cost,'scanners':scanner})
        conn.close()
        return HttpResponse(t.render(c))
    except Exception as e:
        code = read('/home/kedark7893/clrms/templates/404.html')
        t= Template(code)
        c = Context({})
        return HttpResponse(t.render(c))
コード例 #28
0
ファイル: views.py プロジェクト: kedark3/SMSpoll
def login(request):
    global error
    code = read('/home/ssdiprojectfall2015/SMSpoll/templates/login.html')
    t= Template(code)
    c = Context()
    return HttpResponse(t.render(c))
コード例 #29
0
ファイル: views.py プロジェクト: kedark3/clrms
def home(request):
    code = read('/home/kedark7893/clrms/templates/login.html')
    t= Template(code)
    c = Context()
    request.session.clear()
    return HttpResponse(t.render(c))
コード例 #30
0
ファイル: main.py プロジェクト: surru/Sudoku-Solver
import sys

f1=sys.argv[1]
f2=sys.argv[2]

import file_read,file_write,create_clause

N=9

fo=open(f1,"r")

lines=fo.readlines()

for i in range(len(lines)):

	mat=file_read.read(lines[i],N)

	clause=create_clause.clause(mat,N)

	file_write.write("ozw.txt",clause,N)

	l='minisat ozw.txt pzw.txt'

	os.system(l)

	# print mat
	mat=file_read.read_SAT("pzw.txt",mat,N)

	file_write.write_output(f2,mat,N,i)

l='rm pzw.txt'