diff --git a/api/user.py b/api/user.py index f1122a0..fd8aa24 100644 --- a/api/user.py +++ b/api/user.py @@ -13,7 +13,7 @@ api = Api(user_api) class UserAPI: - class _CRUD(Resource): # User API operation for Create, Read. THe Update, Delete methods need to be implemeented + class _CRUD(Resource): # User API operation for Create, Read. The Update, Delete methods need to be implemented @token_required def post(self, current_user): # Create method ''' Read data for json body ''' @@ -64,6 +64,7 @@ def post(self, current_user): # Create method @token_required def get(self, current_user): # Read Method users = User.query.all() # read/extract all users from database + print("dis be what we fetchin boys...", users[3].__dict__) json_ready = [user.read() for user in users] # prepare output in json return jsonify(json_ready) # jsonify creates Flask response object, more specific to APIs than json.dumps diff --git a/main.py b/main.py index f2e3331..eabac76 100644 --- a/main.py +++ b/main.py @@ -65,14 +65,16 @@ def before_request(): @custom_cli.command('generate_data') def generate_data(): initUsers() + print("USers have been stinking created...") initPlayers() initCharClasses() initCurrentChars() # Register the custom command group with the Flask application app.cli.add_command(custom_cli) +initUsers() # this runs the application on the development server if __name__ == "__main__": - # change name for testing + # change name for testing (port 8086) app.run(debug=True, host="0.0.0.0", port="8086") diff --git a/model/users.py b/model/users.py index adef4f6..83e60e3 100644 --- a/model/users.py +++ b/model/users.py @@ -86,7 +86,7 @@ class User(db.Model): posts = db.relationship("Post", cascade='all, delete', backref='users', lazy=True) # constructor of a User object, initializes the instance variables within object (self) - def __init__(self, name, uid, password="123qwerty", dob=date.today(), Nick="", role="User", wins="0"): + def __init__(self, name, uid, wins, password="123qwerty", dob=date.today(), Nick="", role="User"): self._name = name # variables with self prefix become part of the object, self._uid = uid self.set_password(password) @@ -95,7 +95,6 @@ def __init__(self, name, uid, password="123qwerty", dob=date.today(), Nick="", r self._role = role self._wins = wins - @property def role(self): return self._role @@ -178,7 +177,7 @@ def wins(self): @wins.setter def wins(self, wins): - self.wins = wins + self._wins = wins # output content using str(object) in human readable form, uses getter # output content using json dumps, this is ready for API response def __str__(self): @@ -247,11 +246,11 @@ def initUsers(): """Create database and tables""" db.create_all() """Tester data for table""" - u1 = User(name='Thomas Edison', uid='toby', password='123toby', dob=date(1847, 2, 11), Nick='Tom') - u2 = User(name='Nicholas Tesla', uid='niko', password='123niko', dob=date(1856, 7, 10), Nick='Nikky') - u3 = User(name='Alexander Graham Bell', uid='lex') - u4 = User(name='Grace Hopper', uid='hop', password='123hop', dob=date(1906, 12, 9), Nick='Gracy') - u5 = User(name='Grayson Guyot', uid='Gray', password='123Gray', dob=date(2008, 6, 2), Nick='Gray', role="Admin", wins='0') + u1 = User(name='Thomasasdfghjkl Edison', uid='toby', password='123toby', dob=date(1847, 2, 11), Nick='Tom', wins=1) + u2 = User(name='Nicholas Tesla', uid='niko', password='123niko', dob=date(1856, 7, 10), Nick='Nikky', wins=89) + u3 = User(name='The_goat', uid='goat', wins=1) + u4 = User(name='Nate-the-great', uid='nate', password='123nate', dob=date(2007, 10, 19), Nick='Gracy', wins=5) + u5 = User(name='Grayson Guyot', uid='Gray', password='123Gray', dob=date(2008, 6, 2), Nick='Gray', role="Admin", wins=0) users = [u1, u2, u3, u4, u5] """Builds sample user/note(s) data"""