Skip to content
Snippets Groups Projects

auth

6 files
+ 24
11
Compare changes
  • Side-by-side
  • Inline

Files

+ 15
4
@@ -183,7 +183,18 @@ def get_comments(place: str, page: int, db: Session):
if page == 0:
comments = db.query(models.Comments).order_by(models.Comments.published_at.desc(), models.Comments.id.desc()).all()
else:
comments = db.query(models.Comments, models.Users.username).join(models.Users).filter(models.Comments.place == place).order_by(models.Comments.published_at.desc(), models.Comments.id.desc()).slice((page - 1) * 20, page * 20).all()
comments = db.query(
models.Comments,
models.Users.username).join(
models.Users).filter(
models.Comments.place == place).order_by(
models.Comments.published_at.desc(),
models.Comments.id.desc()).slice(
(page -
1) *
20,
page *
20).all()
return list(schemas.Comment(**comment.__dict__, username=username) for comment, username in comments)
@@ -369,14 +380,14 @@ def update_user(user: schemas.User, user_info: dict, db: Session):
existing_user.cookie = user.cookie
existing_user.expiration_date = expiration_date
db.delete(user)
db.add(existing_user)
db.add(existing_user)
db.commit()
db.refresh(existing_user)
return existing_user
else:
user.username = full_name
user.expiration_date = expiration_date
db.add(user)
db.add(user)
db.commit()
db.refresh(user)
return user
@@ -387,4 +398,4 @@ def end_session(cookie: str, db: Session):
user.expiration_date = datetime.now(tz=pytz.timezone("Europe/Paris"))
db.add(user)
db.commit()
return
\ No newline at end of file
return
Loading