Beispiel #1
0
def delete_graffiti():
    if 'current_user_uid' not in session:
        return redirect(url_for('start'))
    else:
        key = str(request.form['key'])
        Graffiti.delete_graffiti(key)
        return redirect(url_for('show_graffities'))
Beispiel #2
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)
Beispiel #3
0
def show_graffiti():
    if 'current_user_uid' not in session:
        return redirect(url_for('start'))
    else:
        key = str(request.args.get('key'))
        graffiti = Graffiti.get_by_key(key)
        return render_template('graffiti.html',
                               graffiti=graffiti,
                               title='YATAM - View Graffiti')
Beispiel #4
0
def search_graffities():
    if 'current_user_uid' not in session:
        return redirect(url_for('start'))
    else:
        req = request.get_json()
        graffities = Graffiti.search_by_description(req)
        return Response(response=json.dumps(graffities,
                                            default=lambda o: o.encode(),
                                            indent=4),
                        status=200,
                        mimetype=mimetype)
Beispiel #5
0
def create_graffiti():
    if 'current_user_uid' not in session:
        return redirect(url_for('start'))
    else:
        if request.method == 'GET':
            return render_template('create_graffiti.html',
                                   title='YATAM - Create Graffiti')
        elif request.method == 'POST':
            description = request.form['description']
            photo = request.form['photo']
            graffiti = Graffiti.create_graffiti(
                description=description,
                url=photo,
                user=session['current_user_uid'])
            return redirect(url_for('show_graffiti', key=graffiti.key))
Beispiel #6
0
def show_graffities():
    if 'current_user_uid' not in session:
        return redirect(url_for('start'))
    else:
        if request.method == 'POST':
            req = request.get_json()
            graffities = Graffiti.get_all()
            return Response(response=json.dumps(
                graffities[req['from']:req['to']],
                default=lambda o: o.encode(),
                indent=4),
                            status=200,
                            mimetype=mimetype)
        else:
            return render_template('graffiti_list.html',
                                   title='YATAM - Graffities')
Beispiel #7
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)