def getAllResources(): if request.method == 'POST': return ResourcesHandler().insertResource(request.form) else: if not request.args: return ResourcesHandler().getAllResources() else: return ResourcesHandler().searchResource(request.args)
def getResourceById(r_id): if request.method == 'GET': return ResourcesHandler().getResourceById(r_id) elif request.method == 'PUT': #Update return ResourcesHandler().updateResource(r_id, request.form) elif request.method == 'DELETE': return ResourcesHandler().deleteResource(r_id) else: return jsonify(Error="Method not allowed"), 405
def getLocationByResourceId(r_id): class Map: def __init__(self, name, lat, lng): self.name = name self.lat = lat self.lng = lng api_key = "AIzaSyCeHf-jcEx21QPuV7BZOUOukikZ-bQYxDA" google = GoogleMaps(api_key) location = ResourcesHandler().getLocationByResourceId(r_id) geocode_result = google.geocode(location + ', Puerto Rico') lat = geocode_result[0]['geometry']['location']['lat'] lng = geocode_result[0]['geometry']['location']['lng'] map = Map(location, lat, lng) return render_template('map.html', map=map)
def getResourcesAvailableBySenateRegion(): return ResourcesHandler().getResourcesAvailableBySenateRegion()
def getAllResourcesReserves(): return ResourcesHandler().getAllResourcesReserves()
def getSupplierByResourceId(r_id): return ResourcesHandler().getSuppliersByResourceId(r_id)
def getResourcesAvailableWeekly(): return ResourcesHandler().getResourcesAvailableWeekly()
def getResourcesMatchingWeekly(): return ResourcesHandler().getResourcesMatchingWeekly()
def getResourcesInNeedDaily(): return ResourcesHandler().getResourcesInNeedDaily()
def getResourcesInNeedWeekly(): return ResourcesHandler().getResourcesInNeedWeekly()
def getAllResourcesRequests(): return ResourcesHandler().getAllResourcesRequests()
def getResourcesMatchingBySenateRegion(): return ResourcesHandler().getResourcesMatchingBySenateRegion()
def getResourcesInNeedBySenateRegion(): return ResourcesHandler().getResourcesInNeedBySenateRegion()
def sortResourcesAvailableByResourceName(): return ResourcesHandler().sortResourcesAvailableByResourceName()
def getAllResourcesAvailable(): return ResourcesHandler().getAllResourcesAvailable()
def sortResourcesRequestsByResourceName(): return ResourcesHandler().sortResourcesRequestsByResourceName()
def getAllResourcesPurchases(): return ResourcesHandler().getAllResourcesPurchases()