Skip to content

Commit

Permalink
should be 1 error test now
Browse files Browse the repository at this point in the history
  • Loading branch information
Vucis committed Mar 14, 2024
1 parent 511024a commit f4e6eb8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
1 change: 0 additions & 1 deletion backend/project/endpoints/courses/courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def post(self, teacher_id=None):
This function will create a new course
if the body of the post contains a name and uid is an admin or teacher
"""
# TODO add teacher_id in request
req = request.json
req["teacher"] = teacher_id
return insert_into_model(
Expand Down
4 changes: 2 additions & 2 deletions backend/project/endpoints/projects/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from flask_restful import Resource

from project.models.project import Project
from project.utils.query_agent import query_selected_from_model, insert_into_model
from project.utils.query_agent import query_selected_from_model, create_model_instance
from project.utils.authentication import authorize_teacher

from project.endpoints.projects.endpoint_parser import parse_project_params
Expand Down Expand Up @@ -54,7 +54,7 @@ def post(self, teacher_id=None):

# save the file that is given with the request
try:
new_project, status_code = insert_into_model(
new_project, status_code = create_model_instance(
Project,
project_json,
urljoin(f"{API_URL}/", "/projects"),
Expand Down
13 changes: 7 additions & 6 deletions backend/project/endpoints/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ def get(self) -> dict[str, any]:

# Filter by uid
uid = request.args.get("uid")
if uid:
if session.get(User, uid):
if uid is not None:
if session.get(User, uid) is not None:
query = query.filter_by(uid=uid)
else:
data["message"] = f"Invalid user (uid={uid})"
return data, 400
else:
query = query.filter_by(uid=uid)

# Filter by project_id
project_id = request.args.get("project_id")
if project_id is not None:
Expand Down Expand Up @@ -146,7 +147,7 @@ class SubmissionEndpoint(Resource):

@authorize_submission_request
def get(self, submission_id: int) -> dict[str, any]:
"""Get the submission given a submission ID
"""Get the submission given an submission ID
Args:
submission_id (int): Submission ID
Expand Down Expand Up @@ -275,4 +276,4 @@ def delete(self, submission_id: int) -> dict[str, any]:
submissions_bp.add_url_rule(
"/submissions/<int:submission_id>",
view_func=SubmissionEndpoint.as_view("submission")
)
)
2 changes: 1 addition & 1 deletion backend/project/utils/query_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,4 @@ def patch_by_id_from_model(model: DeclarativeMeta,
"url": urljoin(f"{base_url}/", str(column_id))}), 200
except SQLAlchemyError:
return {"error": "Something went wrong while updating the database.",
"url": base_url}, 500
"url": base_url}, 500

0 comments on commit f4e6eb8

Please sign in to comment.