Beispiel #1
0
 def __init__(self,
              key=None,
              user=None,
              leisure=None,
              grade=None,
              text=None):
     if key is not None and user is None and leisure is None and grade is None and text is None:
         # e.g. __init__(key)
         r = db.search_by_key('ratings', key)
         self.user = r['user']
         self.leisure = r['leisure']
         self.grade = r['grade']
         self.text = r['text']
     elif key is None and user is not None and leisure is not None and grade is not None and text is not None:
         # e.g. __init__(user, leisure, grade, text)
         db.create('ratings', {
             'user': user,
             'leisure': leisure,
             'grade': grade,
             'text': text
         })
         self.user = user
         self.leisure = leisure
         self.grade = grade
         self.text = text
 def __init__(self, key=None, name=None, text=None):
     if key is not None and name is None and text is None:
         t = db.search_by_key('trophies', key)
         self.name = t['name']
         self.text = t['text']
     elif key is None and name is not None and text is not None:
         db.create('trophies', {'name': name, 'text': text})
         self.name = name
         self.text = text
 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
 def search_by_trophy_key(key):
     return db.search_by_key('trophies', key)
Beispiel #5
0
 def search_by_id(key):
     r = db.search_by_key('ratings', key)
     if r is not None:
         return r
     else:
         return f'No rating has been found with rating id : "{key}".'
 def search_by_key(key):
     r = db.search_by_key('users', key)
     if r is None:
         return f'No user has been found with key : "{key}".'
     else:
         return r