Add get info
This commit is contained in:
parent
bd6b87177d
commit
c6edcc73e8
@ -190,3 +190,24 @@ def upload_project_files() -> flask.Response:
|
||||
os.mkdir(f"./data/project-files/{team_id}")
|
||||
file.save(f"./data/project-files/{team_id}/{file_name}")
|
||||
return flask.Response()
|
||||
|
||||
|
||||
@app.post("/get-info")
|
||||
def get_info() -> flask.Response:
|
||||
info: dict = {
|
||||
"team_members" : [],
|
||||
"project_details": {},
|
||||
"project_files": [],
|
||||
}
|
||||
try:
|
||||
user_id = flask.session["user_id"]
|
||||
except KeyError:
|
||||
return flask.Response("Not logged in", 428)
|
||||
team_id = utils.UserHandler.get_user_by_id(user_id).team_id
|
||||
team_members = utils.TeamHandler.get_team_members(team_id)
|
||||
print(team_members)
|
||||
for team_member in team_members:
|
||||
info["team_members"].append(utils.UserHandler.get_user_by_id(team_member).to_dict())
|
||||
info["project_details"] = vars(utils.TeamHandler.get_project(team_id))
|
||||
info["project_files"] = os.listdir(f"./data/project-files/{team_id}")
|
||||
return flask.jsonify(info)
|
||||
|
@ -68,7 +68,7 @@ class TeamHandler:
|
||||
""",
|
||||
(team_id, )
|
||||
).fetchall()
|
||||
return users
|
||||
return [user[0] for user in users]
|
||||
|
||||
@classmethod
|
||||
def update_project_information(
|
||||
@ -105,3 +105,24 @@ class TeamHandler:
|
||||
)
|
||||
)
|
||||
cls.__connection.commit()
|
||||
|
||||
@classmethod
|
||||
def get_project(cls, team_id: int) -> Team:
|
||||
teams = cls.__cursor.execute(
|
||||
f"""
|
||||
SELECT * FROM teams WHERE team_id = ?
|
||||
""", (team_id, )
|
||||
).fetchall()[0]
|
||||
return Team(
|
||||
teams[0],
|
||||
teams[1],
|
||||
teams[2],
|
||||
teams[3],
|
||||
teams[4],
|
||||
teams[5],
|
||||
teams[6],
|
||||
teams[7],
|
||||
teams[8],
|
||||
teams[9],
|
||||
teams[10],
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user