def get_by_key(key):
     graffiti = db.get_dict(Graffiti.entry + '/' + key)
     return Graffiti(key=graffiti['key'],
                     description=graffiti['description'],
                     n_likes=graffiti['nlikes'],
                     url=graffiti['url'],
                     user=User.get_by_uid(graffiti['user']))
 def get_graffiti(order=None, value=None):
     # ordered dictionary to list and getting first element
     graffiti = list(
         db.get_dict(Graffiti.entry, order=order, value=value).values())[0]
     return Graffiti(key=graffiti['key'],
                     description=graffiti['description'],
                     n_likes=graffiti['nlikes'],
                     url=graffiti['url'],
                     user=User.get_by_uid(graffiti['user']))
 def get_by_key(key):
     leisure = db.get_dict(UserLeisure.entry + '/' + key)
     return UserLeisure(key=leisure['key'],
                        description=leisure['description'],
                        name=leisure['name'],
                        address=leisure['address'],
                        url_photo=leisure['url_photo'],
                        user=User.get_by_uid(leisure['user']),
                        schedule=leisure['schedule'],
                        coordinates=leisure['coordinates'],
                        n_likes=leisure['nlikes'])
 def get_all():
     result = []
     graffities = db.get_dict(Graffiti.entry)
     for key, value in graffities.items():
         result.append(
             Graffiti(key=value.get('key'),
                      description=value.get('description'),
                      n_likes=value.get('nlikes'),
                      url=value.get('url'),
                      user=User.get_by_uid(value.get('user'))))
     return result
Beispiel #5
0
 def get_all():
     result = []
     ratings = db.get_dict(Rating.entry)
     for key, value in ratings.items():
         result.append(
             Rating(key=value.get('key'),
                    grade=value.get('grade'),
                    description=value.get('description'),
                    n_likes=value.get('n_likes'),
                    leisure=value.get('url'),
                    user=User.get_by_uid(value.get('user'))))
     return result
Beispiel #6
0
 def get_ratings_by_leisure(order=None, value=None):
     ratings = db.get_dict(Rating.entry, order=order, value=value)
     result = []
     if ratings:
         for key, value in ratings.items():
             result.append(
                 Rating(key=value.get('key'),
                        grade=value.get('grade'),
                        description=value.get('description'),
                        n_likes=value.get('nlikes'),
                        leisure=value.get('url'),
                        user=User.get_by_uid(value.get('user'))))
     return result
 def get_user_leisure(order=None, value=None):
     # ordered dictionary to list and getting first element
     leisure = list(
         db.get_dict(UserLeisure.entry, order=order,
                     value=value).values())[0]
     return UserLeisure(key=leisure['key'],
                        description=leisure['description'],
                        name=leisure['name'],
                        address=leisure['address'],
                        url_photo=leisure['url_photo'],
                        user=User.get_by_uid(leisure['user']),
                        schedule=leisure['schedule'],
                        coordinates=leisure['coordinates'],
                        n_likes=leisure['nlikes'])
 def get_all():
     result = []
     leisures = db.get_dict(UserLeisure.entry)
     for key, value in leisures.items():
         result.append(
             UserLeisure(key=value.get('key'),
                         description=value.get('description'),
                         name=value.get('name'),
                         url_photo=value.get('url_photo'),
                         schedule=value.get('schedule'),
                         user=User.get_by_uid(value.get('user')),
                         coordinates=value.get('coordinates'),
                         address=value.get('address'),
                         n_likes=value.get('nlikes')))
     return result
 def create_graffiti(description, url, user):
     new_key = keygen.gen_random_key()
     data = {
         'key': new_key,
         'description': str(description),
         'nlikes': 0,
         'url': url,
         'user': user
     }
     db.create(Graffiti.entry + '/' + new_key, data)
     return Graffiti(key=new_key,
                     description=description,
                     n_likes=0,
                     url=url,
                     user=User.get_by_uid(user))
Beispiel #10
0
def start():
    if request.method == 'POST':  # when an user enters with Google
        email = request.form['email']
        uid = request.form['uid']
        display_name = request.form['displayName']
        profile_picture = request.form['profilePicture']
        user = User.get_by_uid(uid)
        if user is None:
            User.create_user(uid, email, display_name, profile_picture)
        session['current_user_email'] = email
        session['current_user_uid'] = uid
        session['current_user_display_name'] = display_name
        session['current_user_profile_picture'] = profile_picture
        return json.dumps({'status': 'OK'})
    else:
        if 'current_user_uid' in session:
            return redirect(url_for('show_home'))
        else:
            return render_template('login.html', title='YATAM - Login')
 def create_user_leisure(name, description, address, url_photo, schedule,
                         coordinates, user):
     new_key = keygen.gen_random_key()
     data = {
         'key': new_key,
         'name': name,
         'description': str(description),
         'address': address,
         'url_photo': url_photo,
         'schedule': schedule,
         'coordinates': coordinates,
         'user': user,
         'nlikes': 0
     }
     db.create(UserLeisure.entry + '/' + new_key, data)
     return UserLeisure(key=new_key,
                        description=description,
                        name=name,
                        address=address,
                        url_photo=url_photo,
                        schedule=schedule,
                        coordinates=coordinates,
                        user=User.get_by_uid(user))