Exemplo n.º 1
0
	def get(self, slug):
		people = []

		q = Location.gql("WHERE slug = :slug", slug = slug)

		location = q.get()
		if location:
			tapins = Tapin.gql("WHERE location = :location ORDER BY date", location = location)

			from collections import defaultdict
			grouped = defaultdict(list)
			for tapin in tapins: 
				grouped[tapin.date.date()].append(tapin)

			tapin = self.request.get('tapin')

			template = jinja_environment.get_template("location.html")
			self.response.out.write(template.render({
				"user": users.get_current_user(),
				"location": location,
				"tapins": grouped,
				"tapin": tapin
			}))
		else:
			self.redirect("/new-location?slug=%s&message=not-found" % slug)
Exemplo n.º 2
0
	def get(self):
		user = users.get_current_user()
		if user:
			tapins = Tapin.gql("WHERE user = :user ORDER BY date DESC", user = user)
			locations = []
			for loc in filter(None, map(lambda x: x.geolocation, tapins)):
				locations.append([loc.lat, loc.lon])
			pointjson = json.dumps(locations)

			template = jinja_environment.get_template("user.html")
			self.response.out.write(template.render({"user": user, "tapins": tapins, "pointjson": pointjson}))
		else:
			self.redirect(users.create_login_url("/"))
Exemplo n.º 3
0
	def post(self):
		tapin_key = self.request.get('tapin')
		latitude = self.request.get('latitude')
		longitude = self.request.get('longitude')
		if tapin_key:
			tapin_key = db.Key(tapin_key)
			tapin = Tapin.get(tapin_key)
			if tapin:
				tapin.geolocation = db.GeoPt(latitude, longitude)
				tapin.put()
				self.response.out.write('Location recorded')
			else:
				self.response.set_status(400)
				self.response.out.write('400 - Tapin not found')
		else:
			self.response.set_status(400)
			self.response.out.write('400 - Tapin not provided')
Exemplo n.º 4
0
	def get(self, slug):
		if users.get_current_user():
			q = Location.gql("WHERE slug = :slug", slug=slug)
			location = q.get()
			if location:
				tapin = Tapin()
				tapin.user = users.get_current_user()
				tapin.location = location.key()
				tapin.put()
				self.redirect("/location/" + slug + "?tapin=" + str(tapin.key()))
		else:
			self.redirect(users.create_login_url("/tapin/%s" % slug))
Exemplo n.º 5
0
	def get(self):
		tapins = Tapin.gql("ORDER BY date")
		template = jinja_environment.get_template("tapins.html")
		self.response.out.write(template.render({"tapins":tapins}))