From 609bec7aab9f02e61748f1da4d94830689c3efe6 Mon Sep 17 00:00:00 2001
From: Antoine Gaudron-desjardins <antoine.gaudrondesjardins@student-cs.fr>
Date: Fri, 15 Jul 2022 11:43:45 +0200
Subject: [PATCH] linting

---
 backend/db/crud.py                  | 19 +++++++++++++++----
 backend/db/models.py                |  2 +-
 backend/db/schemas.py               |  4 ++--
 backend/routers/__init__.py         |  2 +-
 backend/routers/authentication.py   |  4 ++--
 frontend/src/components/Comments.js |  4 +++-
 6 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/backend/db/crud.py b/backend/db/crud.py
index a78139b..246b0f6 100644
--- a/backend/db/crud.py
+++ b/backend/db/crud.py
@@ -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
diff --git a/backend/db/models.py b/backend/db/models.py
index 13ea196..ff985da 100644
--- a/backend/db/models.py
+++ b/backend/db/models.py
@@ -62,4 +62,4 @@ class Users(Base):
     username = Column(String(50))
     cookie = Column(String(50))
     expiration_date = Column(DateTime)
-    comments = relationship("Comments")
\ No newline at end of file
+    comments = relationship("Comments")
diff --git a/backend/db/schemas.py b/backend/db/schemas.py
index 86bb23b..55e13ba 100644
--- a/backend/db/schemas.py
+++ b/backend/db/schemas.py
@@ -30,7 +30,7 @@ class CommentBase(BaseModel):
 class Comment(CommentBase):
     """Comments reading schema"""
     id: int
-    username : str = Field(..., title="Name of the user posting the comment")
+    username: str = Field(..., title="Name of the user posting the comment")
     published_at: datetime = Field(..., title="Publication date of the comment")
     place: str = Field(..., title="Name of the RU corresponding the comment")
 
@@ -78,4 +78,4 @@ class User(BaseModel):
     state: str
     username: str
     cookie: str
-    expiration_date: datetime
\ No newline at end of file
+    expiration_date: datetime
diff --git a/backend/routers/__init__.py b/backend/routers/__init__.py
index 92c71e3..b751487 100644
--- a/backend/routers/__init__.py
+++ b/backend/routers/__init__.py
@@ -2,4 +2,4 @@ from . import authentication
 from . import comments
 from . import news
 from . import opening_hours
-from . import stats
\ No newline at end of file
+from . import stats
diff --git a/backend/routers/authentication.py b/backend/routers/authentication.py
index 856493d..df409df 100644
--- a/backend/routers/authentication.py
+++ b/backend/routers/authentication.py
@@ -54,7 +54,7 @@ async def login(code: Optional[str] = None, state: Optional[str] = None, connect
         "client_id": os.getenv("CLIENT_ID"),
         "client_secret": os.getenv("CLIENT_SECRET"),
     }
-    
+
     token_response = post(
         f"{os.getenv('AUTH_ROOT')}/oauth/token",
         data=data,
@@ -76,4 +76,4 @@ async def delete_session(connect_id: str = Cookie(...), db: Session = Depends(ge
     response = RedirectResponse(f"{os.getenv('AUTH_ROOT')}/logout?{urlencode({'redirect_logout': os.getenv('WEB_ROOT')})}")
     response.delete_cookie(key="connect_id")
     crud.end_session(connect_id, db)
-    return response
\ No newline at end of file
+    return response
diff --git a/frontend/src/components/Comments.js b/frontend/src/components/Comments.js
index 2b93bcf..a195b65 100644
--- a/frontend/src/components/Comments.js
+++ b/frontend/src/components/Comments.js
@@ -152,7 +152,9 @@ export default function Messages({ place, infos }) {
             let [year, month, day] = date.split("-");
             return (
               <div key={index} className="comment">
-                <div className={`comment-title${infos ? "-infos" : ""}`}>{infos ? message.title : message.username}</div>
+                <div className={`comment-title${infos ? "-infos" : ""}`}>
+                  {infos ? message.title : message.username}
+                </div>
                 <div className="comment-content">{message.content}</div>
                 <div className="comment-date">
                   {`À ${hour.substring(0, 5)} le ${day}/${month}/${year}`}
-- 
GitLab