Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhongxuanWang committed Dec 3, 2023
1 parent e2bce3c commit 744851d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
9 changes: 6 additions & 3 deletions src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ def create_app(config=Config()):
def load_user(user):
user_info = str(user).split('_')
user_type, user_id = user_info[0], user_info[1]
print(' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ')
print(user_info)
print(' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ')
if user_type == 'club':
return Club.query.get({'id': user})
return Club.query.get({'id': user_id})
elif user_type == 'admin':
return Admin.query.get({'id': user})
return Admin.query.get({'id': user_id})
elif user_type == 'student':
return Student.query.get({'id': user})
return Student.query.get({'id': user_id})
else:
return None

Expand Down
2 changes: 1 addition & 1 deletion src/clubs/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def signin_club():
if login_user(club, remember=True):
# print(current_user.authenticated)
# print(club.authenticated)
return success_message("Log in success. ")
return success_message(current_user.serialize(ios_style=True))
else:
return failure_message(FAIL_MSG.LOGIN_FAILED)

Expand Down
4 changes: 1 addition & 3 deletions src/models/club.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,18 @@ class Club(db.Model, UserMixin):

fundraisers = db.relationship('Fundraiser', cascade='delete')

authenticated = db.Column(db.Boolean, nullable=False, default=False)
authenticated = db.Column(db.Boolean)

email = db.Column(db.String, nullable=False, unique=True)
password = db.Column(db.String, nullable=False)

@property
def is_authenticated(self):
"""
If the user is authenticated.
:return: True if authenticated. False otherwise.
"""
return self.authenticated

@property
def is_anonymous(self):
"""
Return whether the student cna be anonymous
Expand Down
4 changes: 1 addition & 3 deletions src/models/student.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Student(db.Model, UserMixin):

clubs = db.relationship("Club", secondary=student_club_association_table, back_populates='members')

authenticated = db.Column(db.Boolean, nullable=False, default=False)
authenticated = db.Column(db.Boolean, default=False)

email = db.Column(db.String, nullable=False, unique=True)
password = db.Column(db.String, nullable=False)
Expand All @@ -32,15 +32,13 @@ def get_id(self):
"""
return self.role + "_" + str(self.id)

@property
def is_authenticated(self):
"""
If the user is authenticated.
:return: True if authenticated. False otherwise.
"""
return self.authenticated

@property
def is_anonymous(self):
"""
Return whether the student cna be anonymous
Expand Down
2 changes: 1 addition & 1 deletion src/students/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def signout_student():
"""

if logout_user():
return success_message("Log out success. ")
return success_message(current_user.serialize(ios_style=True))
else:
return failure_message(FAIL_MSG.SIGNOUT_FAILED)

Expand Down

0 comments on commit 744851d

Please sign in to comment.