Initial code added for models and services not functional yet. Bootstrap and migrations added for db.

This commit is contained in:
Nicholas Staples
2016-01-07 17:31:17 +00:00
parent 44b0a5f07d
commit a327702ad0
20 changed files with 341 additions and 2 deletions

View File

@@ -2,11 +2,16 @@ from flask import jsonify
from .. import main
# TODO need for health check url
# TODO remove
@main.route('/', methods=['GET'])
def get_index():
return jsonify(result="hello world"), 200
# TODO remove
@main.route('/', methods=['POST'])
def post_index():
return jsonify(result="hello world"), 200

View File

@@ -0,0 +1,38 @@
from flask import jsonify
from app.main.dao.services_dao import (create_new_service, get_services)
from app.main.dao.users_dao import (get_users)
from .. import main
# TODO auth to be added.
@main.route('/service', methods=['POST'])
def create_service():
return jsonify(result="created"), 201
# TODO auth to be added
@main.route('/service/<int:service_id>', method=['PUT'])
def update_service(service_id):
return jsonify(result="updated")
# TODO auth to be added.
# Should be restricted by user, user id
# is pulled from the token
@main.route('/service/<int:service_id>', method=['GET'])
@main.route('/service', methods=['GET'])
def get_service(service_id=None):
services = get_services
return jsonify(
data=services
)
# TODO auth to be added
# auth should be allow for admin tokens only
@main.route('/user/<int:user_id>/service', method=['GET'])
@main.route('/user/<int:user_id>/service/<int:service_id>', method=['GET'])
def get_service_by_user_id(user_id, service_id=None):
user = get_users(user_id=user_id)
services = get_services(user, service_id=service_id)
return jsonify(data=services)