Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend/feature/projects endpoint #31

Merged
merged 83 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
91e6dd6
route /projects/ added
Gerwoud Feb 24, 2024
de332a7
added functionality for parsing the dict once the query is ran
Gerwoud Feb 25, 2024
b032e39
display json data at endpoint instead of dummy data
Gerwoud Feb 25, 2024
9f5e4f3
detail endpoint created
Gerwoud Feb 25, 2024
2dc1340
post functionality for projects
Gerwoud Feb 25, 2024
aed5d38
remove functionality for projects, only works with updated sql script
Gerwoud Feb 25, 2024
eeb38b5
added right exit codes
Gerwoud Feb 25, 2024
e1125c2
code reformat
Gerwoud Feb 25, 2024
6475ea5
added 404 page if you're trying to remove a non-existing project
Gerwoud Feb 25, 2024
c6fb5eb
404 function made
Gerwoud Feb 25, 2024
3399e6d
added basic add and remove test for project
Gerwoud Feb 25, 2024
100572a
wrote extra test for just getting the users
Gerwoud Feb 25, 2024
aa0269d
added put for a project
Gerwoud Feb 25, 2024
792ddd9
added test for put
Gerwoud Feb 25, 2024
28b82fa
testing working
Gerwoud Feb 25, 2024
5db9ded
added comments to project_test project and projects_detail
Gerwoud Feb 25, 2024
8bd67ae
added pytest fixture
Gerwoud Feb 26, 2024
3ec266d
added right dummy data for fixtures
Gerwoud Feb 26, 2024
f9295fc
linter fixes, project endpoint files now score 10/10
Gerwoud Feb 26, 2024
3cedf3e
more linter fixes
Gerwoud Feb 26, 2024
7206efa
linter import order fix
Gerwoud Feb 26, 2024
b3a53bd
added ingores for linter
Gerwoud Feb 26, 2024
5be4c0a
more linter
Gerwoud Feb 26, 2024
061dbd8
renamed is_existing_project function
Gerwoud Feb 26, 2024
5b544f9
changed arguments of get functions to not use **kwargs anymore
Gerwoud Feb 26, 2024
9f5033a
fixed jsonify issue for response
Gerwoud Feb 26, 2024
dacc4f6
added try catch blocks and changed Message to message
Gerwoud Feb 26, 2024
672aea8
applied jsonify on projects
Gerwoud Feb 26, 2024
167efd3
removed print statement
Gerwoud Feb 26, 2024
deaaebb
removed unnecessary session.commit
Gerwoud Feb 26, 2024
794a797
test if tests still work on git
Gerwoud Feb 26, 2024
3b3792f
added the commit messages again
Gerwoud Feb 26, 2024
af7d44d
better tests, pray for git tests
Gerwoud Feb 27, 2024
a9ade40
fixed TODO of path.append('.')
Gerwoud Feb 27, 2024
13554fa
fixed code duplication for parser (hopefully)
Gerwoud Feb 27, 2024
f41cd84
fixed non existing fields in testing bug
Gerwoud Feb 27, 2024
e27d270
fixed parse code duplication
Gerwoud Feb 27, 2024
56af6bc
linter fixes
Gerwoud Feb 27, 2024
f908303
more linter fixes
Gerwoud Feb 27, 2024
d10fcf6
removed linter disables
Gerwoud Feb 28, 2024
054f90d
fixed linter import order
Gerwoud Feb 28, 2024
dd0f7fe
removed unused imports
Gerwoud Feb 28, 2024
0b58bab
removed unused comment
Gerwoud Feb 28, 2024
0e73d09
removed print statement and unused comments
Gerwoud Feb 28, 2024
3b8aee3
changed put to patch
Gerwoud Feb 28, 2024
42f20f7
fixed wrong status code
Gerwoud Feb 28, 2024
d16b10f
removed useless comment
Gerwoud Feb 28, 2024
60ae98b
added message field to return json
Gerwoud Feb 28, 2024
ae817d6
removed all fields from /projects get except project_id, title and de…
Gerwoud Feb 28, 2024
f6d2157
added try catch block to post of projects endpoint
Gerwoud Feb 28, 2024
7a397f1
removed print statements
Gerwoud Feb 28, 2024
8a1f467
removed commented code
Gerwoud Feb 28, 2024
d5b07bb
changed the get from tuple to a json
Gerwoud Feb 28, 2024
de7a616
linter fix
Gerwoud Feb 28, 2024
7648d81
edited OpenAPI_Object
Gerwoud Feb 29, 2024
c2dfb3f
linter fix
Gerwoud Feb 29, 2024
1d23226
fixed no module named project error
Gerwoud Feb 29, 2024
320030e
added file sessionmaker for code duplication purposes
Gerwoud Feb 29, 2024
41400af
Thanks for this linter for helping me improve my code :)
Gerwoud Feb 29, 2024
04d8976
added root point conftest.py
Gerwoud Feb 29, 2024
d74f764
added root point conftest.py
Gerwoud Mar 1, 2024
a72ef10
added try catch block
Gerwoud Mar 1, 2024
15fa782
removed commented code
Gerwoud Mar 2, 2024
85cce0b
removed print statements
Gerwoud Mar 2, 2024
87255c1
return whole URL of project instead of just the id
Gerwoud Mar 2, 2024
c994225
small linter fixes :)
Gerwoud Mar 2, 2024
4b667bf
load the env variable at the start of file as constant
Gerwoud Mar 2, 2024
ec323bb
paths attribute should be an object, not a list
AronBuzogany Mar 2, 2024
09c2117
patched patch function
Gerwoud Mar 3, 2024
f992a55
fixed typo in patch
Gerwoud Mar 3, 2024
81b2740
fixed json return in 500 patch message
Gerwoud Mar 3, 2024
c68b01a
fixed url returns
Gerwoud Mar 3, 2024
3cfa66f
fix: wrapped project json with seperate message
Gerwoud Mar 3, 2024
eabcc85
fix: keyerror on tests with change of return json in projects POST me…
Gerwoud Mar 3, 2024
c90dfac
fix: return good json representation
Gerwoud Mar 3, 2024
604cd92
fixed typos in OpenAPI_Object.json
Gerwoud Mar 3, 2024
97f0866
fixed typos in project_detail
Gerwoud Mar 3, 2024
b89f5b3
fixed typos in model Projects
Gerwoud Mar 3, 2024
5c2b718
typo fixed
Gerwoud Mar 4, 2024
12b1a29
route -> routes
Gerwoud Mar 4, 2024
4425192
Merge branch 'development' into backend/feature/projects-endpoint
Gerwoud Mar 5, 2024
cdd94d2
fix: naming of new database schemes
Gerwoud Mar 5, 2024
e055344
i <3 linters
Gerwoud Mar 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from flask import Flask
from .db_in import db
from .endpoints.index.index import index_bp
from .endpoints.projects.project_endpoint import project_bp
from .endpoints.courses import courses_bp


Expand All @@ -18,6 +19,7 @@ def create_app():

app = Flask(__name__)
app.register_blueprint(index_bp)
app.register_blueprint(project_bp)
app.register_blueprint(courses_bp)

return app
Expand Down
201 changes: 193 additions & 8 deletions backend/project/endpoints/index/OpenAPI_Object.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,192 @@
]
},
"paths": {

"/projects": {
"get": {
"description": "Returns all projects from the database that the user has access to",
"responses": {
"200": {
"description": "A list of projects",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"project_id": {
"type": "int"
},
"descriptions": {
"type": "string"
},
"title": {
"type": "string"
}
}
}
}
}
}
}
}
},
"post": {
"description": "Upload a new project",
"responses": {
"201": {
"description": "Uploaded a new project succesfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": "string"
}
}
}
}
}
}
}
},
"/projects/{id}": {
"get": {
"description": "Return a project with corresponding id",
"responses": {
"200": {
"description": "A project with corresponding id",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"archieved": {
"type": "bool"
},
"assignment_file": {
"type": "string"
},
"course_id": {
"type": "int"
},
"deadline": {
"type": "date"
},
"descriptions": {
"type": "array",
"items": {
"description": "string"
}
},
"project_id": {
"type": "int"
},
"regex_expressions": {
"type": "array",
"items": {
"regex": "string"
}
},
"script_name": {
"type": "string"
},
"test_path": {
"type": "string"
},
"title": {
"type": "string"
},
"visible_for_students": {
"type": "bool"
}
}
}
}
}
},
"404": {
"description": "An id that doesn't correspond to an existing project",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
}
}
}
},
"patch": {
"description": "Patch certain fields of a project",
"responses": {
"200": {
"description": "Patched a project succesfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": "string"
}
}
}
}
},
"404": {
"description": "Tried to patch a project that is not present",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
}
}
}
},
"delete": {
"description": "Delete a project with given id",
"responses": {
"200": {
"description": "Removed a project succesfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": "string"
}
}
}
}
},
"404": {
"description": "Tried to remove a project that is not present",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": "string"
}
}
}
}
}
}
}
},
"/courses": {
"get": {
"description": "Get a list of all courses.",
Expand Down Expand Up @@ -85,7 +270,7 @@
}
}
}
}
}
},
"parameters": [
{
Expand All @@ -111,7 +296,7 @@
"schema": {
"type": "string"
}
}
}
]
},
"post": {
Expand Down Expand Up @@ -611,7 +796,7 @@
}
},
"post":{
"description": "Assign students to a course.",
"description": "Assign students to a course.",
"parameters": [
{
"name": "course_id",
Expand Down Expand Up @@ -733,7 +918,7 @@
}
}
}
}
}
},
"delete":{
"description": "Remove students from a course.",
Expand Down Expand Up @@ -918,7 +1103,7 @@
}
},
"post":{
"description": "Assign admins to a course.",
"description": "Assign admins to a course.",
"parameters": [
{
"name": "course_id",
Expand Down Expand Up @@ -1040,7 +1225,7 @@
}
}
}
}
}
},
"delete":{
"description": "Remove an admin from a course.",
Expand Down Expand Up @@ -1156,6 +1341,6 @@
}
}
}

}
}
31 changes: 31 additions & 0 deletions backend/project/endpoints/projects/endpoint_parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Parser for the argument when posting or patching a project
"""

from flask_restful import reqparse

parser = reqparse.RequestParser()
parser.add_argument('title', type=str, help='Projects title')
parser.add_argument('descriptions', type=str, help='Projects description')
parser.add_argument('assignment_file', type=str, help='Projects assignment file')
parser.add_argument("deadline", type=str, help='Projects deadline')
parser.add_argument("course_id", type=str, help='Projects course_id')
parser.add_argument("visible_for_students", type=bool, help='Projects visibility for students')
parser.add_argument("archieved", type=bool, help='Projects')
parser.add_argument("test_path", type=str, help='Projects test path')
parser.add_argument("script_name", type=str, help='Projects test script path')
parser.add_argument("regex_expressions", type=str, help='Projects regex expressions')


def parse_project_params():
"""
Return a dict of every non None value in the param
"""
args = parser.parse_args()
result_dict = {}

for key, value in args.items():
if value is not None:
result_dict[key] = value

return result_dict
Loading