예제 #1
0
def mengmei(request):
	uname = request.session.get('username',None)
	pagenow = str(datetime.datetime.now()).split('.')[0]
	text = userlog.objects.order_by('-realtime')[:10]
	rname = usertable.objects.get(username=uname).realname
	if request.method == 'GET':
        	work = request.GET.get('work','')
		if work != '':
			u1 = userlog(username=uname,logtime=str(datetime.datetime.now()).split()[0],logcontain=work,realname=rname,realtime=int(time.mktime(datetime.datetime.now().timetuple())))
			u1.save()
	return render_to_response('mengmei.html',{'username':rname,'time':pagenow,'uwork':text})
예제 #2
0
def main_page(request):
	if request.method == 'GET':
		usernames = request.GET.get('username','')
                work = request.GET.get('work','')
		
                if work != '':
			uname = request.session.get('username',None)
#			lastwork = userlog.objects.filter(username=uname).order_by('-realtime')[:1]
			for lastwork in userlog.objects.filter(username=uname).order_by('-realtime')[:1]:
				lastwork = lastwork.logcontain
        		rname = usertable.objects.get(username=uname).realname
			print work 
			print 'sdf'
			print lastwork
			print 'tyu'
			if work != lastwork:
				pagenow = str(datetime.datetime.now()).split('.')[0]
        			text = userlog.objects.order_by('-realtime')[:10]
                        	u1 = userlog(username=uname,logtime=str(datetime.datetime.now()).split()[0],logcontain=work,realname=rname,realtime=int(time.mktime(datetime.datetime.now().timetuple())))
                        	u1.save()
				lastwork = work
				return render_to_response('main.html',{'rname':rname})
			else:
				return render_to_response('main.html',{'rname':rname})
		elif usernames == '':
			usernames = request.session.get('username',None)
			text = userlog.objects.order_by('-realtime')[:15]
			rname = usertable.objects.get(username=usernames).realname
			usernames = ''
			return render_to_response('main.html',{'rname':rname})
		password = request.GET.get('password','')
		passwd = usertable.objects.get(username=usernames).password
#		if username == 'liwei' and password == '123456':
		if password == passwd:
			request.session['username'] = usernames
			text = userlog.objects.order_by('-realtime')[:15]
			rname = usertable.objects.get(username=usernames).realname
			#t = get_template('cmd.html')
			#html = t.render()
#		return 	HttpResponseRedirect('/cmd')	
			return render_to_response('main.html',{'rname':rname})