Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 491056c
Showing
5 changed files
with
599 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
application: tracker-widget | ||
version: 1 | ||
runtime: python | ||
api_version: 1 | ||
|
||
handlers: | ||
- url: .* | ||
script: main.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
Oops, something went wrong.