Compare commits

..

No commits in common. "c6edcc73e8edac486333219c66e525951c1ceb89" and "65db6d350ab9344b325d6a441a6798ade571570f" have entirely different histories.

3 changed files with 2 additions and 62 deletions

View File

@ -1,4 +1,4 @@
import os from re import T
import secrets import secrets
import sqlite3 import sqlite3
import flask import flask
@ -172,42 +172,3 @@ def update_ideas() -> flask.Response:
except KeyError: except KeyError:
return flask.Response("Something is missing", 422) return flask.Response("Something is missing", 422)
return flask.Response() return flask.Response()
@app.post("/upload-project-file")
def upload_project_files() -> flask.Response:
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
try:
file = flask.request.files["file"]
except KeyError:
return flask.Response("file missing", 422)
file_name = file.filename if file.filename else secrets.token_urlsafe(20)
if not os.path.isdir(f"./data/project-files/{team_id}"):
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)

View File

@ -68,7 +68,7 @@ class TeamHandler:
""", """,
(team_id, ) (team_id, )
).fetchall() ).fetchall()
return [user[0] for user in users] return users
@classmethod @classmethod
def update_project_information( def update_project_information(
@ -105,24 +105,3 @@ class TeamHandler:
) )
) )
cls.__connection.commit() 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],
)