コード例 #1
0
ファイル: main.py プロジェクト: vncnz/howmuch
	def safeGet(self, user):
		
		params = self.getAllParametersInDict()
		userData = UserData.getUserData(user)[0]
		aziendaData = None
		proj = None
		
		if params['azienda']:
			aziendaData = db.get(params['azienda']).myserialize()
			sessionSum = SessionData.getSumBetween(user, azienda=params['azienda'], start=params['start'], end=params['end'])
		elif params['progetto']:
			proj = db.get(params['progetto'])
			aziendaData = proj.azienda.myserialize()
			sessionSum = proj.eur
		else:
			self.sendError(MyException(), 'Si è verificato un errore!')
		
		msg = ('msg' in params) and params['msg'] or "Messaggio di prova"
		
		try:
			date = ('date' in params) and datetime.datetime.strptime(params['date'], "%m/%d/%Y") or datetime.datetime.now()
		except:
			date = datetime.datetime.now()
		xls = XLS_creator(userdata=userData, azienda=aziendaData, sessionSum=sessionSum, msg=msg, date=date)

		# HTTP headers to force file download
		self.response.headers['Content-Type'] = 'application/ms-excel'
		self.response.headers['Content-Transfer-Encoding'] = 'Binary'
		self.response.headers['Content-disposition'] = 'attachment; filename="Diaria_test.xls"'

		# output to user
		xls.save(self.response.out)
		if proj:
			proj.closeProj()
コード例 #2
0
ファイル: main.py プロジェクト: vncnz/howmuch
	def safeGet(self, user):
		
			print "processing page request..."
			#boxesText = ((not FORCE_FILL_DB) and reloadData()) or (fillDB() and reloadData())
			
			
			path = 'html/index.html'
			
			userstate = 0
			if user:
				if UserData.exist(user) or self.request.get('skip'):
					userstate = 2
				else:
					userstate = 1
			
			if userstate>0:
				path = 'html/index.html'
				template_values = {
					'datetime':datetime.datetime.utcnow().strftime("%d/%m/%y %X"),
					'usermail':user.email(),
					'username':user.nickname(),
					'logsession':users.create_logout_url('/')
				}
			else:
				path = 'html/welcome.html'
				template_values = {
					'init_string': "Accedi",
					'redirect_url': users.create_login_url(self.request.uri)
				}
				
			
			path = os.path.join(os.path.dirname(__file__), path)
			self.response.out.write(template.render(path, template_values))
コード例 #3
0
ファイル: main.py プロジェクト: vncnz/howmuch
	def safeGet(self, user):
		print "processing userHandler ajax request..."
		d = self.getAllParametersInDict()
		userdata,modified = UserData.getUserData(user, **d)
		print "Record modificato: "+str(modified)
		self.response.out.write(json.dumps({
				'status':0,
				'resultType': modified and 'success' or "",
				'msg': modified and 'Record modificato con successo' or "",
				'data':userdata
			}))