Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 460 lines (413 sloc) 19.436 kB
8414350 @billsaysthis multiline for details and notes fields
billsaysthis authored
1 import cgi
9b632dd @progrium initial commit -- basic form, rough listing
progrium authored
2 from google.appengine.ext import webapp, db
3 from google.appengine.ext.webapp import util, template
47a7f7a @progrium basic form validation, added end time, start of notifications, some f…
progrium authored
4 from google.appengine.api import urlfetch, memcache, users, mail
5
9b632dd @progrium initial commit -- basic form, rough listing
progrium authored
6 from django.utils import simplejson
fcf7602 @progrium working approval process and ical view of approved events
progrium authored
7 from django.template.defaultfilters import slugify
5cd04ac Fixed iCalendar-related imports, and added the end date to the
Matt Hancher authored
8 from icalendar import Calendar
b4ea292 Handler to bug pending events
Brian Klug authored
9 import logging, urllib, os
7bdb866 Let all members staff events.
Brian Klug authored
10 from pprint import pprint
b879063 @mdhancher Respect the local timezone (Pacific), and tidy up related imports.
mdhancher authored
11 from datetime import datetime, timedelta
fcf7602 @progrium working approval process and ical view of approved events
progrium authored
12
2ad290e @billsaysthis add logging model and obscure list view
billsaysthis authored
13 from models import Event, Feedback, HDLog, ROOM_OPTIONS, PENDING_LIFETIME
4c7da5d @billsaysthis added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
14 from utils import username, human_username, set_cookie, local_today, is_phone_valid, UserRights, dojo, is_event_dup
81a81e1 @progrium adding errors for form validation, full notifications, and minor edit…
progrium authored
15 from notices import *
7742592 @progrium start of maintaining form state on errors
progrium authored
16
9f06c39 @casey Added RSS for upcoming events.
casey authored
17 import PyRSS2Gen
18
4c7da5d @billsaysthis added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
19 webapp.template.register_template_library('templatefilters')
20
9f06c39 @casey Added RSS for upcoming events.
casey authored
21 def event_path(event):
22 return '/event/%s-%s' % (event.key().id(), slugify(event.name))
23
219203b @dustball Cache better
dustball authored
24 class DomainCacheCron(webapp.RequestHandler):
25 def post(self):
26 noop = dojo('/groups/events',force=True)
27
28
f49797a @dustball Reminders 2.0
dustball authored
29 class ReminderCron(webapp.RequestHandler):
30 def post(self):
31 self.response.out.write("REMINDERS")
32 today = local_today()
33 # remind everyone 3 days in advance they need to show up
34 events = Event.all() \
35 .filter('status IN', ['approved']) \
36 .filter('reminded =', False) \
37 .filter('start_time <', today + timedelta(days=3))
38 for event in events:
39 self.response.out.write(event.name)
40 # only mail them if they created the event 2+ days ago
41 if event.created < today - timedelta(days=2):
42 schedule_reminder_email(event)
43 event.reminded = True
44 event.put()
45
46
e2b9558 @btubbs Fixes issue 4. Changed to jqueryUI datepicker. Replaced jquery
btubbs authored
47 class ExpireCron(webapp.RequestHandler):
47a7f7a @progrium basic form validation, added end time, start of notifications, some f…
progrium authored
48 def post(self):
49 # Expire events marked to expire today
b879063 @mdhancher Respect the local timezone (Pacific), and tidy up related imports.
mdhancher authored
50 today = local_today()
47a7f7a @progrium basic form validation, added end time, start of notifications, some f…
progrium authored
51 events = Event.all() \
52 .filter('status IN', ['pending', 'understaffed']) \
53 .filter('expired >=', today) \
54 .filter('expired <', today + timedelta(days=1))
55 for event in events:
56 event.expire()
57 notify_owner_expired(event)
f49797a @dustball Reminders 2.0
dustball authored
58
f1997e4 @christopherb Made misc style fixes
christopherb authored
59
47a7f7a @progrium basic form validation, added end time, start of notifications, some f…
progrium authored
60 class ExpireReminderCron(webapp.RequestHandler):
61 def post(self):
62 # Find events expiring in 10 days to warn owner
b879063 @mdhancher Respect the local timezone (Pacific), and tidy up related imports.
mdhancher authored
63 ten_days = local_today() + timedelta(days=10)
47a7f7a @progrium basic form validation, added end time, start of notifications, some f…
progrium authored
64 events = Event.all() \
65 .filter('status IN', ['pending', 'understaffed']) \
66 .filter('expired >=', ten_days) \
67 .filter('expired <', ten_days + timedelta(days=1))
68 for event in events:
69 notify_owner_expiring(event)
70
f1997e4 @christopherb Made misc style fixes
christopherb authored
71
fcf7602 @progrium working approval process and ical view of approved events
progrium authored
72 class EventsHandler(webapp.RequestHandler):
73 def get(self, format):
9f06c39 @casey Added RSS for upcoming events.
casey authored
74 events = Event.all().filter('status IN', ['approved', 'canceled']).order('start_time')
64ccc02 @billsaysthis make nav menu into filter, move new event link to top, make all event…
billsaysthis authored
75 access_rights = UserRights(user, event)
736390e @dustball Bug fixes & UI
dustball authored
76 show_all_nav = user
fcf7602 @progrium working approval process and ical view of approved events
progrium authored
77 if format == 'ics':
78 cal = Calendar()
79 for event in events:
80 cal.add_component(event.to_ical())
81 self.response.headers['content-type'] = 'text/calendar'
82 self.response.out.write(cal.as_string())
2e08a66 @progrium cleaning things up and adding json representations for jon
progrium authored
83 elif format == 'json':
84 self.response.headers['content-type'] = 'application/json'
a493a39 @progrium changing the json events list to the approved list
progrium authored
85 events = map(lambda x: x.to_dict(summarize=True), Event.get_approved_list())
2e08a66 @progrium cleaning things up and adding json representations for jon
progrium authored
86 self.response.out.write(simplejson.dumps(events))
9f06c39 @casey Added RSS for upcoming events.
casey authored
87 elif format =='rss':
88 url_base = 'http://' + self.request.headers.get('host', 'events.hackerdojo.com')
89 rss = PyRSS2Gen.RSS2(
90 title = "Hacker Dojo Events Feed",
91 link = url_base,
92 description = "Upcoming events at the Hacker Dojo in Mountain View, CA",
93 lastBuildDate = datetime.now(),
94 items = [PyRSS2Gen.RSSItem(
95 title = event.name,
96 link = url_base + event_path(event),
97 description = event.details,
98 guid = url_base + event_path(event),
99 pubDate = event.updated,
100 ) for event in events]
101 )
102
103 self.response.headers['content-type'] = 'application/xml'
104 self.response.out.write(rss.to_xml())
9b632dd @progrium initial commit -- basic form, rough listing
progrium authored
105
f1997e4 @christopherb Made misc style fixes
christopherb authored
106
ca8c7f2 @dustball Let edit events and refactor error handling
dustball authored
107 class EditHandler(webapp.RequestHandler):
108 def get(self, id):
109 event = Event.get_by_id(int(id))
110 user = users.get_current_user()
736390e @dustball Bug fixes & UI
dustball authored
111 show_all_nav = user
ca8c7f2 @dustball Let edit events and refactor error handling
dustball authored
112 access_rights = UserRights(user, event)
113 if access_rights.can_edit:
4c7da5d @billsaysthis added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
114 logout_url = users.create_logout_url('/')
115 rooms = ROOM_OPTIONS
116 hours = [1,2,3,4,5,6,7,8,9,10,11,12]
117 self.response.out.write(template.render('templates/edit.html', locals()))
ca8c7f2 @dustball Let edit events and refactor error handling
dustball authored
118 else:
4c7da5d @billsaysthis added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
119 self.response.out.write("Access denied")
ca8c7f2 @dustball Let edit events and refactor error handling
dustball authored
120
121 def post(self, id):
122 event = Event.get_by_id(int(id))
123 user = users.get_current_user()
124 access_rights = UserRights(user, event)
125 if access_rights.can_edit:
4c7da5d @billsaysthis added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
126 try:
127 srg_date = self.request.get('date')
128 if event.start_time == srg_date:
129 start_time = start_time
130 else:
131 st_date = srg_date[0:len(srg_date)-9]
132 start_time = datetime.strptime('%s %s:%s %s' % (
133 st_date,
134 self.request.get('start_time_hour'),
135 self.request.get('start_time_minute'),
136 self.request.get('start_time_ampm')), '%Y-%m-%d %I:%M %p')
137 end_time = datetime.strptime('%s %s:%s %s' % (
138 st_date,
139 self.request.get('end_time_hour'),
140 self.request.get('end_time_minute'),
141 self.request.get('end_time_ampm')), '%Y-%m-%d %I:%M %p')
142 if not self.request.get('estimated_size').isdigit():
143 raise ValueError('Estimated number of people must be a number')
144 if not int(self.request.get('estimated_size')) > 0:
145 raise ValueError('Estimated number of people must be greater then zero')
146 if ( self.request.get( 'contact_phone' ) and not is_phone_valid( self.request.get( 'contact_phone' ) ) ):
147 raise ValueError( 'Phone number does not appear to be valid' )
148 else:
149 event.name = self.request.get('name')
150 event.start_time = start_time
151 event.end_time = end_time
152 event.estimated_size = cgi.escape(self.request.get('estimated_size'))
153 event.contact_name = cgi.escape(self.request.get('contact_name'))
154 event.contact_phone = cgi.escape(self.request.get('contact_phone'))
155 event.details = cgi.escape(self.request.get('details'))
156 event.url = cgi.escape(self.request.get('url'))
157 event.fee = cgi.escape(self.request.get('fee'))
158 event.notes = cgi.escape(self.request.get('notes'))
159 event.rooms = self.request.get_all('rooms')
160 event.put()
0eb5a92 @billsaysthis basic logging for all user-initiated post methods in place
billsaysthis authored
161 log = HDLog(event=event,description="Edited event")
2ad290e @billsaysthis add logging model and obscure list view
billsaysthis authored
162 log.put()
4c7da5d @billsaysthis added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
163 self.redirect(event_path(event))
2ad290e @billsaysthis add logging model and obscure list view
billsaysthis authored
164 except ValueError, e:
4c7da5d @billsaysthis added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
165 error = str(e)
166 self.response.out.write(template.render('templates/error.html', locals()))
ca8c7f2 @dustball Let edit events and refactor error handling
dustball authored
167 else:
4c7da5d @billsaysthis added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
168 self.response.out.write("Access denied")
ca8c7f2 @dustball Let edit events and refactor error handling
dustball authored
169
170
9b632dd @progrium initial commit -- basic form, rough listing
progrium authored
171 class EventHandler(webapp.RequestHandler):
172 def get(self, id):
173 event = Event.get_by_id(int(id))
2e08a66 @progrium cleaning things up and adding json representations for jon
progrium authored
174 if self.request.path.endswith('json'):
175 self.response.headers['content-type'] = 'application/json'
176 self.response.out.write(simplejson.dumps(event.to_dict()))
fcf7602 @progrium working approval process and ical view of approved events
progrium authored
177 else:
2e08a66 @progrium cleaning things up and adding json representations for jon
progrium authored
178 user = users.get_current_user()
179 if user:
766e87c @christopherb Added UserRights class.
christopherb authored
180 access_rights = UserRights(user, event)
2e08a66 @progrium cleaning things up and adding json representations for jon
progrium authored
181 logout_url = users.create_logout_url('/')
766e87c @christopherb Added UserRights class.
christopherb authored
182
2e08a66 @progrium cleaning things up and adding json representations for jon
progrium authored
183 else:
184 login_url = users.create_login_url('/')
7ebb2cd @christopherb Cleaned up the style of the files some. Mostly standardizing on singl…
christopherb authored
185 event.details = db.Text(event.details.replace('\n','<br/>'))
736390e @dustball Bug fixes & UI
dustball authored
186 show_all_nav = user
7ebb2cd @christopherb Cleaned up the style of the files some. Mostly standardizing on singl…
christopherb authored
187 event.notes = db.Text(event.notes.replace('\n','<br/>'))
2e08a66 @progrium cleaning things up and adding json representations for jon
progrium authored
188 self.response.out.write(template.render('templates/event.html', locals()))
e2b9558 @btubbs Fixes issue 4. Changed to jqueryUI datepicker. Replaced jquery
btubbs authored
189
fcf7602 @progrium working approval process and ical view of approved events
progrium authored
190 def post(self, id):
191 event = Event.get_by_id(int(id))
192 user = users.get_current_user()
766e87c @christopherb Added UserRights class.
christopherb authored
193 access_rights = UserRights(user, event)
194
fcf7602 @progrium working approval process and ical view of approved events
progrium authored
195 state = self.request.get('state')
196 if state:
0eb5a92 @billsaysthis basic logging for all user-initiated post methods in place
billsaysthis authored
197 desc = ''
766e87c @christopherb Added UserRights class.
christopherb authored
198 if state.lower() == 'approve' and access_rights.can_approve:
fcf7602 @progrium working approval process and ical view of approved events
progrium authored
199 event.approve()
0eb5a92 @billsaysthis basic logging for all user-initiated post methods in place
billsaysthis authored
200 desc = 'Approved event'
b84b533 @dustball Fix one more staff logic bomb
dustball authored
201 if state.lower() == 'staff' and access_rights.can_staff:
fcf7602 @progrium working approval process and ical view of approved events
progrium authored
202 event.add_staff(user)
0eb5a92 @billsaysthis basic logging for all user-initiated post methods in place
billsaysthis authored
203 desc = 'Added self as staff'
766e87c @christopherb Added UserRights class.
christopherb authored
204 if state.lower() == 'unstaff' and access_rights.can_unstaff:
72849c2 @billsaysthis added unstaff event, including email notification if event becomes un…
billsaysthis authored
205 event.remove_staff(user)
0eb5a92 @billsaysthis basic logging for all user-initiated post methods in place
billsaysthis authored
206 desc = 'Removed self as staff'
766e87c @christopherb Added UserRights class.
christopherb authored
207 if state.lower() == 'cancel' and access_rights.can_cancel:
fcf7602 @progrium working approval process and ical view of approved events
progrium authored
208 event.cancel()
0eb5a92 @billsaysthis basic logging for all user-initiated post methods in place
billsaysthis authored
209 desc = 'Cancelled event'
766e87c @christopherb Added UserRights class.
christopherb authored
210 if state.lower() == 'delete' and access_rights.is_admin:
a67ac50 @mdhancher Add a simple admin-only event delete and undelete.
mdhancher authored
211 event.delete()
0eb5a92 @billsaysthis basic logging for all user-initiated post methods in place
billsaysthis authored
212 desc = 'Deleted event'
766e87c @christopherb Added UserRights class.
christopherb authored
213 if state.lower() == 'undelete' and access_rights.is_admin:
a67ac50 @mdhancher Add a simple admin-only event delete and undelete.
mdhancher authored
214 event.undelete()
0eb5a92 @billsaysthis basic logging for all user-initiated post methods in place
billsaysthis authored
215 desc = 'Undeleted event'
766e87c @christopherb Added UserRights class.
christopherb authored
216 if state.lower() == 'expire' and access_rights.is_admin:
47a7f7a @progrium basic form validation, added end time, start of notifications, some f…
progrium authored
217 event.expire()
0eb5a92 @billsaysthis basic logging for all user-initiated post methods in place
billsaysthis authored
218 desc = 'Expired event'
47a7f7a @progrium basic form validation, added end time, start of notifications, some f…
progrium authored
219 if event.status == 'approved':
220 notify_owner_approved(event)
0eb5a92 @billsaysthis basic logging for all user-initiated post methods in place
billsaysthis authored
221 if desc != '':
222 log = HDLog(event=event,description=desc)
223 log.put()
9f06c39 @casey Added RSS for upcoming events.
casey authored
224 self.redirect(event_path(event))
9b632dd @progrium initial commit -- basic form, rough listing
progrium authored
225
f1997e4 @christopherb Made misc style fixes
christopherb authored
226
9b632dd @progrium initial commit -- basic form, rough listing
progrium authored
227 class ApprovedHandler(webapp.RequestHandler):
228 def get(self):
229 user = users.get_current_user()
230 if user:
231 logout_url = users.create_logout_url('/')
232 else:
233 login_url = users.create_login_url('/')
b879063 @mdhancher Respect the local timezone (Pacific), and tidy up related imports.
mdhancher authored
234 today = local_today()
736390e @dustball Bug fixes & UI
dustball authored
235 show_all_nav = user
47a7f7a @progrium basic form validation, added end time, start of notifications, some f…
progrium authored
236 events = Event.get_approved_list()
9b632dd @progrium initial commit -- basic form, rough listing
progrium authored
237 tomorrow = today + timedelta(days=1)
d63161a Add widget mode
Brian Klug authored
238 whichbase = 'base.html'
239 if self.request.get('base'):
7ebb2cd @christopherb Cleaned up the style of the files some. Mostly standardizing on singl…
christopherb authored
240 whichbase = self.request.get('base') + '.html'
9b632dd @progrium initial commit -- basic form, rough listing
progrium authored
241 self.response.out.write(template.render('templates/approved.html', locals()))
242
f1997e4 @christopherb Made misc style fixes
christopherb authored
243
a82b43e @billsaysthis add myevents, pastevents code, refined list display on event page
billsaysthis authored
244 class MyEventsHandler(webapp.RequestHandler):
245 @util.login_required
246 def get(self):
247 user = users.get_current_user()
248 if user:
249 logout_url = users.create_logout_url('/')
250 else:
251 login_url = users.create_login_url('/')
252 events = Event.all().filter('member = ', user).order('start_time')
736390e @dustball Bug fixes & UI
dustball authored
253 show_all_nav = user
b879063 @mdhancher Respect the local timezone (Pacific), and tidy up related imports.
mdhancher authored
254 today = local_today()
a82b43e @billsaysthis add myevents, pastevents code, refined list display on event page
billsaysthis authored
255 tomorrow = today + timedelta(days=1)
256 self.response.out.write(template.render('templates/myevents.html', locals()))
257
f1997e4 @christopherb Made misc style fixes
christopherb authored
258
a82b43e @billsaysthis add myevents, pastevents code, refined list display on event page
billsaysthis authored
259 class PastHandler(webapp.RequestHandler):
260 def get(self):
261 user = users.get_current_user()
262 if user:
263 logout_url = users.create_logout_url('/')
264 else:
265 login_url = users.create_login_url('/')
b879063 @mdhancher Respect the local timezone (Pacific), and tidy up related imports.
mdhancher authored
266 today = local_today()
736390e @dustball Bug fixes & UI
dustball authored
267 show_all_nav = user
d75579f @progrium minor updates here and there to bills contributions.
progrium authored
268 events = Event.all().filter('start_time < ', today).order('-start_time')
a82b43e @billsaysthis add myevents, pastevents code, refined list display on event page
billsaysthis authored
269 self.response.out.write(template.render('templates/past.html', locals()))
270
f1997e4 @christopherb Made misc style fixes
christopherb authored
271
b4ea292 Handler to bug pending events
Brian Klug authored
272 class CronBugOwnersHandler(webapp.RequestHandler):
273 def get(self):
274 events = Event.get_pending_list()
275 for e in events:
4c7da5d @billsaysthis added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
276 bug_owner_pending(e)
277
278
279 class AllFutureHandler(webapp.RequestHandler):
280 def get(self):
281 user = users.get_current_user()
282 if user:
283 logout_url = users.create_logout_url('/')
284 else:
285 login_url = users.create_login_url('/')
736390e @dustball Bug fixes & UI
dustball authored
286 show_all_nav = user
4c7da5d @billsaysthis added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
287 events = Event.get_all_future_list()
288 today = local_today()
289 tomorrow = today + timedelta(days=1)
290 self.response.out.write(template.render('templates/all_future.html', locals()))
b4ea292 Handler to bug pending events
Brian Klug authored
291
f1997e4 @christopherb Made misc style fixes
christopherb authored
292
9b632dd @progrium initial commit -- basic form, rough listing
progrium authored
293 class PendingHandler(webapp.RequestHandler):
294 def get(self):
295 user = users.get_current_user()
296 if user:
297 logout_url = users.create_logout_url('/')
298 else:
299 login_url = users.create_login_url('/')
47a7f7a @progrium basic form validation, added end time, start of notifications, some f…
progrium authored
300 events = Event.get_pending_list()
736390e @dustball Bug fixes & UI
dustball authored
301 show_all_nav = user
b879063 @mdhancher Respect the local timezone (Pacific), and tidy up related imports.
mdhancher authored
302 today = local_today()
9b632dd @progrium initial commit -- basic form, rough listing
progrium authored
303 tomorrow = today + timedelta(days=1)
304 self.response.out.write(template.render('templates/pending.html', locals()))
305
f1997e4 @christopherb Made misc style fixes
christopherb authored
306
9b632dd @progrium initial commit -- basic form, rough listing
progrium authored
307 class NewHandler(webapp.RequestHandler):
fcf7602 @progrium working approval process and ical view of approved events
progrium authored
308 @util.login_required
9b632dd @progrium initial commit -- basic form, rough listing
progrium authored
309 def get(self):
310 user = users.get_current_user()
4d85afa @dustball Remove staffing requirement and make members more responsible
dustball authored
311 human = human_username(user)
9b632dd @progrium initial commit -- basic form, rough listing
progrium authored
312 if user:
313 logout_url = users.create_logout_url('/')
314 else:
315 login_url = users.create_login_url('/')
316 rooms = ROOM_OPTIONS
317 self.response.out.write(template.render('templates/new.html', locals()))
e2b9558 @btubbs Fixes issue 4. Changed to jqueryUI datepicker. Replaced jquery
btubbs authored
318
f1997e4 @christopherb Made misc style fixes
christopherb authored
319
9b632dd @progrium initial commit -- basic form, rough listing
progrium authored
320 def post(self):
321 user = users.get_current_user()
7742592 @progrium start of maintaining form state on errors
progrium authored
322 try:
7ebb2cd @christopherb Cleaned up the style of the files some. Mostly standardizing on singl…
christopherb authored
323 start_time = datetime.strptime('%s %s:%s %s' % (
7742592 @progrium start of maintaining form state on errors
progrium authored
324 self.request.get('date'),
325 self.request.get('start_time_hour'),
326 self.request.get('start_time_minute'),
7ebb2cd @christopherb Cleaned up the style of the files some. Mostly standardizing on singl…
christopherb authored
327 self.request.get('start_time_ampm')), '%m/%d/%Y %I:%M %p')
328 end_time = datetime.strptime('%s %s:%s %s' % (
7742592 @progrium start of maintaining form state on errors
progrium authored
329 self.request.get('date'),
330 self.request.get('end_time_hour'),
331 self.request.get('end_time_minute'),
7ebb2cd @christopherb Cleaned up the style of the files some. Mostly standardizing on singl…
christopherb authored
332 self.request.get('end_time_ampm')), '%m/%d/%Y %I:%M %p')
8615877 Fix validation for event size
Brian Klug authored
333 if not self.request.get('estimated_size').isdigit():
7ebb2cd @christopherb Cleaned up the style of the files some. Mostly standardizing on singl…
christopherb authored
334 raise ValueError('Estimated number of people must be a number')
8615877 Fix validation for event size
Brian Klug authored
335 if not int(self.request.get('estimated_size')) > 0:
7ebb2cd @christopherb Cleaned up the style of the files some. Mostly standardizing on singl…
christopherb authored
336 raise ValueError('Estimated number of people must be greater then zero')
7742592 @progrium start of maintaining form state on errors
progrium authored
337 if (end_time-start_time).days < 0:
7ebb2cd @christopherb Cleaned up the style of the files some. Mostly standardizing on singl…
christopherb authored
338 raise ValueError('End time must be after start time')
a244c65 @dustball Bug fixes
dustball authored
339 if ( self.request.get( 'contact_phone' ) and not is_phone_valid( self.request.get( 'contact_phone' ) ) ):
7ebb2cd @christopherb Cleaned up the style of the files some. Mostly standardizing on singl…
christopherb authored
340 raise ValueError( 'Phone number does not appear to be valid' )
7742592 @progrium start of maintaining form state on errors
progrium authored
341 else:
342 event = Event(
ca3c6dd Escaped additional fields that could be used for XSS
Christopher Biettchert authored
343 name = cgi.escape(self.request.get('name')),
7742592 @progrium start of maintaining form state on errors
progrium authored
344 start_time = start_time,
345 end_time = end_time,
ca3c6dd Escaped additional fields that could be used for XSS
Christopher Biettchert authored
346 type = cgi.escape(self.request.get('type')),
347 estimated_size = cgi.escape(self.request.get('estimated_size')),
348 contact_name = cgi.escape(self.request.get('contact_name')),
349 contact_phone = cgi.escape(self.request.get('contact_phone')),
8414350 @billsaysthis multiline for details and notes fields
billsaysthis authored
350 details = cgi.escape(self.request.get('details')),
ca3c6dd Escaped additional fields that could be used for XSS
Christopher Biettchert authored
351 url = cgi.escape(self.request.get('url')),
352 fee = cgi.escape(self.request.get('fee')),
8414350 @billsaysthis multiline for details and notes fields
billsaysthis authored
353 notes = cgi.escape(self.request.get('notes')),
7ebb2cd @christopherb Cleaned up the style of the files some. Mostly standardizing on singl…
christopherb authored
354 rooms = self.request.get_all('rooms'),
b879063 @mdhancher Respect the local timezone (Pacific), and tidy up related imports.
mdhancher authored
355 expired = local_today() + timedelta(days=PENDING_LIFETIME), # Set expected expiration date
7742592 @progrium start of maintaining form state on errors
progrium authored
356 )
357 event.put()
0eb5a92 @billsaysthis basic logging for all user-initiated post methods in place
billsaysthis authored
358 log = HDLog(event=event,description="Created new event")
359 log.put()
7742592 @progrium start of maintaining form state on errors
progrium authored
360 notify_owner_confirmation(event)
361 notify_new_event(event)
81a81e1 @progrium adding errors for form validation, full notifications, and minor edit…
progrium authored
362 set_cookie(self.response.headers, 'formvalues', None)
7742592 @progrium start of maintaining form state on errors
progrium authored
363 self.redirect('/event/%s-%s' % (event.key().id(), slugify(event.name)))
81a81e1 @progrium adding errors for form validation, full notifications, and minor edit…
progrium authored
364 except Exception, e:
365 message = str(e)
366 if 'match format' in message:
7ebb2cd @christopherb Cleaned up the style of the files some. Mostly standardizing on singl…
christopherb authored
367 message = 'Date is required.'
81a81e1 @progrium adding errors for form validation, full notifications, and minor edit…
progrium authored
368 if message.startswith('Property'):
369 message = message[9:].replace('_', ' ').capitalize()
ca8c7f2 @dustball Let edit events and refactor error handling
dustball authored
370 # This is NOT a reliable way to handle erorrs
371 #set_cookie(self.response.headers, 'formerror', message)
372 #set_cookie(self.response.headers, 'formvalues', dict(self.request.POST))
373 #self.redirect('/new')
374 error = message
375 self.response.out.write(template.render('templates/error.html', locals()))
376
4c7da5d @billsaysthis added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
377 class CheckConflict(webapp.RequestHandler):
378 def post(self, id):
379 start_time = datetime.strptime('%s %s:%s %s' % (
380 self.request.get('date'),
381 self.request.get('start_time_hour'),
382 self.request.get('start_time_minute'),
383 self.request.get('start_time_ampm')), '%m/%d/%Y %I:%M %p')
384 end_time = datetime.strptime('%s %s:%s %s' % (
385 self.request.get('date'),
386 self.request.get('end_time_hour'),
387 self.request.get('end_time_minute'),
388 self.request.get('end_time_ampm')), '%m/%d/%Y %I:%M %p')
389 rooms = self.request.get_all('rooms')
390 message = is_event_dup(start_date, end_date, rooms)
391 self.response.out.write(message)
d2c3dc7 @billsaysthis moved app-specific js to separate file
billsaysthis authored
392
2ad290e @billsaysthis add logging model and obscure list view
billsaysthis authored
393 class LogsHandler(webapp.RequestHandler):
394 @util.login_required
395 def get(self):
396 user = users.get_current_user()
397 logs = HDLog.get_logs_list()
398 if user:
399 logout_url = users.create_logout_url('/')
400 else:
401 login_url = users.create_login_url('/')
736390e @dustball Bug fixes & UI
dustball authored
402 show_all_nav = user
2ad290e @billsaysthis add logging model and obscure list view
billsaysthis authored
403 self.response.out.write(template.render('templates/logs.html', locals()))
404
d2c3dc7 @billsaysthis moved app-specific js to separate file
billsaysthis authored
405 class FeedbackHandler(webapp.RequestHandler):
406 @util.login_required
7ebb2cd @christopherb Cleaned up the style of the files some. Mostly standardizing on singl…
christopherb authored
407 def get(self, id):
d2c3dc7 @billsaysthis moved app-specific js to separate file
billsaysthis authored
408 user = users.get_current_user()
7ebb2cd @christopherb Cleaned up the style of the files some. Mostly standardizing on singl…
christopherb authored
409 event = Event.get_by_id(int(id))
d2c3dc7 @billsaysthis moved app-specific js to separate file
billsaysthis authored
410 if user:
411 logout_url = users.create_logout_url('/')
412 else:
413 login_url = users.create_login_url('/')
414 self.response.out.write(template.render('templates/feedback.html', locals()))
415
7ebb2cd @christopherb Cleaned up the style of the files some. Mostly standardizing on singl…
christopherb authored
416 def post(self, id):
d2c3dc7 @billsaysthis moved app-specific js to separate file
billsaysthis authored
417 user = users.get_current_user()
7ebb2cd @christopherb Cleaned up the style of the files some. Mostly standardizing on singl…
christopherb authored
418 event = Event.get_by_id(int(id))
8c52522 @billsaysthis small tweak to how feedbacks displayed in event page
billsaysthis authored
419 try:
420 if self.request.get('rating'):
421 feedback = Feedback(
422 event = event,
423 rating = int(self.request.get('rating')),
ca3c6dd Escaped additional fields that could be used for XSS
Christopher Biettchert authored
424 comment = cgi.escape(self.request.get('comment')))
8c52522 @billsaysthis small tweak to how feedbacks displayed in event page
billsaysthis authored
425 feedback.put()
0eb5a92 @billsaysthis basic logging for all user-initiated post methods in place
billsaysthis authored
426 log = HDLog(event=event,description="Posted feedback")
427 log.put()
8c52522 @billsaysthis small tweak to how feedbacks displayed in event page
billsaysthis authored
428 self.redirect('/event/%s-%s' % (event.key().id(), slugify(event.name)))
429 else:
7ebb2cd @christopherb Cleaned up the style of the files some. Mostly standardizing on singl…
christopherb authored
430 raise ValueError('Please select a rating')
8c52522 @billsaysthis small tweak to how feedbacks displayed in event page
billsaysthis authored
431 except Exception:
432 set_cookie(self.response.headers, 'formvalues', dict(self.request.POST))
7ebb2cd @christopherb Cleaned up the style of the files some. Mostly standardizing on singl…
christopherb authored
433 self.redirect('/feedback/new/' + id)
d2c3dc7 @billsaysthis moved app-specific js to separate file
billsaysthis authored
434
9b632dd @progrium initial commit -- basic form, rough listing
progrium authored
435 def main():
436 application = webapp.WSGIApplication([
437 ('/', ApprovedHandler),
fcf7602 @progrium working approval process and ical view of approved events
progrium authored
438 ('/events\.(.+)', EventsHandler),
4c7da5d @billsaysthis added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
439 ('/all_future', AllFutureHandler),
d75579f @progrium minor updates here and there to bills contributions.
progrium authored
440 ('/past', PastHandler),
9b632dd @progrium initial commit -- basic form, rough listing
progrium authored
441 ('/pending', PendingHandler),
b4ea292 Handler to bug pending events
Brian Klug authored
442 ('/cronbugowners', CronBugOwnersHandler),
a82b43e @billsaysthis add myevents, pastevents code, refined list display on event page
billsaysthis authored
443 ('/myevents', MyEventsHandler),
9b632dd @progrium initial commit -- basic form, rough listing
progrium authored
444 ('/new', NewHandler),
ca8c7f2 @dustball Let edit events and refactor error handling
dustball authored
445 ('/edit/(\d+).*', EditHandler),
47a7f7a @progrium basic form validation, added end time, start of notifications, some f…
progrium authored
446 ('/event/(\d+).*', EventHandler),
2e08a66 @progrium cleaning things up and adding json representations for jon
progrium authored
447 ('/event/(\d+)\.json', EventHandler),
47a7f7a @progrium basic form validation, added end time, start of notifications, some f…
progrium authored
448 ('/expire', ExpireCron),
34d98f0 @billsaysthis moved feedback stuff to separate py file, small tweak to email notifi…
billsaysthis authored
449 ('/expiring', ExpireReminderCron),
219203b @dustball Cache better
dustball authored
450 ('/domaincache', DomainCacheCron),
f49797a @dustball Reminders 2.0
dustball authored
451 ('/reminder', ReminderCron),
4c7da5d @billsaysthis added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
452 ('/check_conflict', CheckConflict),
2ad290e @billsaysthis add logging model and obscure list view
billsaysthis authored
453 ('/logs', LogsHandler),
d2c3dc7 @billsaysthis moved app-specific js to separate file
billsaysthis authored
454 ('/feedback/new/(\d+).*', FeedbackHandler) ],debug=True)
9b632dd @progrium initial commit -- basic form, rough listing
progrium authored
455 util.run_wsgi_app(application)
456
f1997e4 @christopherb Made misc style fixes
christopherb authored
457
9b632dd @progrium initial commit -- basic form, rough listing
progrium authored
458 if __name__ == '__main__':
459 main()
Something went wrong with that request. Please try again.