コード例 #1
0
	def get(self):

		template_values = {
			#'pilots_online': self.get_pilots()
		}
		query = db.GqlQuery("SELECT * FROM  Aero where aero = :1", self.request.get("aero")) 
		#results = query.fetch(10)
		#c =  query.count()
		foo  ={}
		#print results
		aero = query.get()
		#for res in results:
		#	foo[res.aero] = "foo"
		if not aero:
			x =  "create"
			aero = Aero()
			aero.aero = self.request.get("aero")
		else:
			#x = "edit"
			pass
		aero.author = self.request.get("author")
		aero.description = self.request.get("description")
		aero.status = self.request.get("status")
		aero.fdm = self.request.get("flight-model")
		aero.splash = self.request.get("splash")
		aero.version = self.request.get("version")
		aero.put()

		#print 'Content-Type: text/plain'
		#print ''
		#print json.dumps(self.get_pilots())
		#path = os.path.join(os.path.dirname(__file__), 'templates/pilots_online.html')
		self.response.out.write(json.dumps(foo))
コード例 #2
0
	def get(self, selected_aircraft=None):
		
		template_values = {
			'conf': conf
		}

		if selected_aircraft:
			query = db.GqlQuery("SELECT * FROM  Aero where aero = :1", selected_aircraft) 
			aero = query.get()
			#print "aero=", aero
			if aero:
				airdb = Aircraft()
				template_values['title'] = aero.description
				template_values['aero'] = aero
				template_values['content_template'] = 'aero_include.html'
				template_values['path'] =  '/aircraft/'
				client = app.Issues.GoogleIssuesClient()
				issues = client.aero(aero.aero)
				#print issues
				template_values['issues']  = issues
				query = db.GqlQuery("SELECT * FROM  AeroFile where directory = :1", aero.directory) 
				aero_files = query.fetch(20)
				template_values['aero_files'] = aero_files

				template_values['videos'] = get_videos(selected_aircraft)
				#print template_values
			else:
				self.redirect("/aircraft/?search=%s" % selected_aircraft)

		else:
			""" Show all aircraft or searched"""
			search_text = ""
			airdb = Aircraft()
			if self.request.get("search"):
				search_text = self.request.get("search").lower()
				aircraft = []
				if search_text:
					query = Aero.all()
					dbair = query.fetch(1000)
			
					for aero in dbair:
						#print aero.aero, search_text,  aero.aero.find(search_text)
						if aero.description.lower().find(search_text)  > -1:
							#print "match", search_str
							aircraft.append(aero)
			else:
				aircraft = airdb.get_all()
			
			
			template_values['title'] = 'Aircraft'
			template_values['aircraft'] = aircraft 
			template_values['search_text'] = search_text
			template_values['content_template'] = 'aircraft_include.html'
			template_values['path'] =  '/aircraft/'
		
		path = os.path.join(os.path.dirname(__file__), 'templates/aircraft.html')
		self.response.out.write(template.render(path, template_values))
コード例 #3
0
	def get_all(self):

		data = memcache.get("aircraft_all")
		if data is not None:
			return data

		query = Aero.all()
		query.order("description")
		aircraft = query.fetch(20)

		aircraft_list = {}
		for aero in aircraft:
			aircraft_list[aero.aero] = aero.description
		if not memcache.set("aircraft_list", data, 5):
			print "error=aircraft_list"
		
		if not memcache.set("aircraft_all", data, 5):
			print "error=aircraft_all"

		return aircraft
コード例 #4
0
	def get(self, selected_aircraft=None):
		
		template_values = {
			'conf': conf
		}
		search_text = self.request.get("query")
		aircraft_list = []
		if search_text:
			query = Aero.all()
			aircraft = query.fetch(1000)
			
			for aero in aircraft:
				#print aero.aero, search_text,  aero.aero.find(search_text)
				if aero.aero.find(search_text)  > -1:
					#print "match", search_str
					aircraft_list.append({'aero': aero.aero, 'description': aero.description})

		payload = {'success': True, 'aircraft': aircraft_list, 'count': len(aircraft_list)}
		self.response.headers['Content-Type'] = 'text/plain'
		self.response.out.write(json.dumps(payload))
コード例 #5
0
	def get(self, section):
		fgApp = app.fetch.FGApp()
		template_values = {
			'path': '/idea/%s/' % section,
			'conf': conf,
			'app': fgApp
		}

		#if section == 'gallery':
		#	template_values['gallery'] = app.fetch.gallery_thumbs()

		#if section == "multiplayer":
		#		template_values['servers'] = app.fetch.mpservers()

		if section == "download":
				sql = "SELECT * FROM DownloadServer ORDER BY location"
				query = db.GqlQuery(sql)
				template_values['download_servers'] = query.fetch(100)
				template_values['title'] = 'Download Central'

		if section == 'about':
			template_values['title'] = 'About FlightGear'

		if section == 'aircraft': # and subpage == "aircraft":
			
			## 
			aero_request = self.request.get("aero")
			if aero_request:
				query = db.GqlQuery("SELECT * FROM  Aero where aero = :1", aero_request) 
				aero = query.get()
				#print "aero=", aero_request, aero.description
				if aero:
					##airdb = Aircraft()
					template_values['title'] = aero.description
					template_values['aero'] = aero
					##template_values['content_template'] = 'aero_include.html'
					##template_values['path'] =  '/aircraft/'
					##client = app.Issues.GoogleIssuesClient()
					##issues = client.aero(aero.aero)
					#print issues
					##template_values['issues']  = issues
					##q#uery = db.GqlQuery("SELECT * FROM  AeroFile where directory = :1", aero.directory) 
					##aero_files = query.fetch(20)
					##template_values['aero_files'] = aero_files

					##template_values['videos'] = get_videos(selected_aircraft)
					#print template_values
				else:
					self.redirect("/aircraft/?search=%s" % aero_request)

			else:
				search_text = ""
				airdb = Aircraft()
				if self.request.get("search"):
					search_text = self.request.get("search").lower()
					aircraft = []
					if search_text:
						query = Aero.all()
						dbair = query.fetch(1000)
				
						for aero in dbair:
							#print aero.aero, search_text,  aero.aero.find(search_text)
							if aero.description.lower().find(search_text)  > -1:
								#print "match", search_str
								aircraft.append(aero)
				else:
					aircraft = airdb.get_all()
				
				
				template_values['title'] = 'Aircraft'
				template_values['aircraft'] = aircraft 
				template_values['search_text'] = search_text
				#template_values['liveries'] = app.fetch.liveries()




		path = os.path.join(os.path.dirname(__file__), 'templates/%s.html' % section)
		self.response.out.write(template.render(path, template_values))
コード例 #6
0
	def post(self):

		template_values = {
			#'pilots_online': self.get_pilots()
		}
		query = db.GqlQuery("SELECT * FROM  Aero where aero = :1", self.request.get("aero")) 
		aero = query.get()
		if not aero:
			x =  "add"
			aero = Aero()
			aero.aero = self.request.get("aero")
			aero.author = self.request.get("author")
			aero.directory = self.request.get("directory")
			aero.description = self.request.get("description")
			aero.status = self.request.get("status")
			aero.fdm = self.request.get("flight-model")
			aero.splash = self.request.get("splash")
			aero.version = self.request.get("version")
			aero.splash = self.request.get("splash")
			aero.put()
		else:
			x = "edit"
			pass



		reply = {'success': True, 'status': x}
		#print 'Content-Type: text/plain'
		#print ''
		#print json.dumps(self.get_pilots())
		#path = os.path.join(os.path.dirname(__file__), 'templates/pilots_online.html')
		self.response.out.write(json.dumps(reply))