Exemple #1
0
def updatePostAuthor():
    port = Portfolio()
    newname = request.json['newname']
    oldname = request.json['oldname']

    port.UpdateUsername(newname, oldname)
    port.UpdateComentAuthor(newname, oldname)

    return jsonify({'msg': 'OK'})
Exemple #2
0
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)
Exemple #3
0
def GetByCategory(cat):
    port = Portfolio()
    res = port.GetByCategory(str(escape(cat)))
    return res
Exemple #4
0
def GetMostValored():
    port = Portfolio()
    res = port.MejorValorados()
    return res
Exemple #5
0
def search():
    args = str(request.json['args']).lower()
    filt = request.json['filt']
    port = Portfolio()
    return port.Search(args, filt)
Exemple #6
0
def GetPortfolio(_id):
    port = Portfolio()
    return port.GetById(escape(_id))
Exemple #7
0
def UserPortfolioID(_id):
    port = Portfolio()
    return port.GetByUserId(escape(_id))