def updatePostAuthor(): port = Portfolio() newname = request.json['newname'] oldname = request.json['oldname'] port.UpdateUsername(newname, oldname) port.UpdateComentAuthor(newname, oldname) return jsonify({'msg': 'OK'})
def portfolio(iden=''): port = Portfolio() if request.method == 'GET': return port.GetAll() elif request.method == 'POST': #filename = Upload() port = Portfolio(title=request.form['titulo'], file=ast.literal_eval(request.form['file']), text=request.form['text'], author=request.form['author'], authorname=request.form['authorname'], category=request.form['category'], totalpoints=0, totalcoments=0, tags=list( str(request.form['tags']).lower().split(','))) #print(str(request.form['tags']).split(',')) return port.Post() elif request.method == 'PUT': iden = request.json['_id'] return port.Update(iden['$oid'], request.json['archivo'], request.json['titulo'], request.json['texto'], request.json['autor'], request.json['authorname'], request.json['coments'], request.json['points'], request.json['category'], request.json['tags']) elif request.method == 'DELETE': return port.Delete(escape(iden)) return jsonify({"msg": "Route Not Found"}, 400)
def GetByCategory(cat): port = Portfolio() res = port.GetByCategory(str(escape(cat))) return res
def GetMostValored(): port = Portfolio() res = port.MejorValorados() return res
def search(): args = str(request.json['args']).lower() filt = request.json['filt'] port = Portfolio() return port.Search(args, filt)
def GetPortfolio(_id): port = Portfolio() return port.GetById(escape(_id))
def UserPortfolioID(_id): port = Portfolio() return port.GetByUserId(escape(_id))