-
Notifications
You must be signed in to change notification settings - Fork 1
Conversation
""" | ||
This function will return all the admins of a course | ||
""" | ||
abort_url = API_URL + "/courses/" + str(course_id) + "/admins" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use f-strings
""" | ||
Api endpoint for adding new admins to a course, can only be done by the teacher | ||
""" | ||
abort_url = API_URL + "/courses/" + str(course_id) + "/admins" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use f-strings
""" | ||
Api endpoint for removing admins of a course, can only be done by the teacher | ||
""" | ||
abort_url = API_URL + "/courses/" + str(course_id) + "/admins" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use f-strings
} | ||
|
||
return { | ||
"message": "Succesfully retrieved course with course_id: " + str(course_id), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use f-strings
to get all the users assigned to a course | ||
everyone can get this data so no need to have uid query in the link | ||
""" | ||
abort_url = API_URL + "/courses/" + str(course_id) + "/students" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use f-strings
return json_message(message), 400 | ||
add_abort_if_error(CourseStudent(uid=uid, course_id=course_id), abort_url) | ||
commit_abort_if_error(abort_url) | ||
response = json_message("User were succesfully added to the course") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User -> Users
delete_abort_if_error(student_relation, abort_url) | ||
commit_abort_if_error(abort_url) | ||
|
||
response = json_message("User were succesfully removed from the course") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User -> Users
HTTPException: If the current user is not authorized or | ||
if the UID of the person to be made an admin is missing in the request body. | ||
""" | ||
url = API_URL + "/courses/" + str(course_id) + "/admins" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use f-strings
403: If the user is not authorized to assign new students to the course. | ||
400: If the request body does not contain the required 'students' field. | ||
""" | ||
url = API_URL + "/courses/" + str(course_id) + "/students" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use f-strings
backend/project/utils/misc.py
Outdated
@@ -0,0 +1,76 @@ | |||
""" | |||
This module contains functions that are not related to anything specific but | |||
are ought to be used throughout the project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but are ought is wrong, you can say the functions ought to be used if they should be used, or the functions are usable if they can be used
backend/project/utils/query_agent.py
Outdated
return jsonify({ | ||
"data": new_instance, | ||
"message": "Object created succesfully.", | ||
"url": urljoin(response_url_base, str(getattr(new_instance, url_id_field)))}), 201 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be
url": urljoin(response_url_base + "/", str(getattr(new_instance, url_id_field)))}), 201
otherwise the response url won't be returned correctly
No description provided.