Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 698 lines (641 sloc) 32.556 kb
8414350 William Stuart Lazar multiline for details and notes fields
billsaysthis authored
1 import cgi
9b632dd Jeff Lindsay 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 Jeff Lindsay basic form validation, added end time, start of notifications, some fixe...
progrium authored
4 from google.appengine.api import urlfetch, memcache, users, mail
5
c4d250e Brian Klug Python 2.7 upgrade & HRD compatibility
dustball authored
6 import json
7 import unicodedata
841fefb added meaningful descriptions to ical events.
Stig Hackvan authored
8 from icalendar import Calendar, Event as CalendarEvent
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 Matt Hancher Respect the local timezone (Pacific), and tidy up related imports.
mdhancher authored
11 from datetime import datetime, timedelta
fcf7602 Jeff Lindsay working approval process and ical view of approved events
progrium authored
12
2ad290e William Stuart Lazar add logging model and obscure list view
billsaysthis authored
13 from models import Event, Feedback, HDLog, ROOM_OPTIONS, PENDING_LIFETIME
c97598b Brian Klug Room Conflict Detection
dustball authored
14 from utils import username, human_username, set_cookie, local_today, is_phone_valid, UserRights, dojo
81a81e1 Jeff Lindsay adding errors for form validation, full notifications, and minor edits t...
progrium authored
15 from notices import *
7742592 Jeff Lindsay start of maintaining form state on errors
progrium authored
16
9f06c39 Casey Rodarmor Added RSS for upcoming events.
casey authored
17 import PyRSS2Gen
841fefb added meaningful descriptions to ical events.
Stig Hackvan authored
18 import re
7787223 restored an inscrutible but necessary pytz tzinfo quirk to the start/end...
Stig Hackvan authored
19 import pytz
fdcb013 Brian Klug HVAC auto-pilot
dustball authored
20 import keymaster
35f68f4 clean up extraneous whitespace
daniel watson authored
21
c4d250e Brian Klug Python 2.7 upgrade & HRD compatibility
dustball authored
22 webapp.template.register_template_library('templatefilters.templatefilters')
23
24 def slugify(str):
25 str = unicodedata.normalize('NFKD', str.lower()).encode('ascii','ignore')
26 return re.sub(r'\W+','-',str)
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
27
9f06c39 Casey Rodarmor Added RSS for upcoming events.
casey authored
28 def event_path(event):
29 return '/event/%s-%s' % (event.key().id(), slugify(event.name))
30
219203b Brian Klug Cache better
dustball authored
31 class DomainCacheCron(webapp.RequestHandler):
c4d250e Brian Klug Python 2.7 upgrade & HRD compatibility
dustball authored
32 def get(self):
219203b Brian Klug Cache better
dustball authored
33 noop = dojo('/groups/events',force=True)
34
35
f49797a Brian Klug Reminders 2.0
dustball authored
36 class ReminderCron(webapp.RequestHandler):
c4d250e Brian Klug Python 2.7 upgrade & HRD compatibility
dustball authored
37 def get(self):
f49797a Brian Klug Reminders 2.0
dustball authored
38 self.response.out.write("REMINDERS")
39 today = local_today()
40 # remind everyone 3 days in advance they need to show up
41 events = Event.all() \
42 .filter('status IN', ['approved']) \
43 .filter('reminded =', False) \
44 .filter('start_time <', today + timedelta(days=3))
5459516 William Stuart Lazar [#40] add not approved status and list view
billsaysthis authored
45 for event in events:
f49797a Brian Klug Reminders 2.0
dustball authored
46 self.response.out.write(event.name)
47 # only mail them if they created the event 2+ days ago
48 if event.created < today - timedelta(days=2):
49 schedule_reminder_email(event)
50 event.reminded = True
51 event.put()
52
53
e2b9558 Brent Tubbs Fixes issue 4. Changed to jqueryUI datepicker. Replaced jquery
btubbs authored
54 class ExpireCron(webapp.RequestHandler):
47a7f7a Jeff Lindsay basic form validation, added end time, start of notifications, some fixe...
progrium authored
55 def post(self):
56 # Expire events marked to expire today
b879063 Matt Hancher Respect the local timezone (Pacific), and tidy up related imports.
mdhancher authored
57 today = local_today()
47a7f7a Jeff Lindsay basic form validation, added end time, start of notifications, some fixe...
progrium authored
58 events = Event.all() \
59 .filter('status IN', ['pending', 'understaffed']) \
60 .filter('expired >=', today) \
61 .filter('expired <', today + timedelta(days=1))
62 for event in events:
63 event.expire()
64 notify_owner_expired(event)
5459516 William Stuart Lazar [#40] add not approved status and list view
billsaysthis authored
65
f1997e4 Christopher Biettchert Made misc style fixes
christopherb authored
66
47a7f7a Jeff Lindsay basic form validation, added end time, start of notifications, some fixe...
progrium authored
67 class ExpireReminderCron(webapp.RequestHandler):
68 def post(self):
69 # Find events expiring in 10 days to warn owner
b879063 Matt Hancher Respect the local timezone (Pacific), and tidy up related imports.
mdhancher authored
70 ten_days = local_today() + timedelta(days=10)
47a7f7a Jeff Lindsay basic form validation, added end time, start of notifications, some fixe...
progrium authored
71 events = Event.all() \
72 .filter('status IN', ['pending', 'understaffed']) \
73 .filter('expired >=', ten_days) \
74 .filter('expired <', ten_days + timedelta(days=1))
75 for event in events:
76 notify_owner_expiring(event)
77
841fefb added meaningful descriptions to ical events.
Stig Hackvan authored
78 class ExportHandler(webapp.RequestHandler):
fcf7602 Jeff Lindsay working approval process and ical view of approved events
progrium authored
79 def get(self, format):
9c331d0 Jeff Lindsay refactoring the export handler a bit
progrium authored
80 content_type, body = getattr(self, 'export_%s' % format)()
81 self.response.headers['content-type'] = content_type
82 self.response.out.write(body)
5459516 William Stuart Lazar [#40] add not approved status and list view
billsaysthis authored
83
9c331d0 Jeff Lindsay refactoring the export handler a bit
progrium authored
84 def export_json(self):
20a578c Brian Klug Reasonable limits
dustball authored
85 events = Event.get_recent_past_and_future()
9c331d0 Jeff Lindsay refactoring the export handler a bit
progrium authored
86 for k in self.request.GET:
87 if self.request.GET[k] and k in ['member']:
88 value = users.User(urllib.unquote(self.request.GET[k]))
89 else:
90 value = urllib.unquote(self.request.GET[k])
91 events = events.filter('%s =' % k, value)
92 events = map(lambda x: x.to_dict(summarize=True), events)
c4d250e Brian Klug Python 2.7 upgrade & HRD compatibility
dustball authored
93 return 'application/json', json.dumps(events)
5459516 William Stuart Lazar [#40] add not approved status and list view
billsaysthis authored
94
9c331d0 Jeff Lindsay refactoring the export handler a bit
progrium authored
95 def export_ics(self):
20a578c Brian Klug Reasonable limits
dustball authored
96 events = Event.get_recent_past_and_future()
841fefb added meaningful descriptions to ical events.
Stig Hackvan authored
97 url_base = 'http://' + self.request.headers.get('host', 'events.hackerdojo.com')
9c331d0 Jeff Lindsay refactoring the export handler a bit
progrium authored
98 cal = Calendar()
99 for event in events:
100 iev = CalendarEvent()
101 iev.add('summary', event.name if event.status == 'approved' else event.name + ' (%s)' % event.status.upper())
102 # make verbose description with empty fields where information is missing
103 ev_desc = '__Status: %s\n__Member: %s\n__Type: %s\n__Estimated size: %s\n__Info URL: %s\n__Fee: %s\n__Contact: %s, %s\n__Rooms: %s\n\n__Details: %s\n\n__Notes: %s' % (
5459516 William Stuart Lazar [#40] add not approved status and list view
billsaysthis authored
104 event.status,
105 event.owner(),
106 event.type,
107 event.estimated_size,
108 event.url,
109 event.fee,
110 event.contact_name,
111 event.contact_phone,
112 event.roomlist(),
113 event.details,
9c331d0 Jeff Lindsay refactoring the export handler a bit
progrium authored
114 event.notes)
115 # then delete the empty fields with a regex
116 ev_desc = re.sub(re.compile(r'^__.*?:[ ,]*$\n*',re.M),'',ev_desc)
117 ev_desc = re.sub(re.compile(r'^__',re.M),'',ev_desc)
118 ev_url = url_base + event_path(event)
119 iev.add('description', ev_desc + '\n--\n' + ev_url)
120 iev.add('url', ev_url)
121 if event.start_time:
122 iev.add('dtstart', event.start_time.replace(tzinfo=pytz.timezone('US/Pacific')))
123 if event.end_time:
124 iev.add('dtend', event.end_time.replace(tzinfo=pytz.timezone('US/Pacific')))
125 cal.add_component(iev)
126 return 'text/calendar', cal.as_string()
85d17af Brian Klug "Large Events" page and iCal feed
dustball authored
127
128 def export_large_ics(self):
20a578c Brian Klug Reasonable limits
dustball authored
129 events = Event.get_recent_past_and_future()
85d17af Brian Klug "Large Events" page and iCal feed
dustball authored
130 url_base = 'http://' + self.request.headers.get('host', 'events.hackerdojo.com')
131 cal = Calendar()
132 for event in events:
133 iev = CalendarEvent()
134 iev.add('summary', event.name + ' (%s)' % event.estimated_size)
135 # make verbose description with empty fields where information is missing
136 ev_desc = '__Status: %s\n__Member: %s\n__Type: %s\n__Estimated size: %s\n__Info URL: %s\n__Fee: %s\n__Contact: %s, %s\n__Rooms: %s\n\n__Details: %s\n\n__Notes: %s' % (
5459516 William Stuart Lazar [#40] add not approved status and list view
billsaysthis authored
137 event.status,
138 event.owner(),
139 event.type,
140 event.estimated_size,
141 event.url,
142 event.fee,
143 event.contact_name,
144 event.contact_phone,
145 event.roomlist(),
146 event.details,
85d17af Brian Klug "Large Events" page and iCal feed
dustball authored
147 event.notes)
148 # then delete the empty fields with a regex
149 ev_desc = re.sub(re.compile(r'^__.*?:[ ,]*$\n*',re.M),'',ev_desc)
150 ev_desc = re.sub(re.compile(r'^__',re.M),'',ev_desc)
151 ev_url = url_base + event_path(event)
152 iev.add('description', ev_desc + '\n--\n' + ev_url)
153 iev.add('url', ev_url)
154 if event.start_time:
155 iev.add('dtstart', event.start_time.replace(tzinfo=pytz.timezone('US/Pacific')))
156 if event.end_time:
157 iev.add('dtend', event.end_time.replace(tzinfo=pytz.timezone('US/Pacific')))
158 cal.add_component(iev)
159 return 'text/calendar', cal.as_string()
5459516 William Stuart Lazar [#40] add not approved status and list view
billsaysthis authored
160
9c331d0 Jeff Lindsay refactoring the export handler a bit
progrium authored
161 def export_rss(self):
162 url_base = 'http://' + self.request.headers.get('host', 'events.hackerdojo.com')
0fef364 Michelle Steigerwalt Removing events from RSS if they're cancelled (#51).
Yuffster authored
163 events = Event.get_recent_past_and_future_approved()
9c331d0 Jeff Lindsay refactoring the export handler a bit
progrium authored
164 rss = PyRSS2Gen.RSS2(
165 title = "Hacker Dojo Events Feed",
166 link = url_base,
167 description = "Upcoming events at the Hacker Dojo in Mountain View, CA",
168 lastBuildDate = datetime.now(),
169 items = [PyRSS2Gen.RSSItem(
15786c3 Mike Harris Include event date on RSS feed (Fixes #39)
mikeharris100 authored
170 title = "%s @ %s: %s" % (
171 event.start_time.strftime("%A, %B %d"),
35f68f4 clean up extraneous whitespace
daniel watson authored
172 event.start_time.strftime("%I:%M%p").lstrip("0"),
15786c3 Mike Harris Include event date on RSS feed (Fixes #39)
mikeharris100 authored
173 event.name),
9c331d0 Jeff Lindsay refactoring the export handler a bit
progrium authored
174 link = url_base + event_path(event),
175 description = event.details,
176 guid = url_base + event_path(event),
177 pubDate = event.updated,
178 ) for event in events]
179 )
180 return 'application/xml', rss.to_xml()
9b632dd Jeff Lindsay initial commit -- basic form, rough listing
progrium authored
181
f1997e4 Christopher Biettchert Made misc style fixes
christopherb authored
182
ca8c7f2 Brian Klug Let edit events and refactor error handling
dustball authored
183 class EditHandler(webapp.RequestHandler):
184 def get(self, id):
185 event = Event.get_by_id(int(id))
186 user = users.get_current_user()
736390e Brian Klug Bug fixes & UI
dustball authored
187 show_all_nav = user
ca8c7f2 Brian Klug Let edit events and refactor error handling
dustball authored
188 access_rights = UserRights(user, event)
189 if access_rights.can_edit:
5459516 William Stuart Lazar [#40] add not approved status and list view
billsaysthis authored
190 logout_url = users.create_logout_url('/')
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
191 rooms = ROOM_OPTIONS
192 hours = [1,2,3,4,5,6,7,8,9,10,11,12]
193 self.response.out.write(template.render('templates/edit.html', locals()))
ca8c7f2 Brian Klug Let edit events and refactor error handling
dustball authored
194 else:
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
195 self.response.out.write("Access denied")
ca8c7f2 Brian Klug Let edit events and refactor error handling
dustball authored
196
197 def post(self, id):
198 event = Event.get_by_id(int(id))
199 user = users.get_current_user()
200 access_rights = UserRights(user, event)
201 if access_rights.can_edit:
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
202 try:
8aa7c21 patch edit screen.. changed datepicker formatting to be cohesive.. fixed...
jonathan authored
203 start_time = datetime.strptime('%s %s:%s %s' % (
c6a3cce Mike Harris (For #12) Added basic ability to add/edit/view end *date* of an event
mikeharris100 authored
204 self.request.get('start_date'),
8aa7c21 patch edit screen.. changed datepicker formatting to be cohesive.. fixed...
jonathan authored
205 self.request.get('start_time_hour'),
206 self.request.get('start_time_minute'),
207 self.request.get('start_time_ampm')), '%m/%d/%Y %I:%M %p')
208 end_time = datetime.strptime('%s %s:%s %s' % (
c6a3cce Mike Harris (For #12) Added basic ability to add/edit/view end *date* of an event
mikeharris100 authored
209 self.request.get('end_date'),
8aa7c21 patch edit screen.. changed datepicker formatting to be cohesive.. fixed...
jonathan authored
210 self.request.get('end_time_hour'),
211 self.request.get('end_time_minute'),
212 self.request.get('end_time_ampm')), '%m/%d/%Y %I:%M %p')
21a4c09 Michelle Steigerwalt Support for setup and teardown times in base Event model.
Yuffster authored
213 conflicts = Event.check_conflict(
214 start_time,end_time,
215 self.request.get('setup'),
216 self.request.get('teardown'),
217 self.request.get_all('rooms'),
218 int(id)
219 )
c97598b Brian Klug Room Conflict Detection
dustball authored
220 if conflicts:
be77370 Michelle Steigerwalt Added check to ensure that start time and end time are not the same (#60...
Yuffster authored
221 raise ValueError('Room conflict detected')
7c9d8ee Brian Klug Make desc required field
dustball authored
222 if not self.request.get('details'):
223 raise ValueError('You must provide a description of the event')
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
224 if not self.request.get('estimated_size').isdigit():
225 raise ValueError('Estimated number of people must be a number')
226 if not int(self.request.get('estimated_size')) > 0:
227 raise ValueError('Estimated number of people must be greater then zero')
228 if ( self.request.get( 'contact_phone' ) and not is_phone_valid( self.request.get( 'contact_phone' ) ) ):
229 raise ValueError( 'Phone number does not appear to be valid' )
be77370 Michelle Steigerwalt Added check to ensure that start time and end time are not the same (#60...
Yuffster authored
230 if start_time == end_time:
231 raise ValueError('End time for the event cannot be the same as the start time')
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
232 else:
c4d250e Brian Klug Python 2.7 upgrade & HRD compatibility
dustball authored
233 log_desc = ""
8aa7c21 patch edit screen.. changed datepicker formatting to be cohesive.. fixed...
jonathan authored
234 previous_object = Event.get_by_id(int(id))
2b868a9 Michelle Steigerwalt Sending email notice when events change (#52).
Yuffster authored
235 event.status = 'pending'
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
236 event.name = self.request.get('name')
8aa7c21 patch edit screen.. changed datepicker formatting to be cohesive.. fixed...
jonathan authored
237 if (previous_object.name != event.name):
21a4c09 Michelle Steigerwalt Support for setup and teardown times in base Event model.
Yuffster authored
238 log_desc += "<strong>Title:</strong> " + previous_object.name + " to " + event.name + "<br />"
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
239 event.start_time = start_time
8aa7c21 patch edit screen.. changed datepicker formatting to be cohesive.. fixed...
jonathan authored
240 if (previous_object.start_time != event.start_time):
21a4c09 Michelle Steigerwalt Support for setup and teardown times in base Event model.
Yuffster authored
241 log_desc += "<strong>Start time:</strong> " + str(previous_object.start_time) + " to " + str(event.start_time) + "<br />"
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
242 event.end_time = end_time
8aa7c21 patch edit screen.. changed datepicker formatting to be cohesive.. fixed...
jonathan authored
243 if (previous_object.end_time != event.end_time):
21a4c09 Michelle Steigerwalt Support for setup and teardown times in base Event model.
Yuffster authored
244 log_desc += "<strong>End time:</strong> " + str(previous_object.end_time) + " to " + str(event.end_time) + "<br />"
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
245 event.estimated_size = cgi.escape(self.request.get('estimated_size'))
8aa7c21 patch edit screen.. changed datepicker formatting to be cohesive.. fixed...
jonathan authored
246 if (previous_object.estimated_size != event.estimated_size):
21a4c09 Michelle Steigerwalt Support for setup and teardown times in base Event model.
Yuffster authored
247 log_desc += "<strong>Est. size:</strong> " + previous_object.estimated_size + " to " + event.estimated_size + "<br />"
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
248 event.contact_name = cgi.escape(self.request.get('contact_name'))
8aa7c21 patch edit screen.. changed datepicker formatting to be cohesive.. fixed...
jonathan authored
249 if (previous_object.contact_name != event.contact_name):
21a4c09 Michelle Steigerwalt Support for setup and teardown times in base Event model.
Yuffster authored
250 log_desc += "<strong>Contact:</strong> " + previous_object.contact_name + " to " + event.contact_name + "<br />"
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
251 event.contact_phone = cgi.escape(self.request.get('contact_phone'))
8aa7c21 patch edit screen.. changed datepicker formatting to be cohesive.. fixed...
jonathan authored
252 if (previous_object.contact_phone != event.contact_phone):
21a4c09 Michelle Steigerwalt Support for setup and teardown times in base Event model.
Yuffster authored
253 log_desc += "<strong>Contact phone:</strong> " + previous_object.contact_phone + " to " + event.contact_phone + "<br />"
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
254 event.details = cgi.escape(self.request.get('details'))
8aa7c21 patch edit screen.. changed datepicker formatting to be cohesive.. fixed...
jonathan authored
255 if (previous_object.details != event.details):
21a4c09 Michelle Steigerwalt Support for setup and teardown times in base Event model.
Yuffster authored
256 log_desc += "<strong>Details:</strong> " + previous_object.details + " to " + event.details + "<br />"
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
257 event.url = cgi.escape(self.request.get('url'))
8aa7c21 patch edit screen.. changed datepicker formatting to be cohesive.. fixed...
jonathan authored
258 if (previous_object.url != event.url):
21a4c09 Michelle Steigerwalt Support for setup and teardown times in base Event model.
Yuffster authored
259 log_desc += "<strong>Url:</strong> " + previous_object.url + " to " + event.url + "<br />"
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
260 event.fee = cgi.escape(self.request.get('fee'))
8aa7c21 patch edit screen.. changed datepicker formatting to be cohesive.. fixed...
jonathan authored
261 if (previous_object.fee != event.fee):
21a4c09 Michelle Steigerwalt Support for setup and teardown times in base Event model.
Yuffster authored
262 log_desc += "<strong>Fee:</strong> " + previous_object.fee + " to " + event.fee + "<br />"
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
263 event.notes = cgi.escape(self.request.get('notes'))
8aa7c21 patch edit screen.. changed datepicker formatting to be cohesive.. fixed...
jonathan authored
264 if (previous_object.notes != event.notes):
21a4c09 Michelle Steigerwalt Support for setup and teardown times in base Event model.
Yuffster authored
265 log_desc += "<strong>Notes:</strong> " + previous_object.notes + " to " + event.notes + "<br />"
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
266 event.rooms = self.request.get_all('rooms')
8aa7c21 patch edit screen.. changed datepicker formatting to be cohesive.. fixed...
jonathan authored
267 if (previous_object.rooms != event.rooms):
21a4c09 Michelle Steigerwalt Support for setup and teardown times in base Event model.
Yuffster authored
268 log_desc += "<strong>Rooms changed</strong><br />"
269 log_desc += "<strong>Old room:</strong> " + previous_object.roomlist() + "<br />"
270 log_desc += "<strong>New room:</strong> " + event.roomlist() + "<br />"
a9eeaef setup and teardown times persist across edits
daniel watson authored
271 setup = cgi.escape(self.request.get('setup')) or 0
272 event.setup = int(setup)
273 if (previous_object.setup != event.setup):
21a4c09 Michelle Steigerwalt Support for setup and teardown times in base Event model.
Yuffster authored
274 log_desc += "<strong>Setup time changed</strong><br />"
a9eeaef setup and teardown times persist across edits
daniel watson authored
275 log_desc += "<strong>Old time:</strong> %s minutes<br/>" % previous_object.setup
276 log_desc += "<strong>New time:</strong> %s minutes<br/>" % event.setup
277 teardown = cgi.escape(self.request.get('teardown')) or 0
278 event.teardown = int(teardown)
279 if (previous_object.teardown != event.teardown):
21a4c09 Michelle Steigerwalt Support for setup and teardown times in base Event model.
Yuffster authored
280 log_desc += "<strong>Teardown time changed</strong><br />"
a9eeaef setup and teardown times persist across edits
daniel watson authored
281 log_desc += "<strong>Old time:</strong> %s minutes<br/>" % previous_object.teardown
282 log_desc += "<strong>New time:</strong> %s minutes<br/>" % event.teardown
c4d250e Brian Klug Python 2.7 upgrade & HRD compatibility
dustball authored
283 log = HDLog(event=event,description="Event edited<br />"+log_desc)
2ad290e William Stuart Lazar add logging model and obscure list view
billsaysthis authored
284 log.put()
c4d250e Brian Klug Python 2.7 upgrade & HRD compatibility
dustball authored
285 show_all_nav = user
286 access_rights = UserRights(user, event)
287 if access_rights.can_edit:
288 logout_url = users.create_logout_url('/')
289 rooms = ROOM_OPTIONS
290 hours = [1,2,3,4,5,6,7,8,9,10,11,12]
291 if log_desc:
292 edited = "<u>Saved changes:</u><br>"+log_desc
21a4c09 Michelle Steigerwalt Support for setup and teardown times in base Event model.
Yuffster authored
293 notify_event_change(event=event,modification=1)
eae6945 Michelle Steigerwalt Don't save event changes unless the user can actually edit the event.
Yuffster authored
294 event.put()
c7134b3 Michelle Steigerwalt Change event status to pending when the event is modified.
Yuffster authored
295 self.response.out.write(template.render('templates/edit.html', locals()))
c4d250e Brian Klug Python 2.7 upgrade & HRD compatibility
dustball authored
296 else:
297 self.response.out.write("Access denied")
5d18329 Michelle Steigerwalt Fixed exception on creating new events.
Yuffster authored
298 except NameError, e:
299 logging.log(e)
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
300 self.response.out.write(template.render('templates/error.html', locals()))
ca8c7f2 Brian Klug Let edit events and refactor error handling
dustball authored
301 else:
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
302 self.response.out.write("Access denied")
ca8c7f2 Brian Klug Let edit events and refactor error handling
dustball authored
303
304
9b632dd Jeff Lindsay initial commit -- basic form, rough listing
progrium authored
305 class EventHandler(webapp.RequestHandler):
306 def get(self, id):
5459516 William Stuart Lazar [#40] add not approved status and list view
billsaysthis authored
307
9b632dd Jeff Lindsay initial commit -- basic form, rough listing
progrium authored
308 event = Event.get_by_id(int(id))
2e08a66 Jeff Lindsay cleaning things up and adding json representations for jon
progrium authored
309 if self.request.path.endswith('json'):
310 self.response.headers['content-type'] = 'application/json'
c4d250e Brian Klug Python 2.7 upgrade & HRD compatibility
dustball authored
311 self.response.out.write(json.dumps(event.to_dict()))
fcf7602 Jeff Lindsay working approval process and ical view of approved events
progrium authored
312 else:
2e08a66 Jeff Lindsay cleaning things up and adding json representations for jon
progrium authored
313 user = users.get_current_user()
314 if user:
766e87c Christopher Biettchert Added UserRights class.
christopherb authored
315 access_rights = UserRights(user, event)
2e08a66 Jeff Lindsay cleaning things up and adding json representations for jon
progrium authored
316 logout_url = users.create_logout_url('/')
5459516 William Stuart Lazar [#40] add not approved status and list view
billsaysthis authored
317
2e08a66 Jeff Lindsay cleaning things up and adding json representations for jon
progrium authored
318 else:
319 login_url = users.create_login_url('/')
7ebb2cd Christopher Biettchert Cleaned up the style of the files some. Mostly standardizing on single q...
christopherb authored
320 event.details = db.Text(event.details.replace('\n','<br/>'))
736390e Brian Klug Bug fixes & UI
dustball authored
321 show_all_nav = user
7ebb2cd Christopher Biettchert Cleaned up the style of the files some. Mostly standardizing on single q...
christopherb authored
322 event.notes = db.Text(event.notes.replace('\n','<br/>'))
2e08a66 Jeff Lindsay cleaning things up and adding json representations for jon
progrium authored
323 self.response.out.write(template.render('templates/event.html', locals()))
e2b9558 Brent Tubbs Fixes issue 4. Changed to jqueryUI datepicker. Replaced jquery
btubbs authored
324
fcf7602 Jeff Lindsay working approval process and ical view of approved events
progrium authored
325 def post(self, id):
326 event = Event.get_by_id(int(id))
327 user = users.get_current_user()
766e87c Christopher Biettchert Added UserRights class.
christopherb authored
328 access_rights = UserRights(user, event)
329
fcf7602 Jeff Lindsay working approval process and ical view of approved events
progrium authored
330 state = self.request.get('state')
331 if state:
0eb5a92 William Stuart Lazar basic logging for all user-initiated post methods in place
billsaysthis authored
332 desc = ''
766e87c Christopher Biettchert Added UserRights class.
christopherb authored
333 if state.lower() == 'approve' and access_rights.can_approve:
fcf7602 Jeff Lindsay working approval process and ical view of approved events
progrium authored
334 event.approve()
0eb5a92 William Stuart Lazar basic logging for all user-initiated post methods in place
billsaysthis authored
335 desc = 'Approved event'
5459516 William Stuart Lazar [#40] add not approved status and list view
billsaysthis authored
336 if state.lower() == 'notapproved' and access_rights.can_not_approve:
337 event.not_approved()
338 desc = 'Event marked not approved'
5ef05d9 Brian Klug RSVP system
dustball authored
339 if state.lower() == 'rsvp' and user:
340 event.rsvp()
134bb40 Brian Klug New RSVP e-mail and fix issue #35
dustball authored
341 notify_owner_rsvp(event,user)
b84b533 Brian Klug Fix one more staff logic bomb
dustball authored
342 if state.lower() == 'staff' and access_rights.can_staff:
fcf7602 Jeff Lindsay working approval process and ical view of approved events
progrium authored
343 event.add_staff(user)
0eb5a92 William Stuart Lazar basic logging for all user-initiated post methods in place
billsaysthis authored
344 desc = 'Added self as staff'
766e87c Christopher Biettchert Added UserRights class.
christopherb authored
345 if state.lower() == 'unstaff' and access_rights.can_unstaff:
72849c2 William Stuart Lazar added unstaff event, including email notification if event becomes under...
billsaysthis authored
346 event.remove_staff(user)
0eb5a92 William Stuart Lazar basic logging for all user-initiated post methods in place
billsaysthis authored
347 desc = 'Removed self as staff'
f8ffd89 William Stuart Lazar refactor lists to use singe event partial, adds contact email link in he...
billsaysthis authored
348 if state.lower() == 'onhold' and access_rights.can_cancel:
349 event.on_hold()
350 desc = 'Put event on hold'
766e87c Christopher Biettchert Added UserRights class.
christopherb authored
351 if state.lower() == 'cancel' and access_rights.can_cancel:
fcf7602 Jeff Lindsay working approval process and ical view of approved events
progrium authored
352 event.cancel()
0eb5a92 William Stuart Lazar basic logging for all user-initiated post methods in place
billsaysthis authored
353 desc = 'Cancelled event'
a5aecd4 Michelle Steigerwalt Allow event creators to delete their event for the first thirty minutes ...
Yuffster authored
354 if state.lower() == 'delete' and access_rights.can_delete:
a67ac50 Matt Hancher Add a simple admin-only event delete and undelete.
mdhancher authored
355 event.delete()
0eb5a92 William Stuart Lazar basic logging for all user-initiated post methods in place
billsaysthis authored
356 desc = 'Deleted event'
8c2d718 Michelle Steigerwalt Fixed undelete functionality for event owner.
Yuffster authored
357 notify_deletion(event,user)
358 if state.lower() == 'undelete' and access_rights.can_undelete:
a67ac50 Matt Hancher Add a simple admin-only event delete and undelete.
mdhancher authored
359 event.undelete()
0eb5a92 William Stuart Lazar basic logging for all user-initiated post methods in place
billsaysthis authored
360 desc = 'Undeleted event'
766e87c Christopher Biettchert Added UserRights class.
christopherb authored
361 if state.lower() == 'expire' and access_rights.is_admin:
47a7f7a Jeff Lindsay basic form validation, added end time, start of notifications, some fixe...
progrium authored
362 event.expire()
0eb5a92 William Stuart Lazar basic logging for all user-initiated post methods in place
billsaysthis authored
363 desc = 'Expired event'
134bb40 Brian Klug New RSVP e-mail and fix issue #35
dustball authored
364 if event.status == 'approved' and state.lower() == 'approve':
47a7f7a Jeff Lindsay basic form validation, added end time, start of notifications, some fixe...
progrium authored
365 notify_owner_approved(event)
0eb5a92 William Stuart Lazar basic logging for all user-initiated post methods in place
billsaysthis authored
366 if desc != '':
367 log = HDLog(event=event,description=desc)
368 log.put()
c4d250e Brian Klug Python 2.7 upgrade & HRD compatibility
dustball authored
369 event.details = db.Text(event.details.replace('\n','<br/>'))
370 show_all_nav = user
371 event.notes = db.Text(event.notes.replace('\n','<br/>'))
372 self.response.out.write(template.render('templates/event.html', locals()))
f1997e4 Christopher Biettchert Made misc style fixes
christopherb authored
373
9b632dd Jeff Lindsay initial commit -- basic form, rough listing
progrium authored
374 class ApprovedHandler(webapp.RequestHandler):
375 def get(self):
376 user = users.get_current_user()
377 if user:
378 logout_url = users.create_logout_url('/')
379 else:
380 login_url = users.create_login_url('/')
b879063 Matt Hancher Respect the local timezone (Pacific), and tidy up related imports.
mdhancher authored
381 today = local_today()
736390e Brian Klug Bug fixes & UI
dustball authored
382 show_all_nav = user
411c89f Mike Harris (For #12) Show every day of multiple day events
mikeharris100 authored
383 events = Event.get_approved_list_with_multiday()
9b632dd Jeff Lindsay initial commit -- basic form, rough listing
progrium authored
384 tomorrow = today + timedelta(days=1)
d63161a Add widget mode
Brian Klug authored
385 whichbase = 'base.html'
386 if self.request.get('base'):
7ebb2cd Christopher Biettchert Cleaned up the style of the files some. Mostly standardizing on single q...
christopherb authored
387 whichbase = self.request.get('base') + '.html'
9b632dd Jeff Lindsay initial commit -- basic form, rough listing
progrium authored
388 self.response.out.write(template.render('templates/approved.html', locals()))
389
f1997e4 Christopher Biettchert Made misc style fixes
christopherb authored
390
a82b43e William Stuart Lazar add myevents, pastevents code, refined list display on event page
billsaysthis authored
391 class MyEventsHandler(webapp.RequestHandler):
392 @util.login_required
393 def get(self):
394 user = users.get_current_user()
395 if user:
396 logout_url = users.create_logout_url('/')
397 else:
398 login_url = users.create_login_url('/')
399 events = Event.all().filter('member = ', user).order('start_time')
736390e Brian Klug Bug fixes & UI
dustball authored
400 show_all_nav = user
b879063 Matt Hancher Respect the local timezone (Pacific), and tidy up related imports.
mdhancher authored
401 today = local_today()
a82b43e William Stuart Lazar add myevents, pastevents code, refined list display on event page
billsaysthis authored
402 tomorrow = today + timedelta(days=1)
403 self.response.out.write(template.render('templates/myevents.html', locals()))
404
f1997e4 Christopher Biettchert Made misc style fixes
christopherb authored
405
a82b43e William Stuart Lazar add myevents, pastevents code, refined list display on event page
billsaysthis authored
406 class PastHandler(webapp.RequestHandler):
407 def get(self):
408 user = users.get_current_user()
409 if user:
410 logout_url = users.create_logout_url('/')
411 else:
412 login_url = users.create_login_url('/')
b879063 Matt Hancher Respect the local timezone (Pacific), and tidy up related imports.
mdhancher authored
413 today = local_today()
736390e Brian Klug Bug fixes & UI
dustball authored
414 show_all_nav = user
d75579f Jeff Lindsay minor updates here and there to bills contributions.
progrium authored
415 events = Event.all().filter('start_time < ', today).order('-start_time')
a82b43e William Stuart Lazar add myevents, pastevents code, refined list display on event page
billsaysthis authored
416 self.response.out.write(template.render('templates/past.html', locals()))
417
f1997e4 Christopher Biettchert Made misc style fixes
christopherb authored
418
5459516 William Stuart Lazar [#40] add not approved status and list view
billsaysthis authored
419 class NotApprovedHandler(webapp.RequestHandler):
420 def get(self):
421 user = users.get_current_user()
422 if user:
423 logout_url = users.create_logout_url('/')
424 else:
425 login_url = users.create_login_url('/')
426 today = local_today()
427 show_all_nav = user
428 events = Event.get_recent_not_approved_list()
429 self.response.out.write(template.render('templates/not_approved.html', locals()))
430
431
b4ea292 Handler to bug pending events
Brian Klug authored
432 class CronBugOwnersHandler(webapp.RequestHandler):
433 def get(self):
434 events = Event.get_pending_list()
435 for e in events:
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
436 bug_owner_pending(e)
437
438
439 class AllFutureHandler(webapp.RequestHandler):
440 def get(self):
441 user = users.get_current_user()
442 if user:
443 logout_url = users.create_logout_url('/')
444 else:
445 login_url = users.create_login_url('/')
736390e Brian Klug Bug fixes & UI
dustball authored
446 show_all_nav = user
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
447 events = Event.get_all_future_list()
448 today = local_today()
449 tomorrow = today + timedelta(days=1)
450 self.response.out.write(template.render('templates/all_future.html', locals()))
b4ea292 Handler to bug pending events
Brian Klug authored
451
85d17af Brian Klug "Large Events" page and iCal feed
dustball authored
452 class LargeHandler(webapp.RequestHandler):
453 def get(self):
454 user = users.get_current_user()
455 if user:
456 logout_url = users.create_logout_url('/')
457 else:
458 login_url = users.create_login_url('/')
459 show_all_nav = user
460 events = Event.get_large_list()
461 today = local_today()
462 tomorrow = today + timedelta(days=1)
463 self.response.out.write(template.render('templates/large.html', locals()))
464
f1997e4 Christopher Biettchert Made misc style fixes
christopherb authored
465
9b632dd Jeff Lindsay initial commit -- basic form, rough listing
progrium authored
466 class PendingHandler(webapp.RequestHandler):
467 def get(self):
468 user = users.get_current_user()
469 if user:
470 logout_url = users.create_logout_url('/')
471 else:
472 login_url = users.create_login_url('/')
47a7f7a Jeff Lindsay basic form validation, added end time, start of notifications, some fixe...
progrium authored
473 events = Event.get_pending_list()
736390e Brian Klug Bug fixes & UI
dustball authored
474 show_all_nav = user
b879063 Matt Hancher Respect the local timezone (Pacific), and tidy up related imports.
mdhancher authored
475 today = local_today()
9b632dd Jeff Lindsay initial commit -- basic form, rough listing
progrium authored
476 tomorrow = today + timedelta(days=1)
477 self.response.out.write(template.render('templates/pending.html', locals()))
478
f1997e4 Christopher Biettchert Made misc style fixes
christopherb authored
479
9b632dd Jeff Lindsay initial commit -- basic form, rough listing
progrium authored
480 class NewHandler(webapp.RequestHandler):
fcf7602 Jeff Lindsay working approval process and ical view of approved events
progrium authored
481 @util.login_required
9b632dd Jeff Lindsay initial commit -- basic form, rough listing
progrium authored
482 def get(self):
483 user = users.get_current_user()
4d85afa Brian Klug Remove staffing requirement and make members more responsible
dustball authored
484 human = human_username(user)
9b632dd Jeff Lindsay initial commit -- basic form, rough listing
progrium authored
485 if user:
486 logout_url = users.create_logout_url('/')
487 else:
488 login_url = users.create_login_url('/')
489 rooms = ROOM_OPTIONS
cb7a9d1 pull in the rules live and memcache them for 1 day on new and confirm ac...
jonathan authored
490 rules = memcache.get("rules")
491 if(rules is None):
f434ff5 Brian Klug Send e-mails to a better place on dev
dustball authored
492 try:
493 rules = urlfetch.fetch("http://wiki.hackerdojo.com/api_v2/op/GetPage/page/Event+Policies/_type/html", "GET").content
494 memcache.add("rules", rules, 86400)
495 except Exception, e:
496 rules = "Error fetching rules. Please report this error to internal-dev@hackerdojo.com."
9b632dd Jeff Lindsay initial commit -- basic form, rough listing
progrium authored
497 self.response.out.write(template.render('templates/new.html', locals()))
e2b9558 Brent Tubbs Fixes issue 4. Changed to jqueryUI datepicker. Replaced jquery
btubbs authored
498
f1997e4 Christopher Biettchert Made misc style fixes
christopherb authored
499
9b632dd Jeff Lindsay initial commit -- basic form, rough listing
progrium authored
500 def post(self):
501 user = users.get_current_user()
7742592 Jeff Lindsay start of maintaining form state on errors
progrium authored
502 try:
7ebb2cd Christopher Biettchert Cleaned up the style of the files some. Mostly standardizing on single q...
christopherb authored
503 start_time = datetime.strptime('%s %s:%s %s' % (
c6a3cce Mike Harris (For #12) Added basic ability to add/edit/view end *date* of an event
mikeharris100 authored
504 self.request.get('start_date'),
7742592 Jeff Lindsay start of maintaining form state on errors
progrium authored
505 self.request.get('start_time_hour'),
506 self.request.get('start_time_minute'),
7ebb2cd Christopher Biettchert Cleaned up the style of the files some. Mostly standardizing on single q...
christopherb authored
507 self.request.get('start_time_ampm')), '%m/%d/%Y %I:%M %p')
508 end_time = datetime.strptime('%s %s:%s %s' % (
c6a3cce Mike Harris (For #12) Added basic ability to add/edit/view end *date* of an event
mikeharris100 authored
509 self.request.get('end_date'),
7742592 Jeff Lindsay start of maintaining form state on errors
progrium authored
510 self.request.get('end_time_hour'),
511 self.request.get('end_time_minute'),
7ebb2cd Christopher Biettchert Cleaned up the style of the files some. Mostly standardizing on single q...
christopherb authored
512 self.request.get('end_time_ampm')), '%m/%d/%Y %I:%M %p')
21a4c09 Michelle Steigerwalt Support for setup and teardown times in base Event model.
Yuffster authored
513 conflicts = Event.check_conflict(
514 start_time,end_time,
515 self.request.get('setup'),
516 self.request.get('teardown'),
5d18329 Michelle Steigerwalt Fixed exception on creating new events.
Yuffster authored
517 self.request.get_all('rooms')
21a4c09 Michelle Steigerwalt Support for setup and teardown times in base Event model.
Yuffster authored
518 )
c97598b Brian Klug Room Conflict Detection
dustball authored
519 if conflicts:
81f76e6 Brian Klug Better error message for deck/savannah conflicts
dustball authored
520 if "Deck" in self.request.get_all('rooms') or "Savanna" in self.request.get_all('rooms'):
521 raise ValueError('Room conflict detected <small>(Note: Deck &amp; Savanna share the same area, two events cannot take place at the same time in these rooms.)</small>')
522 else:
523 raise ValueError('Room conflict detected')
7c9d8ee Brian Klug Make desc required field
dustball authored
524 if not self.request.get('details'):
525 raise ValueError('You must provide a description of the event')
8615877 Fix validation for event size
Brian Klug authored
526 if not self.request.get('estimated_size').isdigit():
7ebb2cd Christopher Biettchert Cleaned up the style of the files some. Mostly standardizing on single q...
christopherb authored
527 raise ValueError('Estimated number of people must be a number')
8615877 Fix validation for event size
Brian Klug authored
528 if not int(self.request.get('estimated_size')) > 0:
7ebb2cd Christopher Biettchert Cleaned up the style of the files some. Mostly standardizing on single q...
christopherb authored
529 raise ValueError('Estimated number of people must be greater then zero')
7742592 Jeff Lindsay start of maintaining form state on errors
progrium authored
530 if (end_time-start_time).days < 0:
7ebb2cd Christopher Biettchert Cleaned up the style of the files some. Mostly standardizing on single q...
christopherb authored
531 raise ValueError('End time must be after start time')
a244c65 Brian Klug Bug fixes
dustball authored
532 if ( self.request.get( 'contact_phone' ) and not is_phone_valid( self.request.get( 'contact_phone' ) ) ):
7ebb2cd Christopher Biettchert Cleaned up the style of the files some. Mostly standardizing on single q...
christopherb authored
533 raise ValueError( 'Phone number does not appear to be valid' )
7742592 Jeff Lindsay start of maintaining form state on errors
progrium authored
534 else:
535 event = Event(
ca3c6dd Escaped additional fields that could be used for XSS
Christopher Biettchert authored
536 name = cgi.escape(self.request.get('name')),
7742592 Jeff Lindsay start of maintaining form state on errors
progrium authored
537 start_time = start_time,
538 end_time = end_time,
ca3c6dd Escaped additional fields that could be used for XSS
Christopher Biettchert authored
539 type = cgi.escape(self.request.get('type')),
540 estimated_size = cgi.escape(self.request.get('estimated_size')),
541 contact_name = cgi.escape(self.request.get('contact_name')),
542 contact_phone = cgi.escape(self.request.get('contact_phone')),
8414350 William Stuart Lazar multiline for details and notes fields
billsaysthis authored
543 details = cgi.escape(self.request.get('details')),
ca3c6dd Escaped additional fields that could be used for XSS
Christopher Biettchert authored
544 url = cgi.escape(self.request.get('url')),
545 fee = cgi.escape(self.request.get('fee')),
8414350 William Stuart Lazar multiline for details and notes fields
billsaysthis authored
546 notes = cgi.escape(self.request.get('notes')),
7ebb2cd Christopher Biettchert Cleaned up the style of the files some. Mostly standardizing on single q...
christopherb authored
547 rooms = self.request.get_all('rooms'),
b879063 Matt Hancher Respect the local timezone (Pacific), and tidy up related imports.
mdhancher authored
548 expired = local_today() + timedelta(days=PENDING_LIFETIME), # Set expected expiration date
a9eeaef setup and teardown times persist across edits
daniel watson authored
549 setup = int(self.request.get('setup') or 0),
550 teardown = int(self.request.get('teardown') or 0)
21a4c09 Michelle Steigerwalt Support for setup and teardown times in base Event model.
Yuffster authored
551 )
7742592 Jeff Lindsay start of maintaining form state on errors
progrium authored
552 event.put()
0eb5a92 William Stuart Lazar basic logging for all user-initiated post methods in place
billsaysthis authored
553 log = HDLog(event=event,description="Created new event")
554 log.put()
7742592 Jeff Lindsay start of maintaining form state on errors
progrium authored
555 notify_owner_confirmation(event)
2b868a9 Michelle Steigerwalt Sending email notice when events change (#52).
Yuffster authored
556 notify_event_change(event)
81a81e1 Jeff Lindsay adding errors for form validation, full notifications, and minor edits t...
progrium authored
557 set_cookie(self.response.headers, 'formvalues', None)
c4d250e Brian Klug Python 2.7 upgrade & HRD compatibility
dustball authored
558
559 rules = memcache.get("rules")
560 if(rules is None):
561 try:
562 rules = urlfetch.fetch("http://wiki.hackerdojo.com/api_v2/op/GetPage/page/Event+Policies/_type/html", "GET").content
563 memcache.add("rules", rules, 86400)
564 except Exception, e:
565 rules = "Error fetching rules. Please report this error to internal-dev@hackerdojo.com."
566 self.response.out.write(template.render('templates/confirmation.html', locals()))
567
5459516 William Stuart Lazar [#40] add not approved status and list view
billsaysthis authored
568
5d18329 Michelle Steigerwalt Fixed exception on creating new events.
Yuffster authored
569 except ValueError, e:
81a81e1 Jeff Lindsay adding errors for form validation, full notifications, and minor edits t...
progrium authored
570 message = str(e)
571 if 'match format' in message:
7ebb2cd Christopher Biettchert Cleaned up the style of the files some. Mostly standardizing on single q...
christopherb authored
572 message = 'Date is required.'
81a81e1 Jeff Lindsay adding errors for form validation, full notifications, and minor edits t...
progrium authored
573 if message.startswith('Property'):
574 message = message[9:].replace('_', ' ').capitalize()
ca8c7f2 Brian Klug Let edit events and refactor error handling
dustball authored
575 # This is NOT a reliable way to handle erorrs
576 #set_cookie(self.response.headers, 'formerror', message)
577 #set_cookie(self.response.headers, 'formvalues', dict(self.request.POST))
578 #self.redirect('/new')
579 error = message
580 self.response.out.write(template.render('templates/error.html', locals()))
87868cf issue 11 add a confirmation page
jonathan authored
581
c4d250e Brian Klug Python 2.7 upgrade & HRD compatibility
dustball authored
582 class SavingHandler(webapp.RequestHandler):
583 def get(self, target):
584 self.response.out.write(template.render('templates/saving.html', locals()))
585
87868cf issue 11 add a confirmation page
jonathan authored
586 class ConfirmationHandler(webapp.RequestHandler):
587 def get(self, id):
588 event = Event.get_by_id(int(id))
cb7a9d1 pull in the rules live and memcache them for 1 day on new and confirm ac...
jonathan authored
589 rules = memcache.get("rules")
590 if(rules is None):
f434ff5 Brian Klug Send e-mails to a better place on dev
dustball authored
591 try:
592 rules = urlfetch.fetch("http://wiki.hackerdojo.com/api_v2/op/GetPage/page/Event+Policies/_type/html", "GET").content
593 memcache.add("rules", rules, 86400)
594 except Exception, e:
595 rules = "Error fetching rules. Please report this error to internal-dev@hackerdojo.com."
b47158d Issue 36 Need to use deffered mail sends everywhere
Abraham Erki authored
596 user = users.get_current_user()
597 logout_url = users.create_logout_url('/')
87868cf issue 11 add a confirmation page
jonathan authored
598 self.response.out.write(template.render('templates/confirmation.html', locals()))
599
2ad290e William Stuart Lazar add logging model and obscure list view
billsaysthis authored
600 class LogsHandler(webapp.RequestHandler):
601 @util.login_required
602 def get(self):
603 user = users.get_current_user()
604 logs = HDLog.get_logs_list()
605 if user:
606 logout_url = users.create_logout_url('/')
607 else:
608 login_url = users.create_login_url('/')
736390e Brian Klug Bug fixes & UI
dustball authored
609 show_all_nav = user
2ad290e William Stuart Lazar add logging model and obscure list view
billsaysthis authored
610 self.response.out.write(template.render('templates/logs.html', locals()))
611
d2c3dc7 William Stuart Lazar moved app-specific js to separate file
billsaysthis authored
612 class FeedbackHandler(webapp.RequestHandler):
613 @util.login_required
7ebb2cd Christopher Biettchert Cleaned up the style of the files some. Mostly standardizing on single q...
christopherb authored
614 def get(self, id):
d2c3dc7 William Stuart Lazar moved app-specific js to separate file
billsaysthis authored
615 user = users.get_current_user()
7ebb2cd Christopher Biettchert Cleaned up the style of the files some. Mostly standardizing on single q...
christopherb authored
616 event = Event.get_by_id(int(id))
d2c3dc7 William Stuart Lazar moved app-specific js to separate file
billsaysthis authored
617 if user:
618 logout_url = users.create_logout_url('/')
619 else:
620 login_url = users.create_login_url('/')
621 self.response.out.write(template.render('templates/feedback.html', locals()))
622
7ebb2cd Christopher Biettchert Cleaned up the style of the files some. Mostly standardizing on single q...
christopherb authored
623 def post(self, id):
d2c3dc7 William Stuart Lazar moved app-specific js to separate file
billsaysthis authored
624 user = users.get_current_user()
7ebb2cd Christopher Biettchert Cleaned up the style of the files some. Mostly standardizing on single q...
christopherb authored
625 event = Event.get_by_id(int(id))
8c52522 William Stuart Lazar small tweak to how feedbacks displayed in event page
billsaysthis authored
626 try:
627 if self.request.get('rating'):
628 feedback = Feedback(
629 event = event,
630 rating = int(self.request.get('rating')),
ca3c6dd Escaped additional fields that could be used for XSS
Christopher Biettchert authored
631 comment = cgi.escape(self.request.get('comment')))
8c52522 William Stuart Lazar small tweak to how feedbacks displayed in event page
billsaysthis authored
632 feedback.put()
0eb5a92 William Stuart Lazar basic logging for all user-initiated post methods in place
billsaysthis authored
633 log = HDLog(event=event,description="Posted feedback")
634 log.put()
8c52522 William Stuart Lazar small tweak to how feedbacks displayed in event page
billsaysthis authored
635 self.redirect('/event/%s-%s' % (event.key().id(), slugify(event.name)))
636 else:
7ebb2cd Christopher Biettchert Cleaned up the style of the files some. Mostly standardizing on single q...
christopherb authored
637 raise ValueError('Please select a rating')
8c52522 William Stuart Lazar small tweak to how feedbacks displayed in event page
billsaysthis authored
638 except Exception:
639 set_cookie(self.response.headers, 'formvalues', dict(self.request.POST))
7ebb2cd Christopher Biettchert Cleaned up the style of the files some. Mostly standardizing on single q...
christopherb authored
640 self.redirect('/feedback/new/' + id)
d2c3dc7 William Stuart Lazar moved app-specific js to separate file
billsaysthis authored
641
fdcb013 Brian Klug HVAC auto-pilot
dustball authored
642 class TempHandler(webapp.RequestHandler):
643 def get(self):
35f68f4 clean up extraneous whitespace
daniel watson authored
644 units = {"AC1":"EDD9A758", "AC2":"B65D8121", "AC3":"0BA20EDC", "AC5":"47718E38"}
8fd9cd7 Brian Klug Bug fixes & code readability
dustball authored
645 modes = ["Off","Heat","Cool"]
646 master = units["AC3"]
fdcb013 Brian Klug HVAC auto-pilot
dustball authored
647 key = keymaster.get('thermkey')
648 url = "https://api.bayweb.com/v2/?id="+master+"&key="+key+"&action=data"
649 result = urlfetch.fetch(url)
650 if result.status_code == 200:
c4d250e Brian Klug Python 2.7 upgrade & HRD compatibility
dustball authored
651 thdata = json.loads(result.content)
8fd9cd7 Brian Klug Bug fixes & code readability
dustball authored
652 inside_air_temp = thdata['iat']
653 mode = thdata['mode']
654 if inside_air_temp <= 66 and modes[mode] == "Cool":
655 for thermostat in units:
656 url = "https://api.bayweb.com/v2/?id="+units[thermostat]+"&key="+key+"&action=set&heat_sp=69&mode="+str(modes.index("Heat"))
657 result = urlfetch.fetch(url)
658 notify_hvac_change(inside_air_temp,"Heat")
659 if inside_air_temp >= 75 and modes[mode] == "Heat":
660 for thermostat in units:
661 url = "https://api.bayweb.com/v2/?id="+units[thermostat]+"&key="+key+"&action=set&cool_sp=71&mode="+str(modes.index("Cool"))
662 result = urlfetch.fetch(url)
663 notify_hvac_change(inside_air_temp,"Cold")
664 self.response.out.write("200 OK")
665 else:
666 notify_hvac_change(result.status_code,"ERROR connecting to BayWeb API")
667 self.response.out.write("500 Internal Server Error")
35f68f4 clean up extraneous whitespace
daniel watson authored
668
fdcb013 Brian Klug HVAC auto-pilot
dustball authored
669
c4d250e Brian Klug Python 2.7 upgrade & HRD compatibility
dustball authored
670 app = webapp.WSGIApplication([
9b632dd Jeff Lindsay initial commit -- basic form, rough listing
progrium authored
671 ('/', ApprovedHandler),
4c7da5d William Stuart Lazar added func to ensure word 'in' only shown when rooms are assigned
billsaysthis authored
672 ('/all_future', AllFutureHandler),
85d17af Brian Klug "Large Events" page and iCal feed
dustball authored
673 ('/large', LargeHandler),
9b632dd Jeff Lindsay initial commit -- basic form, rough listing
progrium authored
674 ('/pending', PendingHandler),
841fefb added meaningful descriptions to ical events.
Stig Hackvan authored
675 ('/past', PastHandler),
fdcb013 Brian Klug HVAC auto-pilot
dustball authored
676 ('/temperature', TempHandler),
c4d250e Brian Klug Python 2.7 upgrade & HRD compatibility
dustball authored
677 #('/cronbugowners', CronBugOwnersHandler),
a82b43e William Stuart Lazar add myevents, pastevents code, refined list display on event page
billsaysthis authored
678 ('/myevents', MyEventsHandler),
5459516 William Stuart Lazar [#40] add not approved status and list view
billsaysthis authored
679 ('/not_approved', NotApprovedHandler),
9b632dd Jeff Lindsay initial commit -- basic form, rough listing
progrium authored
680 ('/new', NewHandler),
c4d250e Brian Klug Python 2.7 upgrade & HRD compatibility
dustball authored
681 ('/saving/(.*)', SavingHandler),
87868cf issue 11 add a confirmation page
jonathan authored
682 ('/confirm/(\d+).*', ConfirmationHandler),
ca8c7f2 Brian Klug Let edit events and refactor error handling
dustball authored
683 ('/edit/(\d+).*', EditHandler),
841fefb added meaningful descriptions to ical events.
Stig Hackvan authored
684 # single event views
47a7f7a Jeff Lindsay basic form validation, added end time, start of notifications, some fixe...
progrium authored
685 ('/event/(\d+).*', EventHandler),
2e08a66 Jeff Lindsay cleaning things up and adding json representations for jon
progrium authored
686 ('/event/(\d+)\.json', EventHandler),
841fefb added meaningful descriptions to ical events.
Stig Hackvan authored
687 # various export methods -- events.{json,rss,ics}
688 ('/events\.(.+)', ExportHandler),
689 #
690 # CRON tasks
c4d250e Brian Klug Python 2.7 upgrade & HRD compatibility
dustball authored
691 #('/expire', ExpireCron),
692 #('/expiring', ExpireReminderCron),
5459516 William Stuart Lazar [#40] add not approved status and list view
billsaysthis authored
693 ('/domaincache', DomainCacheCron),
6519cb8 Brian Klug Safe event details
dustball authored
694 #('/reminder', ReminderCron),
841fefb added meaningful descriptions to ical events.
Stig Hackvan authored
695 #
2ad290e William Stuart Lazar add logging model and obscure list view
billsaysthis authored
696 ('/logs', LogsHandler),
d2c3dc7 William Stuart Lazar moved app-specific js to separate file
billsaysthis authored
697 ('/feedback/new/(\d+).*', FeedbackHandler) ],debug=True)
Something went wrong with that request. Please try again.