Permalink
Browse files

moved app-specific js to separate file

  • Loading branch information...
1 parent fe8f0c4 commit d2c3dc757c89a6eb567c92a76568e0255087a084 @billsaysthis billsaysthis committed Apr 19, 2010
Showing with 41 additions and 106 deletions.
  1. +0 −64 feedback_handlers.py
  2. +23 −24 main.py
  3. +11 −0 static/js/hd-events.js
  4. +1 −12 templates/base.html
  5. +2 −2 templates/feedback.html
  6. +3 −3 templates/new_feedback.html
  7. +1 −1 templates/past.html
View
@@ -1,64 +0,0 @@
-from google.appengine.ext import webapp, db
-from google.appengine.ext.webapp import util, template
-from google.appengine.api import urlfetch, memcache, users, mail
-
-from django.utils import simplejson
-from django.template.defaultfilters import slugify
-import logging, urllib
-from models import Event, Feedback
-
-from datetime import datetime, timedelta, time, date
-
-class FeedbacksHandler(webapp.RequestHandler):
- def get(self, format):
- if format == 'ics':
- events = Event.all().filter('status IN', ['approved', 'canceled']).order('start_time')
- cal = Calendar()
- for event in events:
- cal.add_component(event.to_ical())
- self.response.headers['content-type'] = 'text/calendar'
- self.response.out.write(cal.as_string())
-
-class FeedbackHandler(webapp.RequestHandler):
- def get(self, id):
- feedback = Feedback.get_by_id(int(id))
- user = users.get_current_user()
- if user:
- is_admin = username(user) in dojo('/groups/events')
- is_staff = username(user) in dojo('/groups/staff')
- logout_url = users.create_logout_url('/')
- else:
- login_url = users.create_login_url('/')
- self.response.out.write(template.render('templates/event.html', locals()))
-
- def post(self, id):
- feedback = Feedback.get_by_id(int(id))
- user = users.get_current_user()
- is_admin = username(user) in dojo('/groups/events')
- is_staff = username(user) in dojo('/groups/staff')
- # self.redirect('/feedback/%s-%s' % (feedback.key().id(), slugify(feedback.name)))
-
-class NewFeedbackHandler(webapp.RequestHandler):
- @util.login_required
- def get(self, id):
- user = users.get_current_user()
- event = Event.get_by_id(int(id))
- if user:
- logout_url = users.create_logout_url('/')
- else:
- login_url = users.create_login_url('/')
- past_events = db.GqlQuery("SELECT * from Event WHERE end_time < :1", datetime.today())
- self.response.out.write(template.render('templates/new_feedback.html', locals()))
-
- def post(self,id):
- user = users.get_current_user()
- feedback = Feedback(
- submitter = user,
- event = Event.get_by_id(int(id)),
- rating = int(self.request.get('rating')),
- comment = self.request.get('comment'),
- submitted = datetime.today()
- )
- feedback.put()
- self.redirect('/events')
-
View
47 main.py
@@ -11,7 +11,6 @@
from pytz import timezone
import pytz
from models import Event, Feedback, ROOM_OPTIONS, GUESTS_PER_STAFF, PENDING_LIFETIME, FROM_ADDRESS
-import feedback_handlers
# Hacker Dojo Domain API helper with caching
def dojo(path):
@@ -185,28 +184,6 @@ def get(self):
is_admin = username(user) in dojo('/groups/events')
self.response.out.write(template.render('templates/pending.html', locals()))
-class FeedbackHandler(webapp.RequestHandler):
- @util.login_required
- def get(self, event_id):
- user = users.get_current_user()
- event = Event.get_by_id(int(event_id))
- if user:
- logout_url = users.create_logout_url('/')
- else:
- login_url = users.create_login_url('/')
- self.response.out.write(template.render('templates/feedback.html', locals()))
-
- def post(self, event_id):
- user = users.get_current_user()
- event = Event.get_by_id(int(event_id))
- feedback = Feedback(
- event = event,
- rating = int(self.request.get('rating')),
- comment = self.request.get('comment'))
- feedback.put()
- self.redirect('/event/%s-%s' % (event.key().id(), slugify(event.name)))
-
-
class NewHandler(webapp.RequestHandler):
@util.login_required
def get(self):
@@ -259,6 +236,28 @@ def post(self):
set_cookie(self.response.headers, 'formvalues', dict(self.request.POST))
self.redirect('/new')
+
+class FeedbackHandler(webapp.RequestHandler):
+ @util.login_required
+ def get(self, event_id):
+ user = users.get_current_user()
+ event = Event.get_by_id(int(event_id))
+ if user:
+ logout_url = users.create_logout_url('/')
+ else:
+ login_url = users.create_login_url('/')
+ self.response.out.write(template.render('templates/feedback.html', locals()))
+
+ def post(self, event_id):
+ user = users.get_current_user()
+ event = Event.get_by_id(int(event_id))
+ feedback = Feedback(
+ event = event,
+ rating = int(self.request.get('rating')),
+ comment = self.request.get('comment'))
+ feedback.put()
+ self.redirect('/event/%s-%s' % (event.key().id(), slugify(event.name)))
+
def main():
application = webapp.WSGIApplication([
('/', ApprovedHandler),
@@ -270,7 +269,7 @@ def main():
('/event/(\d+).*', EventHandler),
('/expire', ExpireCron),
('/expiring', ExpireReminderCron),
- ('/feedback/new/(\d+).*', feedback_handlers.NewFeedbackHandler) ],debug=True)
+ ('/feedback/new/(\d+).*', FeedbackHandler) ],debug=True)
util.run_wsgi_app(application)
if __name__ == '__main__':
View
@@ -0,0 +1,11 @@
+var rounder = function(elem, sz, allBrowsers) {
+ // rounded corners JS, handles IE7, 8 too:
+ DD_roundies.addRule(elem, sz.toString()+'px', allBrowsers);
+}
+$(function() {
+ var rndrs = ['#primary'];
+ for(r in rndrs) {
+ rounder(rndrs[r], 8, true);
+ }
+
+});
View
@@ -8,18 +8,7 @@
<script type="text/javascript" src="/static/js/date.js"></script>
<script type="text/javascript" src="/static/js/jquery.datePicker.js"></script>
<script type="text/javascript" src="/static/js/DD_roundies_0.0.2a-min.js"></script>
- <script type="text/javascript">
- var rounder = function(elem, sz, allBrowsers) {
- // rounded corners JS, handles IE7, 8 too:
- DD_roundies.addRule(elem, sz.toString()+'px', allBrowsers);
- }
- $(function() {
- var rndrs = ['#primary'];
- for(r in rndrs) {
- rounder(rndrs[r], 8, true);
- }
- });
- </script>
+ <script type="text/javascript" src="/static/js/hd-events.js"></script>
</head>
<body>
<div id="top">
View
@@ -17,8 +17,8 @@
<option value="1">1 - Terrible</option>
</select><br />
<strong>Comments:</strong><br />
- <textarea rows="5" style="width: 300px;" name="comment"></textarea><br />
- <input type="submit" value="Submit your feedback" style="font-size: larger; margin: 5px;" />
+ <textarea rows="5" style="width: 300px;" name="comment" id="comment"></textarea><br />
+ <input id='new_feedback' type="submit" value="Submit your feedback" style="font-size: larger; margin: 5px;" />
</form>
</div>
@@ -7,19 +7,19 @@
<form method="post" style="width: 49%;">
<h4>Rating</h4>
<p>1 is great, 5 is terrible, 0 is did not attend</p>
- <select name="rating">
+ <select name="rating" id='rating'>
<option>--select rating--</option>
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
- </select>
+ </select> <span id="validation_result" class="result"></span>
<h4>Comment</h4>
<p>Optional, enter any specific feedback you may have for the organizer or Hacker Dojo</p>
<textarea rows="5" style="width: 300px;" name="comment"></textarea>
- <input type="submit" value="Submit your feedback" style="font-size: larger; margin: 5px;" />
+ <input id="new_feedback" type="submit" value="XXXSubmit your feedback" style="font-size: larger; margin: 5px;" />
</form>
</div>
View
@@ -20,7 +20,7 @@
{% if event.is_canceled %}style="text-decoration: line-through;"{% endif %}
href="/event/{{event.key.id}}-{{event.name|slugify}}">{{event.name}}</a>
{% if event.is_canceled %}<span style="color: white; font-size: x-small; padding: 2px; background: gray">canceled</span>
- {% else %}(<a href="/event/feedback/{{event.key.id}}-{{event.name|slugify}}">Give your feedback</a>){% endif %}
+ {% else %}(<a href="/feedback/new/{{event.key.id}}">Give your feedback</a>){% endif %}
</td>
</tr>
{% endfor %}

0 comments on commit d2c3dc7

Please sign in to comment.