-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapedit.py
31 lines (28 loc) · 1.23 KB
/
mapedit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import json, logging, os, urllib
from datetime import datetime, timedelta
from google.appengine.api import users
from google.appengine.ext import ndb
from baserequest import AuthorizedRequest, HelperGeofancyRequest, JINJA
from data import Geofency, Location
class MapEdit(AuthorizedRequest):
def get(self):
geofancy = Geofency.getSortedByLocation(self.user.user_id())
locations = Location.getAllLocations(self.user.user_id())
data = {'username': self.user.nickname(),
'geofancy': map(lambda x:x.to_dict(), geofancy),
'locations': map(lambda x:x.to_dict(), locations)}
template = JINJA.get_template('mapedit.html')
self.response.write(template.render(data))
# get
def post(self):
if self.request.get('name') and self.request.get('lat') and self.request.get('lng'):
loc = Location(user_id = self.user.user_id(),
pos = ndb.GeoPt(self.request.get('lat'), self.request.get('lng')),
radius=100,
name=self.request.get('name'),
home=False,
work=False)
loc.put()
self.redirect('/mapedit')
#post
#MapEdit