Beispiel #1
0
	def post(self):
		
		point = Point()
		point.title = self.request.get('title')
		
		if self.request.get('path'):
			point.path = True
		else:
			point.path = False
		
		point.content = cgi.escape(self.request.get('content')).replace('\r\n','<br>').replace('\n','<br>');
		
		point.lat = float(self.request.get('lat'))
		point.lng = float(self.request.get('lng'))
		
		dt = self.request.get('visit')
		if dt:
			point.date = datetime.datetime.strptime(dt,"%Y-%m-%d")
		else:
			point.date = datetime.datetime.now()
			
		point.dateStr = point.date.strftime('%b %d, %Y')
		
		if self.request.get('image'):
			point.img = db.Blob(images.resize(self.request.get('image'),500,500))
		
		point.put()
		self.redirect('/admin')
Beispiel #2
0
 def post(self):
     user = users.get_current_user()
     if user == None:
         self.response.out.write()
     else:
         lat = float(self.request.get("lat"))
         lon = float(self.request.get("lon"))
         hash = geohash.encode(lat, lon)
         point = Point()
         point.geohash = hash
         point.owner = users.get_current_user()
         point.put()
         template_values = {"method": "post"}
         self.response.headers["Content-Type"] = "application/json"
         self.response.out.write('{result:"OK", geohash:"' + hash + '"}')
 def post(self):
     a, d = self.request.get('author'), self.request.get('description')  # error: missing either key
     try:
         schedString = self.request.get('schedulestring')   # error: missing parameter
         jsonSched = simplejson.loads(schedString)          # error: bad json
     
         s = Schedule(auth = a, desc = d)
         s.put()                                            # error: some puts succeed while others fail
         for pt in jsonSched["points"]:                     # error: not an object, or no "points" key
             p = Point(sched = s, location = map(int, pt), phase = ['R', 'R'])  # error:  setting all phases to RR
             p.put()                                        # error: some puts succeed while others fail
     # schedule should be post-ed as json string
     # so parse the string into Schedule's and Point's, then save it 
     #   (check out previous versions of scheduler.py for examples of saving)
         self.response.out.write(simplejson.dumps({'success': 'Schedule was successfully saved!'})) # maybe add the schedule's id?
     except Exception, e:
         self.response.out.write(simplejson.dumps({'error': e.message}))