Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 105 lines (92 sloc) 4.063 kb
9b632dd Jeff Lindsay initial commit -- basic form, rough listing
progrium authored
1 from google.appengine.ext import webapp, db
2 from google.appengine.ext.webapp import util, template
3 from google.appengine.api import urlfetch, memcache, users
4 from django.utils import simplejson
5 from datetime import datetime, timedelta
6 #import logging, urllib
7
8 ROOM_OPTIONS = ['cave', 'hall', 'savanna', 'sunroom', 'greenroom', 'frontarea', '140b']
9
10 class Event(db.Model):
11 status = db.StringProperty(required=True, default='pending', choices=set(
12 ['pending', 'preapproved', 'approved', 'canceled', 'onhold', 'expired']))
13 member = db.UserProperty(auto_current_user_add=True)
14 name = db.StringProperty(required=True)
15 start_time = db.DateTimeProperty(required=True)
16 end_time = db.DateTimeProperty()
17 staff = db.ListProperty(users.User)
18 rooms = db.StringListProperty() #choices=set(ROOM_OPTIONS)
19
20 details = db.StringProperty()
21 url = db.StringProperty()
22 fee = db.StringProperty()
23 notes = db.StringProperty()
24 type = db.StringProperty(required=True)
25 estimated_size = db.StringProperty(required=True)
26
27 contact_name = db.StringProperty(required=True)
28 contact_phone = db.StringProperty(required=True)
29
30 def start_date(self):
31 return self.start_time.date()
32
33 class EventHandler(webapp.RequestHandler):
34 def get(self, id):
35 event = Event.get_by_id(int(id))
36 self.response.out.write(template.render('templates/event.html', locals()))
37
38 class ApprovedHandler(webapp.RequestHandler):
39 def get(self):
40 user = users.get_current_user()
41 if user:
42 logout_url = users.create_logout_url('/')
43 else:
44 login_url = users.create_login_url('/')
45 events = Event.all().filter('status IN', ['approved', 'canceled']).order('start_time')
46 today = datetime.today()
47 tomorrow = today + timedelta(days=1)
48 self.response.out.write(template.render('templates/approved.html', locals()))
49
50 class PendingHandler(webapp.RequestHandler):
51 def get(self):
52 user = users.get_current_user()
53 if user:
54 logout_url = users.create_logout_url('/')
55 else:
56 login_url = users.create_login_url('/')
57 events = Event.all().filter('status IN', ['pending', 'preapproved', 'onhold', 'expired']).order('start_time')
58 today = datetime.today()
59 tomorrow = today + timedelta(days=1)
60 self.response.out.write(template.render('templates/pending.html', locals()))
61
62 class NewHandler(webapp.RequestHandler):
63 #@util.login_required
64 def get(self):
65 user = users.get_current_user()
66 if user:
67 logout_url = users.create_logout_url('/')
68 else:
69 login_url = users.create_login_url('/')
70 rooms = ROOM_OPTIONS
71 self.response.out.write(template.render('templates/new.html', locals()))
72
73 def post(self):
74 user = users.get_current_user()
75 start_time = datetime.strptime("%s %s:%s %s" % (
76 self.request.get('start_date'),
77 self.request.get('start_time_hour'),
78 self.request.get('start_time_minute'),
79 self.request.get('start_time_ampm')), "%d/%m/%Y %I:%M %p")
80 event = Event(
81 name = self.request.get('name'),
82 start_time = start_time,
83 type = self.request.get('type'),
84 estimated_size = self.request.get('estimated_size'),
85 contact_name = self.request.get('contact_name'),
86 contact_phone = self.request.get('contact_phone'),
87 details = self.request.get('details'),
88 url = self.request.get('url'),
89 fee = self.request.get('fee'),
90 notes = self.request.get('notes'),
91 rooms = self.request.get_all('rooms'))
92 event.put()
93 self.redirect('/')
94
95 def main():
96 application = webapp.WSGIApplication([
97 ('/', ApprovedHandler),
98 ('/pending', PendingHandler),
99 ('/new', NewHandler),
100 ('/event/(\d+).*', EventHandler), ],debug=True)
101 util.run_wsgi_app(application)
102
103 if __name__ == '__main__':
104 main()
Something went wrong with that request. Please try again.