-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.py
30 lines (27 loc) · 1012 Bytes
/
admin.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
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
import datastore
class Admin(webapp.RequestHandler):
def get(self):
areas = []
for area in datastore.Area.all():
areas.append({
'key': area.key(),
'name': area.name
})
template_values={
'areas': areas
}
self.response.out.write(template.render('templates/admin.html', template_values))
def post(self):
action = self.request.get('action')
if action == 'Add Area':
area = datastore.Area(name=self.request.get('area_name'))
area.map_url = self.request.get('area_map_url')
area.put()
elif action == 'Add Trail':
trail = datastore.Trail(
area = datastore.Area.get(self.request.get('trail_area_id')),
name = self.request.get('trail_name'))
trail.put()
self.get()