diff --git a/backend/.gitignore b/backend/.gitignore index 5b635eef..25343357 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -8,4 +8,4 @@ htmlcov/ docs/_build/ dist/ venv/ -*.env +.env diff --git a/backend/environment.env b/backend/environment.env deleted file mode 100644 index 4d652d51..00000000 --- a/backend/environment.env +++ /dev/null @@ -1,2 +0,0 @@ -DB_HOST=postgresql://postgres:postgres@localhost:5432/sel3_db - diff --git a/backend/project/__init__.py b/backend/project/__init__.py index e38de8a9..66435003 100644 --- a/backend/project/__init__.py +++ b/backend/project/__init__.py @@ -20,8 +20,15 @@ def create_app(): return app -def init_db(db_uri): - """Initialize the database with the given uri""" +def create_app_with_db(db_uri:str): + """ + Initialize the database with the given uri + and connect it to the app made with create_app. + Parameters: + db_uri (str): The URI of the database to initialize. + Returns: + Flask -- A Flask application instance + """ app = create_app() app.config["SQLALCHEMY_DATABASE_URI"] = db_uri db.init_app(app) diff --git a/backend/project/__main__.py b/backend/project/__main__.py index c90b8d38..9448b0eb 100644 --- a/backend/project/__main__.py +++ b/backend/project/__main__.py @@ -2,11 +2,11 @@ from sys import path from os import getenv from dotenv import load_dotenv -from project import init_db +from project import create_app_with_db path.append(".") if __name__ == "__main__": - load_dotenv(dotenv_path='environment.env') - app = init_db(getenv("DB_HOST")) + load_dotenv() + app = create_app_with_db(getenv("DB_HOST")) app.run(debug=True) diff --git a/backend/project/endpoints/index.py b/backend/project/endpoints/index.py index 94096189..e5b68473 100644 --- a/backend/project/endpoints/index.py +++ b/backend/project/endpoints/index.py @@ -6,10 +6,11 @@ class Index(Resource): - """Temporary""" + """Api endpoint for the / route""" def get(self): - """Hello world""" + """Example of an api endpoint function that will respond to get requests made to / + return a json data structure with key Message and value Hello World!""" return {"Message": "Hello World!"} diff --git a/backend/project/models/course_relations.py b/backend/project/models/course_relations.py index 277c61f6..7b30ad48 100644 --- a/backend/project/models/course_relations.py +++ b/backend/project/models/course_relations.py @@ -5,7 +5,10 @@ from project import db class BaseCourseRelation(db.Model): - """Base class for course relation models""" + """Base class for course relation models, + both course relation tables have a + course_id of the course to wich someone is related and + an uid of the related person""" __abstract__ = True diff --git a/backend/project/models/courses.py b/backend/project/models/courses.py index b1f73a39..7a105881 100644 --- a/backend/project/models/courses.py +++ b/backend/project/models/courses.py @@ -5,7 +5,8 @@ class Courses(db.Model): - """Course model""" + """This class described the courses table, + a course has an id, name, optional ufora id and the teacher that created it""" __tablename__ = "courses" course_id = Column(Integer, primary_key=True) diff --git a/backend/project/models/projects.py b/backend/project/models/projects.py index 19ade7a2..68f68ae9 100644 --- a/backend/project/models/projects.py +++ b/backend/project/models/projects.py @@ -4,7 +4,14 @@ from project import db class Projects(db.Model): - """Project model""" + """This class describes the projects table, + a projects has an id, a title, a description, + an optional assignment file that can contain more explanation of the projects, + an optional deadline, + the course id of the course to which the project belongs, + visible for students variable so a teacher can decide if the students can see it yet, + archieved var so we can implement the archiving functionality, + a test path,script name and regex experssions for automated testing""" __tablename__ = "projects" project_id = Column(Integer, primary_key=True) diff --git a/backend/project/models/submissions.py b/backend/project/models/submissions.py index 78889337..5b20cee4 100644 --- a/backend/project/models/submissions.py +++ b/backend/project/models/submissions.py @@ -4,7 +4,15 @@ from project import db class Submissions(db.Model): - """Submission model""" + """This class describes the submissions table, + submissions can be made to a project, a submission has + and id, a uid from the user that uploaded it, + the project id of the related project, + an optional grading, + the submission time, + submission path, + and finally the submission status + so we can easily present in a list which submission succeeded the automated checks""" __tablename__ = "submissions" submission_id = Column(Integer, nullable=False, primary_key=True) diff --git a/backend/project/models/users.py b/backend/project/models/users.py index 15e965b1..c5af5287 100644 --- a/backend/project/models/users.py +++ b/backend/project/models/users.py @@ -5,7 +5,10 @@ class Users(db.Model): - """User model""" + """This class defines the users table, + a user has an uid, + is_teacher and is_admin booleans because a user + can be either a student,admin or teacher""" __tablename__ = "users" uid = Column(String(255), primary_key=True)