This repository has been archived by the owner on Mar 12, 2020. It is now read-only.
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
Mike Graves
committed
Jun 17, 2015
1 parent
6d0654d
commit 4cc8d29
Showing
6 changed files
with
83 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
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,10 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import | ||
|
||
from flask import Blueprint | ||
|
||
from kepler.item.views import ItemView | ||
|
||
|
||
item_blueprint = Blueprint('item', __name__) | ||
ItemView.register(item_blueprint, 'items', '/items/') |
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,31 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import | ||
|
||
from flask import request, render_template | ||
from flask.views import View | ||
|
||
from kepler.models import Item, Job | ||
|
||
|
||
class ItemView(View): | ||
def dispatch_request(self, *args, **kwargs): | ||
if request.method == 'GET': | ||
if request.endpoint.endswith('.index'): | ||
return self.list() | ||
return self.show(*args, **kwargs) | ||
|
||
def list(self): | ||
items = Item.query.all() | ||
return render_template('item/index.html', items=items) | ||
|
||
def show(self, id): | ||
item = Item.query.get_or_404(id) | ||
jobs = item.jobs.order_by(Job.time.desc()) | ||
return render_template('item/show.html', item=item, jobs=jobs) | ||
|
||
@classmethod | ||
def register(cls, app, endpoint, url): | ||
view_func = cls.as_view(endpoint) | ||
app.add_url_rule(url, 'index', methods=['GET'], view_func=view_func) | ||
app.add_url_rule('%s<path:id>' % url, 'resource', methods=['GET'], | ||
view_func=view_func) |
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,9 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block content %} | ||
<ol> | ||
{% for item in items %} | ||
<li><a href="{{ url_for('.resource', id=item.id) }}">{{ item.uri }}</a></li> | ||
{% endfor %} | ||
</ol> | ||
{% endblock %} |
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,15 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block content %} | ||
<h1>{{ item.uri }}</h1> | ||
<ol> | ||
{% for job in jobs %} | ||
<li> | ||
<a href="{{ url_for('job.resource', id=job.id) }}"> | ||
{{ job.time.strftime('%Y-%m-%dT%H:%M:%S%z') }} | ||
</a> | ||
{{ job.status }} | ||
</li> | ||
{% endfor %} | ||
</ol> | ||
{% endblock %} |
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