diff options
author | Lei Yan | 2015-02-13 18:18:49 +0000 |
---|---|---|
committer | Lei Yan | 2015-02-13 18:18:49 +0000 |
commit | 723fcb3723d16e4ef476b0fc7471f7a770ed01be (patch) | |
tree | 19e12a1e8e3f9b552ec1e1d1d33942b31edd57d4 | |
parent | 4ea8b8a5efc848c99767894cbdbef2f135e3b83c (diff) | |
download | genenetwork2-723fcb3723d16e4ef476b0fc7471f7a770ed01be.tar.gz |
Committer: Lei Yan <lei@penguin.uthsc.edu>
On branch master
-rwxr-xr-x | wqflask/wqflask/news.py | 16 | ||||
-rwxr-xr-x | wqflask/wqflask/templates/news.html | 21 | ||||
-rwxr-xr-x | wqflask/wqflask/views.py | 13 |
3 files changed, 41 insertions, 9 deletions
diff --git a/wqflask/wqflask/news.py b/wqflask/wqflask/news.py new file mode 100755 index 00000000..62dc1bbb --- /dev/null +++ b/wqflask/wqflask/news.py @@ -0,0 +1,16 @@ +from __future__ import absolute_import, print_function, division +import sys +reload(sys) +sys.setdefaultencoding('utf8') +from flask import g + +class News(object): + + def __init__(self): + sql = """ + SELECT News.id, News.date, News.details + FROM News + order by News.date desc + """ + self.title = "GeneNetwork News" + self.newslist = g.db.execute(sql).fetchall() diff --git a/wqflask/wqflask/templates/news.html b/wqflask/wqflask/templates/news.html new file mode 100755 index 00000000..0a19dcee --- /dev/null +++ b/wqflask/wqflask/templates/news.html @@ -0,0 +1,21 @@ +{% extends "base.html" %} + +{% block title %}{{title}}{% endblock %} + +{% block content %} +<div class="container"> + <h3>{{title}}</h3> + <table class="table table-hover table-striped"> + <tbody> + {% for newsitem in newslist %} + <tr> + <td style="width: 100px;"> + <span style="font-weight: bold;">{{newsitem.date}}</span> + </td> + <td>{{newsitem.details|safe}}</td> + </tr> + {% endfor %} + </tbody> + </table> +</div> +{% endblock %} diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index deb566ba..7c0f4e14 100755 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -30,6 +30,7 @@ from flask import (render_template, request, make_response, Response, from wqflask import search_results from wqflask import docs +from wqflask import news from base.data_set import DataSet # Used by YAML in marker_regression from base.data_set import create_datasets_list from wqflask.show_trait import show_trait @@ -145,15 +146,9 @@ def help(): return render_template("docs.html", **doc.__dict__) @app.route("/news") -def news(): - #variables = whats_new.whats_new() - with open("/home/sam/gene/wqflask/wqflask/yaml_data/whats_new.yaml") as fh: - contents = fh.read() - yamilized = yaml.safe_load(contents) - news_items = yamilized['news'] - for news_item in news_items: - print("\nnews_item is: %s\n" % (news_item)) - return render_template("whats_new.html", news_items=news_items) +def news_route(): + newsobject = news.News() + return render_template("news.html", **newsobject.__dict__) @app.route("/references") def references(): |