|
@@ -72,36 +72,35 @@ def declare_route() :
|
|
for item in inventory.get_all_inventory_items() :
|
|
for item in inventory.get_all_inventory_items() :
|
|
ret.append(item)
|
|
ret.append(item)
|
|
|
|
|
|
- return json.dumps(ret, cls=model_manager.ComplexEncoder)
|
|
|
|
|
|
+ return view.JsonStringToResponse(json.dumps(ret, cls=model_manager.ComplexEncoder))
|
|
|
|
|
|
@inventory_blueprint.route('/item/<int:itemID>',methods = ['GET'])
|
|
@inventory_blueprint.route('/item/<int:itemID>',methods = ['GET'])
|
|
@view_privilege.manager.require_authorization(required_role=inventory_read_only_role,get_privilege_func=view.get_user_privilege)
|
|
@view_privilege.manager.require_authorization(required_role=inventory_read_only_role,get_privilege_func=view.get_user_privilege)
|
|
def get_item(itemID : int) :
|
|
def get_item(itemID : int) :
|
|
- return model_manager.ModelObjectToJsonString(inventory.get_inventory_item(itemID))
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.get_inventory_item(itemID)))
|
|
|
|
|
|
|
|
|
|
@inventory_blueprint.route('/item/<int:itemID>',methods = ['UPDATE','DELETE'])
|
|
@inventory_blueprint.route('/item/<int:itemID>',methods = ['UPDATE','DELETE'])
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
def update_or_delete_item(itemID : int) :
|
|
def update_or_delete_item(itemID : int) :
|
|
if flask.request.method == 'UPDATE':
|
|
if flask.request.method == 'UPDATE':
|
|
- return model_manager.ModelObjectToJsonString(inventory.inventory_item_update(itemID,json.dumps(flask.request.json)))
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.inventory_item_update(itemID,json.dumps(flask.request.json))))
|
|
|
|
|
|
if flask.request.method == 'DELETE':
|
|
if flask.request.method == 'DELETE':
|
|
- return model_manager.ModelObjectToJsonString(inventory.inventory_item_delete(itemID))
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.inventory_item_delete(itemID)))
|
|
|
|
|
|
|
|
|
|
@inventory_blueprint.route('/item',methods = ['POST'])
|
|
@inventory_blueprint.route('/item',methods = ['POST'])
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
def create_item() :
|
|
def create_item() :
|
|
|
|
|
|
- return model_manager.ModelObjectToJsonString(inventory.inventory_item_create(json.dumps(flask.request.json)))
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.inventory_item_create(json.dumps(flask.request.json))))
|
|
|
|
|
|
|
|
|
|
@inventory_blueprint.route('/item/template',methods = ['GET'])
|
|
@inventory_blueprint.route('/item/template',methods = ['GET'])
|
|
@view_privilege.manager.require_authorization(required_role=inventory_read_only_role,get_privilege_func=view.get_user_privilege)
|
|
@view_privilege.manager.require_authorization(required_role=inventory_read_only_role,get_privilege_func=view.get_user_privilege)
|
|
def get_item_template() :
|
|
def get_item_template() :
|
|
-
|
|
|
|
- return model_manager.ModelObjectToJsonString(inventory.inventory_item())
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.inventory_item()))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -121,28 +120,27 @@ def declare_route() :
|
|
@inventory_blueprint.route('/site/<int:siteID>',methods = ['GET'])
|
|
@inventory_blueprint.route('/site/<int:siteID>',methods = ['GET'])
|
|
@view_privilege.manager.require_authorization(required_role=inventory_read_only_role,get_privilege_func=view.get_user_privilege)
|
|
@view_privilege.manager.require_authorization(required_role=inventory_read_only_role,get_privilege_func=view.get_user_privilege)
|
|
def get_site(siteID : int) :
|
|
def get_site(siteID : int) :
|
|
- return model_manager.ModelObjectToJsonString(inventory.get_inventory_site(siteID))
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.get_inventory_site(siteID)))
|
|
|
|
|
|
|
|
|
|
@inventory_blueprint.route('/site/<int:siteID>',methods = ['UPDATE','DELETE'])
|
|
@inventory_blueprint.route('/site/<int:siteID>',methods = ['UPDATE','DELETE'])
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
def update_or_delete_site(siteID : int) :
|
|
def update_or_delete_site(siteID : int) :
|
|
if flask.request.method == 'UPDATE':
|
|
if flask.request.method == 'UPDATE':
|
|
- return model_manager.ModelObjectToJsonString(inventory.inventory_site_update(siteID,json.dumps(flask.request.json)))
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.inventory_site_update(siteID,json.dumps(flask.request.json))))
|
|
|
|
|
|
if flask.request.method == 'DELETE':
|
|
if flask.request.method == 'DELETE':
|
|
- return model_manager.ModelObjectToJsonString(inventory.inventory_site_delete(siteID))
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.inventory_site_delete(siteID)))
|
|
|
|
|
|
@inventory_blueprint.route('/site',methods = ['POST'])
|
|
@inventory_blueprint.route('/site',methods = ['POST'])
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
def create_site() :
|
|
def create_site() :
|
|
- return model_manager.ModelObjectToJsonString(inventory.inventory_site_create(json.dumps(flask.request.json)))
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.inventory_site_create(json.dumps(flask.request.json))))
|
|
|
|
|
|
@inventory_blueprint.route('/site/template',methods = ['GET'])
|
|
@inventory_blueprint.route('/site/template',methods = ['GET'])
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
def get_site_template() :
|
|
def get_site_template() :
|
|
-
|
|
|
|
- return model_manager.ModelObjectToJsonString(inventory.inventory_site())
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.inventory_site()))
|
|
|
|
|
|
#############################################
|
|
#############################################
|
|
######## contacts ########
|
|
######## contacts ########
|
|
@@ -161,29 +159,29 @@ def declare_route() :
|
|
@inventory_blueprint.route('/contact/<int:contactID>',methods = ['GET'])
|
|
@inventory_blueprint.route('/contact/<int:contactID>',methods = ['GET'])
|
|
@view_privilege.manager.require_authorization(required_role=inventory_read_only_role,get_privilege_func=view.get_user_privilege)
|
|
@view_privilege.manager.require_authorization(required_role=inventory_read_only_role,get_privilege_func=view.get_user_privilege)
|
|
def get_contact(contactID : int) :
|
|
def get_contact(contactID : int) :
|
|
- return model_manager.ModelObjectToJsonString(inventory.get_inventory_contact(contactID))
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.get_inventory_contact(contactID)))
|
|
|
|
|
|
@inventory_blueprint.route('/contact/<int:contactID>',methods = ['UPDATE','DELETE'])
|
|
@inventory_blueprint.route('/contact/<int:contactID>',methods = ['UPDATE','DELETE'])
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
def update_or_delete_contact(contactID : int) :
|
|
def update_or_delete_contact(contactID : int) :
|
|
if flask.request.method == 'UPDATE':
|
|
if flask.request.method == 'UPDATE':
|
|
- return model_manager.ModelObjectToJsonString(inventory.inventory_contact_update(contactID,json.dumps(flask.request.json)))
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.inventory_contact_update(contactID,json.dumps(flask.request.json))))
|
|
|
|
|
|
if flask.request.method == 'DELETE':
|
|
if flask.request.method == 'DELETE':
|
|
- return model_manager.ModelObjectToJsonString(inventory.inventory_contact_delete(contactID))
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.inventory_contact_delete(contactID)))
|
|
|
|
|
|
|
|
|
|
@inventory_blueprint.route('/contact',methods = ['POST'])
|
|
@inventory_blueprint.route('/contact',methods = ['POST'])
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
def create_contact() :
|
|
def create_contact() :
|
|
- return model_manager.ModelObjectToJsonString(inventory.inventory_contact_create(json.dumps(flask.request.json)))
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.inventory_contact_create(json.dumps(flask.request.json))))
|
|
|
|
|
|
|
|
|
|
@inventory_blueprint.route('/contact/template',methods = ['GET'])
|
|
@inventory_blueprint.route('/contact/template',methods = ['GET'])
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
def get_contact_template() :
|
|
def get_contact_template() :
|
|
|
|
|
|
- return model_manager.ModelObjectToJsonString(inventory.inventory_contact())
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.inventory_contact()))
|
|
|
|
|
|
#############################################
|
|
#############################################
|
|
######## groups ########
|
|
######## groups ########
|
|
@@ -201,39 +199,60 @@ def declare_route() :
|
|
@inventory_blueprint.route('/group/<int:groupID>',methods = ['GET'])
|
|
@inventory_blueprint.route('/group/<int:groupID>',methods = ['GET'])
|
|
@view_privilege.manager.require_authorization(required_role=inventory_read_only_role,get_privilege_func=view.get_user_privilege)
|
|
@view_privilege.manager.require_authorization(required_role=inventory_read_only_role,get_privilege_func=view.get_user_privilege)
|
|
def get_group(groupID : int) :
|
|
def get_group(groupID : int) :
|
|
- return model_manager.ModelObjectToJsonString(inventory.get_inventory_group(groupID))
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.get_inventory_group(groupID)))
|
|
|
|
|
|
@inventory_blueprint.route('/group/<int:groupID>',methods = ['UPDATE','DELETE'])
|
|
@inventory_blueprint.route('/group/<int:groupID>',methods = ['UPDATE','DELETE'])
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
def update_or_delete_group(groupID : int) :
|
|
def update_or_delete_group(groupID : int) :
|
|
if flask.request.method == 'UPDATE':
|
|
if flask.request.method == 'UPDATE':
|
|
- return model_manager.ModelObjectToJsonString(inventory.inventory_group_update(groupID,json.dumps(flask.request.json)))
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.inventory_group_update(groupID,json.dumps(flask.request.json))))
|
|
|
|
|
|
if flask.request.method == 'DELETE':
|
|
if flask.request.method == 'DELETE':
|
|
- return model_manager.ModelObjectToJsonString(inventory.inventory_group_delete(groupID))
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.inventory_group_delete(groupID)))
|
|
|
|
|
|
@inventory_blueprint.route('/group',methods = ['POST'])
|
|
@inventory_blueprint.route('/group',methods = ['POST'])
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
def create_group() :
|
|
def create_group() :
|
|
- return model_manager.ModelObjectToJsonString(inventory.inventory_group_create(json.dumps(flask.request.json)))
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.inventory_group_create(json.dumps(flask.request.json))))
|
|
|
|
|
|
|
|
|
|
@inventory_blueprint.route('/group/<int:groupID>/item/<int:itemID>',methods = ['POST','DELETE'])
|
|
@inventory_blueprint.route('/group/<int:groupID>/item/<int:itemID>',methods = ['POST','DELETE'])
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
def manage_group_members(groupID : int,itemID : int) :
|
|
def manage_group_members(groupID : int,itemID : int) :
|
|
if flask.request.method == 'POST':
|
|
if flask.request.method == 'POST':
|
|
- return model_manager.ModelObjectToJsonString(inventory.inventory_group_add_item(groupID,itemID))
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.inventory_group_add_item(groupID,itemID)))
|
|
if flask.request.method == 'DELETE':
|
|
if flask.request.method == 'DELETE':
|
|
- return model_manager.ModelObjectToJsonString(inventory.inventory_group_delete_item(groupID,itemID))
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.inventory_group_delete_item(groupID,itemID)))
|
|
|
|
|
|
|
|
|
|
@inventory_blueprint.route('/group/template',methods = ['GET'])
|
|
@inventory_blueprint.route('/group/template',methods = ['GET'])
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
@view_privilege.manager.require_authorization(required_role=inventory_admin_role,get_privilege_func=view.get_user_privilege)
|
|
def get_group_template() :
|
|
def get_group_template() :
|
|
|
|
|
|
- return model_manager.ModelObjectToJsonString(inventory.inventory_group())
|
|
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.inventory_group()))
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+#############################################
|
|
|
|
+######## aggregation ########
|
|
|
|
+#############################################
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @inventory_blueprint.route('/group/<int:groupID>/items',methods = ['GET'])
|
|
|
|
+ @view_privilege.manager.require_authorization(required_role=inventory_read_only_role,get_privilege_func=view.get_user_privilege)
|
|
|
|
+ def get_group_items(groupID : int) :
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.get_inventory_group_items(groupID)))
|
|
|
|
+
|
|
|
|
+ @inventory_blueprint.route('/contact/<int:contactID>/items',methods = ['GET'])
|
|
|
|
+ @view_privilege.manager.require_authorization(required_role=inventory_read_only_role,get_privilege_func=view.get_user_privilege)
|
|
|
|
+ def get_contact_items(contactID : int) :
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.get_inventory_contact_items(contactID)))
|
|
|
|
+
|
|
|
|
+ @inventory_blueprint.route('/site/<int:siteID>/items',methods = ['GET'])
|
|
|
|
+ @view_privilege.manager.require_authorization(required_role=inventory_read_only_role,get_privilege_func=view.get_user_privilege)
|
|
|
|
+ def get_site_items(siteID : int) :
|
|
|
|
+ return view.JsonStringToResponse(model_manager.ModelObjectToJsonString(inventory.get_inventory_site_items(siteID)))
|
|
|
|
|
|
|
|
|