Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
progrium committed Aug 30, 2011
0 parents commit 491056c
Show file tree
Hide file tree
Showing 5 changed files with 599 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app.yaml
@@ -0,0 +1,8 @@
application: tracker-widget
version: 1
runtime: python
api_version: 1

handlers:
- url: .*
script: main.py
11 changes: 11 additions & 0 deletions index.yaml
@@ -0,0 +1,11 @@
indexes:

# AUTOGENERATED

# This index.yaml is automatically updated whenever the dev_appserver
# detects that a new type of query is run. If you want to manage the
# index.yaml file manually, remove the above marker line (the line
# saying "# AUTOGENERATED"). If you want to manage some indexes
# manually, move them above the marker line. The index.yaml file is
# automatically uploaded to the admin console when you next deploy
# your application using appcfg.py.
59 changes: 59 additions & 0 deletions main.py
@@ -0,0 +1,59 @@
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp import template

from pytracker import Tracker
from pytracker import Story
from pytracker import HostedTrackerAuth

def stories_for_view(stories):
return [dict(
name=s.name,
owner=''.join([n[0] for n in s.owned_by.split(' ')]),
labels=(', '.join(list(s.labels))) if s.labels else '')
for s in stories]

class MainHandler(webapp.RequestHandler):
def get(self):
self.response.out.write('Hello world!')

class StoryWidgetHandler(webapp.RequestHandler):
def get(self):
css = self.request.get('css')
username = self.request.get('username')
password = self.request.get('password')
project_id = self.request.get('project_id')
filter = self.request.get('filter')

auth = HostedTrackerAuth(username, password)
project = Tracker(int(project_id), auth)
stories = stories_for_view(project.GetStories(filter))

self.response.out.write(template.render('widget.html',
{'stories': stories, 'css': css}))

class IterationWidgetHandler(webapp.RequestHandler):
def get(self):
css = self.request.get('css')
username = self.request.get('username')
password = self.request.get('password')
project_id = self.request.get('project_id')
iteration = self.request.get('iteration')

auth = HostedTrackerAuth(username, password)
project = Tracker(int(project_id), auth)
stories = stories_for_view(project.GetIterationStories(iteration))

self.response.out.write(template.render('widget.html',
{'stories': stories, 'css': css}))

def main():
application = webapp.WSGIApplication([
('/', MainHandler),
('/widget/stories', StoryWidgetHandler),
('/widget/iteration', IterationWidgetHandler), ], debug=True)
util.run_wsgi_app(application)


if __name__ == '__main__':
main()

0 comments on commit 491056c

Please sign in to comment.