Permalink
Browse files

final version

  • Loading branch information...
1 parent 01a745e commit 88685e7888f6e56f01c09620d4754fa90491ab03 unknown committed May 9, 2012
Showing with 12 additions and 26 deletions.
  1. +8 −18 main.py
  2. +3 −3 models.py
  3. BIN models.pyc
  4. +1 −5 templates/issue.html
View
26 main.py
@@ -69,7 +69,6 @@ def post(self):
if self.request.get('option5'):
issue.add_choice(cgi.escape(self.request.get('option5')))
- #self.redirect('/issue/%s' % (issue.key().id()))
self.redirect('/issue/%s' % issue.urlcode)
class EditHandler(webapp.RequestHandler):
@@ -80,9 +79,7 @@ def get(self,urlcode):
else:
self.redirect(users.create_login_url(self.request.uri))
return
- #issue = Issue.get_by_id(int(id))
- #issue = Issue.get_by_urlcode(urlcode)
- #issue = Issue.get_issue_by_urlcode(urlcode)
+ issue = Issue.get_issue_by_urlcode(urlcode)
choices = issue.choices
self.response.out.write(template.render('templates/edit.html', locals()))
@@ -93,9 +90,7 @@ def post(self,urlcode):
else:
self.redirect(users.create_login_url(self.request.uri))
return
- #issue = Issue.get_by_id(int(id))
- #issue = Issue.get_by_urlcode(urlcode)
- #issue = Issue.get_issue_by_urlcode(urlcode)
+ issue = Issue.get_issue_by_urlcode(urlcode)
if self.request.get('extend'):#if extending vote
choices = issue.choices
@@ -138,16 +133,13 @@ def get(self,urlcode):
self.redirect(users.create_login_url(self.request.uri))
return
- issue = Issue.get_by_id(int(urlcode))
- #issue = Issue.get_issue_by_urlcode(urlcode)
- #issue = Issue.get_by_urlcode(urlcode)
- #issue.update_status()
+ issue = Issue.get_issue_by_urlcode(urlcode)
+ issue.update_status()
#vote = issue.vote_for_member(user)
#issueUrl = self.request.uri
- #self.response.out.write(urlcode + '4')
self.response.out.write(template.render('templates/issue.html', locals()))
@@ -158,9 +150,7 @@ def post(self,urlcode):
else:
self.redirect(users.create_login_url(self.request.uri))
- issue = Issue.get_by_id(int(urlcode))
- #issue = Issue.get_by_url(urlcode)
- #issue = Issue.get_issue_by_urlcode(urlcode)
+ issue = Issue.get_issue_by_urlcode(urlcode)
#vote = issue.vote_for_member()
new_choice = Choice.get_by_id(int(self.request.get('choice')))
@@ -173,15 +163,15 @@ def post(self,urlcode):
def random_string():
- hashbase = 'abcd1234'
+ hashbase = '1234567890abcdefghijklmnopqrstuvwxyz'
return ''.join(random.sample(hashbase,len(hashbase)))
def main():
application = webapp.WSGIApplication([
('/',MainPage),
('/new',NewHandler),
- ('/issue/(\d+).*',IssueHandler),
- ('/edit/(\d+).*',EditHandler)],
+ ('/issue/(\w+).*',IssueHandler),
+ ('/edit/(\w+).*',EditHandler)],
debug=True)
util.run_wsgi_app(application)
View
@@ -132,9 +132,9 @@ def recent_results(cls, member=None,limit=20):#*** Need to fix, limit will be in
#member_votes = Vote.all().filter('member =',member).fetch(limit)
#return [vote.issue for vote in member_votes if vote.issue.has_results()]
-# @classmethod
-# def get_issue_by_urlcode(cls, urlcode):
-# return cls.all().filter('urlcode =',urlcode).get()
+ @classmethod
+ def get_issue_by_urlcode(cls, urlcode):
+ return cls.all().filter('urlcode =',urlcode).get()
class Choice(db.Model):
"""Represents a possible response to an issue (e.g. Yes)"""
View
Binary file not shown.
View
@@ -1,7 +1,5 @@
{% extends 'base.html' %}
-
{% block content %}
-<!--
<div id="primary">
{% if issue.member_is_creator %}
@@ -66,6 +64,4 @@
</div>
--->
-
-{% endblock %}
+{% endblock %}

0 comments on commit 88685e7

Please sign in to comment.