Add update ideas
This commit is contained in:
parent
5f26b48c04
commit
65db6d350a
Binary file not shown.
@ -1,3 +1,4 @@
|
||||
from re import T
|
||||
import secrets
|
||||
import sqlite3
|
||||
import flask
|
||||
@ -151,6 +152,23 @@ def delete_member() -> flask.Response:
|
||||
utils.UserHandler.delete_member(flask.request.form["mail"], user_id)
|
||||
except AssertionError:
|
||||
return flask.Response("User doesn't exist", 404)
|
||||
except KeyError as e:
|
||||
except KeyError:
|
||||
return flask.Response("mail doesn't exist", 422)
|
||||
return flask.Response()
|
||||
|
||||
|
||||
@app.post("/update-ideas")
|
||||
def update_ideas() -> flask.Response:
|
||||
try:
|
||||
user_id = flask.session["user_id"]
|
||||
except KeyError:
|
||||
return flask.Response("Not logged in", 428)
|
||||
try:
|
||||
team_id = utils.UserHandler.get_user_by_id(user_id).team_id
|
||||
utils.TeamHandler.update_project_information(utils.Team(
|
||||
team_id=team_id,
|
||||
**flask.request.form,
|
||||
))
|
||||
except KeyError:
|
||||
return flask.Response("Something is missing", 422)
|
||||
return flask.Response()
|
||||
|
@ -8,16 +8,40 @@ class Team:
|
||||
project_folder: str
|
||||
team_name: str
|
||||
is_related_to_special_topics: bool
|
||||
problem_statement: str
|
||||
title: str
|
||||
solution: str
|
||||
abstract: str
|
||||
why_this_problem: str
|
||||
budget: int
|
||||
sector: str
|
||||
project_type: str
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
team_id: int|str,
|
||||
team_name: str,
|
||||
is_related_to_special_topics: bool|int|str
|
||||
is_related_to_special_topics: bool|int|str,
|
||||
problem_statement: str,
|
||||
title: str,
|
||||
solution: str,
|
||||
abstract: str,
|
||||
why_this_problem: str,
|
||||
budget: int|str,
|
||||
sector: str,
|
||||
project_type: str,
|
||||
) -> None:
|
||||
self.team_id = int(team_id)
|
||||
self.team_name = team_name
|
||||
self.is_related_to_special_topics = bool(int(is_related_to_special_topics))
|
||||
self.problem_statement = problem_statement
|
||||
self.title = title
|
||||
self.solution = solution
|
||||
self.abstract = abstract
|
||||
self.why_this_problem = why_this_problem
|
||||
self.budget = int(budget)
|
||||
self.sector = sector
|
||||
self.project_type = project_type
|
||||
|
||||
|
||||
class TeamHandler:
|
||||
@ -45,3 +69,39 @@ class TeamHandler:
|
||||
(team_id, )
|
||||
).fetchall()
|
||||
return users
|
||||
|
||||
@classmethod
|
||||
def update_project_information(
|
||||
cls,
|
||||
team: Team,
|
||||
) -> None:
|
||||
cls.__cursor.execute(
|
||||
f"""
|
||||
UPDATE teams SET
|
||||
team_name=?,
|
||||
is_related_to_special_topics=?,
|
||||
problem_statement=?,
|
||||
title=?,
|
||||
solution=?,
|
||||
abstract=?,
|
||||
why_this_problem=?,
|
||||
budget=?,
|
||||
sector=?,
|
||||
project_type=?
|
||||
WHERE team_id=?
|
||||
""",
|
||||
(
|
||||
team.team_name,
|
||||
team.is_related_to_special_topics,
|
||||
team.problem_statement,
|
||||
team.title,
|
||||
team.solution,
|
||||
team.abstract,
|
||||
team.why_this_problem,
|
||||
team.budget,
|
||||
team.sector,
|
||||
team.project_type,
|
||||
team.team_id,
|
||||
)
|
||||
)
|
||||
cls.__connection.commit()
|
||||
|
Loading…
x
Reference in New Issue
Block a user