Ejemplo n.º 1
0
	def post(self):

		user = users.get_current_user()
		if user:
			
			file_upload = self.request.POST.get("file", None)
			file_name = file_upload.filename
			logging.info(file_name)
			receipt = Receipt()
			receipt.store = self.request.get('store')
			receipt.usr = user
			receipt.picture = Images(filename = file_name, blob = file_upload.file.read()).put()
			receipt.put()
			t = {"image" : '/serve/%s'%receipt.picture.id()}
			self.response.write(JINJA_ENVIRONMENT.get_template('templates/submit_success.html').render(t))
		else:
			self.redirect(users.create_login_url(self.request.uri))
Ejemplo n.º 2
0
	def post(self):
		user = users.get_current_user()
		if user:
			try:
				file_upload = self.request.POST.get("file", None)
				file_name = file_upload.filename
				logging.info(file_name)
				file = insert_file(file_name,"Image file",None, mimetypes.guess_type(file_name)[0],file_upload.file.read())
				insert_permission(file.get('id'), '*****@*****.**','user','reader')
				receipt = Receipt()
				receipt.desc = self.request.get('desc')
				receipt.tags = self.request.get('tags').split()
				receipt.usr = user
				receipt.picture_dlink = file.get('id')
				receipt.put()
				self.response.write(JINJA_ENVIRONMENT.get_template('templates/submit_success.html').render({'id' : file.get('id')}))
			except Exception as e:
				self.response.write("Sorry, something went wrong. Please try again later!!")
				logging.error(e)
		else:
			self.redirect(users.create_login_url(self.request.uri))