Ejemplo n.º 1
0
 def search_by_user_and_leisure(user, leisure):
     data = None
     d = db.get_dict('ratings', 'user', user)
     for r in d:
         data = d[r]
         if data['leisure'] == leisure:
             break
         else:
             data = None
     if data is not None:
         return data
     else:
         return f'No rating has been found with user id : "{user}" and leisure id : "{leisure}".'
Ejemplo n.º 2
0
 def __init__(self, key=None, email=None, username=None, password=None):
     # e.g. __init__(key)
     if key is not None and email is None and username is None and password is None:
         u = db.search_by_key('users', key)
         self.email = u['email']
         self.username = u['username']
         self.password = u['password']
         self.ratings = db.get_dict('ratings', 'user', key)
     # e.g. __init__(email=email, username=username, password=password)
     elif key is None and email is not None and username is not None and password is not None:
         db.create('users', {
             'email': email,
             'username': username,
             'password': password
         })
         self.email = email
         self.username = username
         self.password = password
Ejemplo n.º 3
0
 def search_by_name(name):
     return db.get_dict('trophies', 'name', name)
Ejemplo n.º 4
0
 def get_dict():
     return db.get_dict('trophies')
Ejemplo n.º 5
0
 def search_by_leisure(leisure):
     r = db.get_dict('ratings', 'leisure', leisure)
     if r is not None:
         return r
     else:
         return f'No rating has been found with leisure id : "{leisure}".'
Ejemplo n.º 6
0
 def search_by_user(user):
     r = db.get_dict('ratings', 'user', user)
     if r is not None:
         return r
     else:
         return f'No rating has been found with user id : "{user}".'
Ejemplo n.º 7
0
 def get_dict():
     return db.get_dict('ratings')
Ejemplo n.º 8
0
 def search_by_username(username):
     r = db.get_dict('users', 'username', username)
     if r is None:
         return f'No user has been found with username : "******".'
     else:
         return r
Ejemplo n.º 9
0
 def search_by_email(email):
     r = db.get_dict('users', 'email', email)
     if r is None:
         return f'No user has been found with email : "{email}".'
     else:
         return r
Ejemplo n.º 10
0
 def get_dict():
     return db.get_dict('users')