Skip to content

Commit

Permalink
Updated docs and .gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
JibrilExe committed Feb 22, 2024
1 parent 16a0d38 commit ba36b8a
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 15 deletions.
2 changes: 1 addition & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ htmlcov/
docs/_build/
dist/
venv/
*.env
.env
2 changes: 0 additions & 2 deletions backend/environment.env

This file was deleted.

11 changes: 9 additions & 2 deletions backend/project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions backend/project/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
5 changes: 3 additions & 2 deletions backend/project/endpoints/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!"}


Expand Down
5 changes: 4 additions & 1 deletion backend/project/models/course_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion backend/project/models/courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion backend/project/models/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion backend/project/models/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion backend/project/models/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ba36b8a

Please sign in to comment.