Пример #1
0
	def get(self, _id):
		submission = ICSubmission(_id=_id)
		try:
			self.finish(submission.j3m.emit())
		except:
			res = Res()
			res.reason = {
				'code' : invalidate['codes']['submission_invalid_j3m'],
				'message' : invalidate['reasons']['submission_invalid_j3m']
			}
			self.finish(res.emit())
Пример #2
0
	def get(self, _id):
		res = Res()
		
		if passesParameterFilter(_id):
			submission = ICSubmission(_id=_id)
			
			if not hasattr(submission, "invalid"):
				res.data = submission.emit()
				res.result = 200
			else:
				res.reason = submission.invalid
				
		self.finish(res.emit())
Пример #3
0
	def post(self, _id):
		res = Res()
		
		if passesParameterFilter(_id):
			submission = ICSubmission(_id=_id)
			
			if not hasattr(submission, "invalid"):
				for k,v in parseRequest(self.request.body).iteritems():
					if k not in submission.locked_fields:
						setattr(source, k, v)
				
				if submission.save():
					res.data = submission.emit()
					res.result = 200
			
		self.finish(res.emit())
Пример #4
0
	def get(self, _id, resolution):		
		submission = ICSubmission(_id=_id)
		
		if resolution == "thumb" and submission.mime_type == mime_types['video']:
			as_file_name = "%s.jpg" % submission.file_name[:-4]
		else:
			as_file_name = submission.file_name
		
		path = "%s%s/%s_%s" % (submissions_dump, _id, resolution, as_file_name)
		if resolution == "orig":
			path = "%s%s/%s" % (submissions_dump, _id, as_file_name)
		
		f = open(path, 'rb')
		if resolution != "thumb":
			self.set_header("Content-Type", submission.mime_type)
		else:
			self.set_header("Content-Type", mime_types['image'])
		self.finish(f.read())
		f.close()