コード例 #1
0
ファイル: index.py プロジェクト: haohy/TDOA-2
	def POST(self):
		#需要接收mission_id
		if session.login == 1:
			if session.user:
				mission_id = web.input().mission_id
				#先添加任务,再把原来的任务删除
				#创建任务
				try:
					mission_duplicate = web.input().mission_duplicate
				except Exception, e:
					mission_duplicate = "off"
				#检查输入信息
				result = mission.mission_check(web.input().mission_name, \
					web.input().mission_content, web.input().mission_starttime, web.input().mission_plan_end_time)

				if result == "no error":
					#存储任务信息
					mission.mission_save(web.input().mission_name, session.user, \
						web.input().mission_content, web.input().mission_starttime, \
						web.input().mission_plan_end_time, mission_duplicate)
					mission_list = mission.mission_list(account_name=session.user, role='mission_publisher')
					#return render.my_mission(session.user, mission_list)
					ajax_result = {"statusCode":"200", "message":"任修改成功", "callbackType":"closeCurrent"}

					try:
						result_del = mission.mission_delete(mission_id)
					except Exception, e:
						print e
					finally:
						mission_list = mission.mission_list(account_name=session.user, role='mission_publisher')
コード例 #2
0
ファイル: index.py プロジェクト: haohy/TDOA
	def POST(self):
		#需要接收mission_id
		if session.login == 1:
			if session.user:
				mission_id = web.input().mission_id
				#先添加任务,再把原来的任务删除
				#创建任务
				try:
					mission_duplicate = web.input().mission_duplicate
				except Exception, e:
					mission_duplicate = "off"
				#检查输入信息
				result = mission.mission_check(web.input().mission_name, \
					web.input().mission_content, web.input().mission_starttime, web.input().mission_plan_end_time)

				if result == "no error":
					#存储任务信息
					mission.mission_save(web.input().mission_name, session.user, \
						web.input().mission_content, web.input().mission_starttime, \
						web.input().mission_plan_end_time, mission_duplicate)
					mission_list = mission.mission_list(account_name=session.user, role='mission_publisher')
					#return render.my_mission(session.user, mission_list)
					ajax_result = {"statusCode":"200", "message":"任务修改成功", "callbackType":"closeCurrent"}

					try:
						result_del = mission.mission_delete(mission_id)
					except Exception, e:
						print e
					finally:
						mission_list = mission.mission_list(account_name=session.user, role='mission_publisher')
コード例 #3
0
ファイル: index.py プロジェクト: lhang/TDOA
	def POST(self):
		#登陆控制
		if session.login == 1:
			if session.user:
				x = web.input(myfile={})
				mission_name = web.input().mission_name
				mission_content = web.input().mission_content
				mission_starttime = web.input().mission_starttime
				mission_plan_end_time = web.input().mission_plan_end_time
				mission_doers = web.input().mission_doers
				#检查任务信息是否合法
				result = mission.mission_check(mission_name, mission_content, mission_starttime, mission_plan_end_time)
				ajax_result = {"statusCode":"300", "message":result}
				web.header('Content-Type', 'application/json')
				#如果任务合法,将任务信息存储进MISSION表
				mission_pubtime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
				if result == "no error":
					mission.mission_save(mission_name, mission_content, mission_starttime, mission_plan_end_time, session.user, mission_doers,mission_pubtime)
					#获取到mission_id的值
					mission_id = mission.mission_id_get(session.user, mission_pubtime)
					file_type = 0
					user = session.user
					filedir = 'uploads/'+user # change this to the directory you want to store the file in.
					file.create_dir(filedir) #create dir if the dir is not exist
					if 'myfile' in x:
						file_url=x.myfile.filename.replace('\\','/')
						print "file_url = x.myfile.filename = :"
						print file_url
						file_name=file_url.split('/')[-1] # splits the and chooses the last part (the filename with extension)
						file_url = './uploads/'+user+'/'+file_name
						fout = open(filedir +'/'+ file_name,'wb') # creates the file where the uploaded file should be stored
						fout.write(x.myfile.file.read()) # writes the uploaded file to the newly created file.
						fout.close() # closes the file, upload complete.
						file_upload_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
						file.upload(mission_id,file_name,file_url, user,file_upload_time,file_type)
						ajax_result = {"statusCode":"200", "message":"任务新添加成功", "callbackType":"closeCurrent"}
						return json.dumps(ajax_result)
				#如果任务不合法,把已填写的表单数据返回给new_mission页面
				"""
				else:
					return render_template(
						type=session.type, 
						template_name='new_mission.html', 
						user=session.user, 
						mission_name=mission_name, 
						mission_content=mission_content, 
						mission_starttime=mission_starttime,
						mission_plan_end_time=mission_plan_end_time, 
						error=result
						)
				"""
			else:
				return json.dumps({"statusCode":"301", "message":"会话超时,请重新登录"})
		else:
			return json.dumps({"statusCode":"301", "message":"会话超时,请重新登录"})
コード例 #4
0
ファイル: index.py プロジェクト: haohy/TDOA
	def POST(self):
		#登陆控制
		if session.login == 1:
			if session.user:
				x = web.input(myfile={})
				mission_name = web.input().mission_name
				mission_content = web.input().mission_content
				mission_starttime = web.input().mission_starttime
				mission_plan_end_time = web.input().mission_plan_end_time
				mission_doers = web.input().mission_doers
				#检查任务信息是否合法
				result = mission.mission_check(mission_name, mission_content, mission_starttime, mission_plan_end_time)
				ajax_result = {"statusCode":"300", "message":result}
				web.header('Content-Type', 'application/json')
				#如果任务合法,将任务信息存储进MISSION表
				mission_pubtime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
				if result == "no error":
					mission.mission_save(mission_name, mission_content, mission_starttime, mission_plan_end_time, session.user, mission_doers,mission_pubtime)
					#获取到mission_id的值
					mission_id = mission.mission_id_get(session.user, mission_pubtime)
					file_type = 0
					user = session.user
					filedir = 'uploads/'+user # change this to the directory you want to store the FILEin.
					file.create_dir(filedir) #create dir if the dir is not exist
					if 'myfile' in x:
						file_url=x.myfile.filename.replace('\\','/')
						print "file_url = x.myfile.filename = :"
						print file_url
						file_name=file_url.split('/')[-1] # splits the and chooses the last part (the filename with extension)
						file_url = './uploads/'+user+'/'+file_name
						fout = open(filedir +'/'+ file_name,'wb') # creates the FILEwhere the uploaded FILEshould be stored
						fout.write(x.myfile.file.read()) # writes the uploaded FILEto the newly created file.
						fout.close() # closes the file, upload complete.
						file_upload_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
						file.upload(mission_id,file_name,file_url, user,file_upload_time,file_type)
						ajax_result = {"statusCode":"200", "message":"任务新添加成功", "callbackType":"closeCurrent"}
						return json.dumps(ajax_result)
				#如果任务不合法,把已填写的表单数据返回给new_mission页面
				"""
				else:
					return render_template(
						type=session.type, 
						template_name='new_mission.html', 
						user=session.user, 
						mission_name=mission_name, 
						mission_content=mission_content, 
						mission_starttime=mission_starttime,
						mission_plan_end_time=mission_plan_end_time, 
						error=result
						)
				"""
			else:
				return json.dumps({"statusCode":"301", "message":"会话超时,请重新登录"})
		else:
			return json.dumps({"statusCode":"301", "message":"会话超时,请重新登录"})
コード例 #5
0
ファイル: index.py プロジェクト: haohy/TDOA-2
	def POST(self):
		#登陆控制
		if session.login == 1:
			if session.user:
				mission_name = web.input().mission_name
				mission_content = web.input().mission_content
				mission_starttime = web.input().mission_starttime
				mission_plan_end_time = web.input().mission_plan_end_time
				try:
					mission_duplicate = web.input().mission_duplicate
				except:
					mission_duplicate = "off"

				#检查任务信息是否合法
				result = mission.mission_check(mission_name, mission_content, mission_starttime, mission_plan_end_time)
				ajax_result = {"statusCode":"300", "message":result}
				web.header('Content-Type', 'application/json')


				#如果任务合法,将任务信息存储进MISSION表
				if result == "no error":
					mission.mission_save(mission_name, session.user, mission_content, mission_starttime, mission_plan_end_time, mission_duplicate)
					mission_list = mission.mission_list(account_name=session.user, role='mission_doer')

					ajax_result = {"statusCode":"200", "message":"任务新添加成功", "callbackType":"closeCurrent"}
					return json.dumps(ajax_result)
				#如果任务不合法,把已填写的表单数据返回给new_mission页面
				"""
				else:
					return render_template(
						type=session.type, template_name='new_mission.html', 
						user=session.user, 
						mission_name=mission_name, 
						mission_content=mission_content, 
						mission_starttime=mission_starttime,
						mission_plan_end_time=mission_plan_end_time, 
						error=result
						)
				"""
			else:
				return json.dumps({"statusCode":"301", "message":"会话超时,请重新登录"})
		else:
			return json.dumps({"statusCode":"301", "message":"会话超时,请重新登录"})