[DEV] remove the old dead code in server
This commit is contained in:
parent
2de40e83f1
commit
7f9c96bf1f
@ -87,43 +87,6 @@ def add(_app, _name_api):
|
||||
return response.json(value)
|
||||
raise ServerError("No data found", status_code=404)
|
||||
|
||||
@elem_blueprint.get('/' + _name_api + '/<id:int>/video_all', strict_slashes=True)
|
||||
@doc.summary("get all videos list")
|
||||
@doc.description("List all the videos availlable for this group.")
|
||||
@doc.produces(content_type='application/json')
|
||||
async def retrive_video(request, id):
|
||||
value = data_global_elements.get_interface(data_global_elements.API_VIDEO).gets_where(select=[["==", "group_id", id]], filter=["id"])
|
||||
if value != None:
|
||||
return response.json(value)
|
||||
raise ServerError("No data found", status_code=404)
|
||||
|
||||
@elem_blueprint.get('/' + _name_api + '/<id:int>/video', strict_slashes=True)
|
||||
@doc.summary("get videos list who have no saison")
|
||||
@doc.description("List all the videos availlable for this group tht does not depend on saison.")
|
||||
@doc.produces(content_type='application/json')
|
||||
async def retrive_video_no_saison(request, id):
|
||||
value = data_global_elements.get_interface(data_global_elements.API_VIDEO).gets_where(select=[["==", "group_id", id], ["==", "saison_id", None]], order_by=["name"], filter=["id"])
|
||||
if value != None:
|
||||
return response.json(value)
|
||||
raise ServerError("No data found", status_code=404)
|
||||
|
||||
@elem_blueprint.get('/' + _name_api + '/<id:int>/saison', strict_slashes=True)
|
||||
@doc.summary("get videos list who have no saison")
|
||||
@doc.description("List all the videos availlable for this group tht does not depend on saison.")
|
||||
@doc.produces(content_type='application/json')
|
||||
async def retrive_saison(request, id):
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_SAISON).gets_where(select=[["==", "group_id", id]], order_by=["number"], filter=["id"])
|
||||
if list_values == None:
|
||||
raise ServerError("No data found", status_code=404)
|
||||
if len(list_values) == 0:
|
||||
return response.json(list_values)
|
||||
if "select" in request.args:
|
||||
if request.args["select"] == "*":
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_SAISON).gets_where(select=[["==", "id", list_values]], order_by=["number"])
|
||||
else:
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_SAISON).gets_where(select=[["==", "id", list_values]], order_by=["number"], filter=request.args["select"])
|
||||
return response.json(list_values)
|
||||
|
||||
@elem_blueprint.put('/' + _name_api + '/<id:int>', strict_slashes=True)
|
||||
@doc.summary("Update resource")
|
||||
@doc.description("Update the specified resource in storage.")
|
||||
|
@ -74,16 +74,6 @@ def add(_app, _name_api):
|
||||
return response.json({"id": elem["id"]})
|
||||
raise ServerError("No data found", status_code=404)
|
||||
|
||||
@elem_blueprint.get('/' + _name_api + '/<id:int>/video', strict_slashes=True)
|
||||
@doc.summary("Show videos")
|
||||
@doc.description("List all the videos availlable for this group.")
|
||||
@doc.produces(content_type='application/json')
|
||||
async def retrive_video(request, id):
|
||||
value = data_global_elements.get_interface(data_global_elements.API_VIDEO).gets_where(select=[["==", "saison_id", id]], order_by=["episode", "name"], filter=["id"])
|
||||
if value != None:
|
||||
return response.json(value)
|
||||
raise ServerError("No data found", status_code=404)
|
||||
|
||||
@elem_blueprint.get('/' + _name_api + '/<id:int>', strict_slashes=True)
|
||||
@doc.summary("Show resources")
|
||||
@doc.description("Display a listing of the resource.")
|
||||
|
@ -86,63 +86,4 @@ def add(_app, _name_api):
|
||||
return response.json({})
|
||||
raise ServerError("No data found", status_code=404)
|
||||
|
||||
@elem_blueprint.get('/' + _name_api + '/<id:int>/count', strict_slashes=True)
|
||||
@doc.summary("Count resources in this cathegory")
|
||||
@doc.description("count resources in this cathegory, in the whole tree.")
|
||||
@doc.produces(content_type='application/json')
|
||||
async def count_values(request, id):
|
||||
count_value = data_global_elements.get_interface(data_global_elements.API_VIDEO).count(select=[["==", "type_id", id]])
|
||||
return response.json({"count":count_value})
|
||||
|
||||
|
||||
@elem_blueprint.get('/' + _name_api + '/<id:int>/video_all', strict_slashes=True)
|
||||
@doc.summary("List the whole video ids even if they are in a group or a univers...")
|
||||
@doc.description("List all video availlable with this type (list of ids).")
|
||||
@doc.produces(content_type='application/json')
|
||||
async def retrive_video(request, id):
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_VIDEO).gets_where(select=[["==", "type_id", id]], filter=["id"])
|
||||
return response.json(list_values)
|
||||
|
||||
@elem_blueprint.get('/' + _name_api + '/<id:int>/video', strict_slashes=True)
|
||||
@doc.summary("List the whole video free")
|
||||
@doc.description("List all video availlable with this type ... not link with an univers or a group.")
|
||||
@doc.produces(content_type='application/json')
|
||||
async def retrive_video_no_group(request, id):
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_VIDEO).gets_where(select=[["==", "type_id", id], ["==", "group_id", None], ["==", "univers_id", None]], order_by=["name"], filter=["id"])
|
||||
return response.json(list_values)
|
||||
|
||||
## ----------------------------------------------------------------------------------------
|
||||
## sub list of Groups ...
|
||||
@elem_blueprint.get('/' + _name_api + '/<id:int>/group', strict_slashes=True)
|
||||
@doc.summary("List all group availlable.")
|
||||
@doc.description("List all groups availlable in this type (not depending of an univers).")
|
||||
@doc.produces(content_type='application/json')
|
||||
async def retrive_group(request, id):
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_VIDEO).gets_where(select=[["==", "type_id", id], ["!=", "group_id", None], ["==", "univers_id", None]], order_by=["name"], filter=["group_id"])
|
||||
if len(list_values) == 0:
|
||||
return response.json(list_values)
|
||||
if "select" in request.args:
|
||||
if request.args["select"] == "*":
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_GROUP).gets_where(select=[["==", "id", list_values]], order_by=["name"])
|
||||
else:
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_GROUP).gets_where(select=[["==", "id", list_values]], order_by=["name"], filter=request.args["select"])
|
||||
return response.json(list_values)
|
||||
|
||||
## ----------------------------------------------------------------------------------------
|
||||
## Sub list of univers ...
|
||||
@elem_blueprint.get('/' + _name_api + '/<id:int>/univers', strict_slashes=True)
|
||||
@doc.summary("List all univers availlable.")
|
||||
@doc.description("List all univers availlable.")
|
||||
@doc.produces(content_type='application/json')
|
||||
async def retrive_group(request, id):
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_VIDEO).gets_where(select=[["==", "type_id", id], ["!=", "univers_id", None]], order_by=["name"], filter=["univers_id"])
|
||||
if len(list_values) == 0:
|
||||
return response.json(list_values)
|
||||
if "select" in request.args:
|
||||
if request.args["select"] == "*":
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_UNIVERS).gets_where(select=[["==", "id", list_values]], order_by=["name"])
|
||||
else:
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_UNIVERS).gets_where(select=[["==", "id", list_values]], order_by=["name"], filter=request.args["select"])
|
||||
return response.json(list_values)
|
||||
|
||||
_app.blueprint(elem_blueprint)
|
@ -87,45 +87,6 @@ def add(_app, _name_api):
|
||||
return response.json({})
|
||||
raise ServerError("No data found", status_code=404)
|
||||
|
||||
@elem_blueprint.get('/' + _name_api + '/<id:int>/count', strict_slashes=True)
|
||||
@doc.summary("Count resources in this cathegory")
|
||||
@doc.description("count resources in this cathegory, in the whole tree.")
|
||||
@doc.produces(content_type='application/json')
|
||||
async def count_values(request, id):
|
||||
count_value = data_global_elements.get_interface(data_global_elements.API_VIDEO).count(select=[["==", "univers_id", id]])
|
||||
return response.json({"count":count_value})
|
||||
|
||||
|
||||
@elem_blueprint.get('/' + _name_api + '/<id:int>/video_all', strict_slashes=True)
|
||||
@doc.summary("List the whole video ids even if they are in a group or a univers...")
|
||||
@doc.description("List all video availlable with this univers (list of ids).")
|
||||
@doc.produces(content_type='application/json')
|
||||
async def retrive_video(request, id):
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_VIDEO).gets_where(select=[["==", "univers_id", id]], filter=["id"])
|
||||
return response.json(list_values)
|
||||
|
||||
@elem_blueprint.get('/' + _name_api + '/<id:int>/video', strict_slashes=True)
|
||||
@doc.summary("List the whole video free")
|
||||
@doc.description("List all video availlable with this univers ... not link with an univers or a group.")
|
||||
@doc.produces(content_type='application/json')
|
||||
async def retrive_video_no_group(request, id):
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_VIDEO).gets_where(select=[["==", "univers_id", id], ["==", "group_id", None], ["==", "univers_id", None]], filter=["id"])
|
||||
return response.json(list_values)
|
||||
|
||||
## ----------------------------------------------------------------------------------------
|
||||
@elem_blueprint.get('/' + _name_api + '/<id:int>/group', strict_slashes=True)
|
||||
@doc.summary("List all group availlable.")
|
||||
@doc.description("List all groups availlable in this univers (not depending of an univers).")
|
||||
@doc.produces(content_type='application/json')
|
||||
async def retrive_group(request, id):
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_VIDEO).gets_where(select=[["==", "univers_id", id], ["!=", "group_id", None], ["==", "univers_id", None]], filter=["group_id"])
|
||||
if "select" in request.args:
|
||||
if request.args["select"] == "*":
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_GROUP).gets_where(select=[["==", "id", list_values]])
|
||||
else:
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_GROUP).gets_where(select=[["==", "id", list_values]], filter=request.args["select"].split('|'))
|
||||
return response.json(list_values)
|
||||
|
||||
@elem_blueprint.post('/' + _name_api + "/<id:int>/add_cover", strict_slashes=True)
|
||||
@doc.summary("Add cover on univers")
|
||||
@doc.description("Add a cover data ID to the univers.")
|
||||
|
@ -11,9 +11,10 @@
|
||||
import tools
|
||||
import json
|
||||
from realog import debug
|
||||
import random
|
||||
import random
|
||||
import copy
|
||||
from sanic.exceptions import ServerError
|
||||
import sqlite3
|
||||
##
|
||||
## @breif Generic interface to access to the BDD (no BDD, direct file IO)
|
||||
##
|
||||
@ -28,8 +29,8 @@ class DataInterface():
|
||||
if tools.exist(self.file) == False:
|
||||
self.mark_to_store()
|
||||
else:
|
||||
data = tools.file_read_data(self.file)
|
||||
self.bdd = json.loads(data)
|
||||
self.conn = sqlite3.connect(self.file)
|
||||
self.cursor = self.conn.cursor()
|
||||
self.upgrade_global_bdd_id();
|
||||
|
||||
def set_data_model(self, _data_model):
|
||||
@ -119,9 +120,7 @@ class DataInterface():
|
||||
if self.need_save == False:
|
||||
return
|
||||
debug.warning("Save bdd: " + self.file)
|
||||
data = json.dumps(self.bdd, sort_keys=True, indent=4)
|
||||
self.need_save = False
|
||||
tools.file_write_data_safe(self.file, data)
|
||||
conn.commit()
|
||||
|
||||
def gets(self, filter=None):
|
||||
debug.info("gets " + self.name)
|
||||
|
Loading…
Reference in New Issue
Block a user