Ejemplo n.º 1
0
def update_graffiti():
    if 'current_user_uid' not in session:
        return redirect(url_for('start'))
    else:
        key = str(request.form['key'])
        description = str(request.form['description'])
        data = {'description': description}
        Graffiti.update_graffiti(key, data)
        return redirect('/graffiti?key=' + key)
Ejemplo n.º 2
0
 def like_increase_decrease(like_type, key, uid):
     if Like.check_like_user(key, uid):
         if like_type == 'RATING':
             rating = Rating.get_by_key(key)
             data = {
                 'nlikes': rating.n_likes - 1
             }
             Rating.update_rating(key, data)
         elif like_type == 'GRAFFITI':
             graffiti = Graffiti.get_by_key(key)
             data = {
                 'nlikes': graffiti.n_likes - 1
             }
             Graffiti.update_graffiti(key, data)
         elif like_type == 'USER':
             leisure = UserLeisure.get_by_key(key)
             data = {
                 'nlikes': leisure.n_likes - 1
             }
             UserLeisure.update_user_leisure(key, data)
         Like.delete_like(key, uid)
     else:
         Like.create_like(key, uid)
         if like_type == 'RATING':
             rating = Rating.get_by_key(key)
             data = {
                 'nlikes': rating.n_likes + 1
             }
             Rating.update_rating(key, data)
         elif like_type == 'GRAFFITI':
             graffiti = Graffiti.get_by_key(key)
             data = {
                 'nlikes': graffiti.n_likes + 1
             }
             Graffiti.update_graffiti(key, data)
         elif like_type == 'USER':
             leisure = UserLeisure.get_by_key(key)
             data = {
                 'nlikes': leisure.n_likes + 1
             }
             UserLeisure.update_user_leisure(key, data)