Skip to content

Commit

Permalink
uu
Browse files Browse the repository at this point in the history
  • Loading branch information
no13bus committed May 19, 2015
1 parent 0051f92 commit 9dbf5d0
Show file tree
Hide file tree
Showing 147 changed files with 1,863 additions and 11,269 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ uploads
openid

env

.idea
.idea/*.*
363 changes: 204 additions & 159 deletions .idea/workspace.xml

Large diffs are not rendered by default.

17 changes: 0 additions & 17 deletions CHANGES

This file was deleted.

31 changes: 0 additions & 31 deletions LICENSE

This file was deleted.

18 changes: 0 additions & 18 deletions MANIFEST.in

This file was deleted.

148 changes: 0 additions & 148 deletions README.markdown

This file was deleted.

23 changes: 0 additions & 23 deletions app.wsgi

This file was deleted.

21 changes: 0 additions & 21 deletions baymax.conf

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
34 changes: 34 additions & 0 deletions baymax/api/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-

from flask import Blueprint, jsonify
from flask.ext.login import current_user, login_required
from ..user import User
from ..monitor import MonitorValue


api = Blueprint('api', __name__, url_prefix='/api')

@api.route('/<monitor_type>', methods=['GET'])
@login_required
def calories_out(monitor_type):
res = []
user_id = current_user.id
mv = MonitorValue.query.filter_by(user_id=user_id, datatype=monitor_type).order_by('recode_date desc').limit(7).all()
if not mv:
return jsonify(result=[])
for one_mv in mv[::-1]:
res.append([one_mv.recode_date.strftime('%Y-%m-%d'), one_mv.value])
return jsonify(result=res)

@api.route('/user/<username>/<monitor_type>', methods=['GET'])
def api_data(username, monitor_type):
res = []
user = User.query.filter_by(name=username).first()
user_id = user.id
mv = MonitorValue.query.filter_by(user_id=user_id, datatype=monitor_type).order_by('recode_date desc').limit(7).all()
if not mv:
return jsonify(result=[])
for one_mv in mv[::-1]:
res.append([one_mv.recode_date.strftime('%Y-%m-%d'), one_mv.value])
return jsonify(result=res)

11 changes: 7 additions & 4 deletions fbone/app.py → baymax/app.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from flask.ext.babel import Babel

from .config import DefaultConfig
from .user import User, user
from .settings import settings
from .user import User
from .frontend import frontend
from .monitor import monitor
from .api import api
Expand All @@ -21,8 +20,6 @@

DEFAULT_BLUEPRINTS = (
frontend,
user,
settings,
api,
admin,
monitor
Expand Down Expand Up @@ -86,12 +83,18 @@ def configure_extensions(app):
# flask-login
login_manager.login_view = 'frontend.login'
login_manager.refresh_view = 'frontend.reauth'
login_manager.login_message = u""

@login_manager.user_loader
def load_user(id):
return User.query.get(id)
login_manager.init_app(app)

# @login_manager.unauthorized_handler
# def unauthorized():
# # do stuff
# return a_response

# flask-openid
oid.init_app(app)

Expand Down
13 changes: 0 additions & 13 deletions fbone/celery_app.py → baymax/celery_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,3 @@ def init_app(self, app):
self.app = app
print app.config
self.config_from_object(app.config)


# def make_celery(app):
# celery = Celery(app.import_name, broker=app.config['CELERY_BROKER_URL'])
# celery.conf.update(app.config)
# TaskBase = celery.Task
# class ContextTask(TaskBase):
# abstract = True
# def __call__(self, *args, **kwargs):
# with app.app_context():
# return TaskBase.__call__(self, *args, **kwargs)
# celery.Task = ContextTask
# return celery
Loading

0 comments on commit 9dbf5d0

Please sign in to comment.