models package

Submodules

models.base_model module

Models initializer.

class models.base_model.BaseModel(table, fields, primary_key=None, init_table=False)[source]

Bases: object

Base class for the data manipulation and database operations.

create(conn=None, data=None)[source]

Creates a and inserts a database row. Given data dictionary fields must be in database fields.

Parameters:
  • conn – Connection from the db_factory_func.
  • data – Relevant data to insert.
delete(conn=None, query='', return_cols=None)[source]

Deletes a row with given query.

Parameters:
  • conn – Connection from the db_factory_func.
  • query – where sql query string.
  • return_cols – array of fields to return.
delete_by_id(_id, return_cols=None)[source]

Deletes a row with the given id.

Parameters:
  • id – element id number.
  • return_cols – array of fields to return.
find(conn=None, query='', limit=0, sort_by='', return_cols=None, offset=None)[source]

Finds and retrieves data with given query from database.

Parameters:
  • conn – Connection from the db_factory_func.
  • query – where sql query string.
  • limit – sql limit value for select.
  • sort_by – sql sort information.
  • return_cols – array of fields to return.
  • offset – sql offset value.
find_by_id(_id)[source]

Finds one element from database with a given id.

Parameters:id – element id number.
find_one(query='')[source]

Finds one element from database with a given query.

Parameters:query – where sql query string.
update(conn=None, data=None, query='', return_cols=None)[source]

Finds and updates the rows with given query.

Parameters:
  • conn – Connection from the db_factory_func.
  • data – Relevant data to update.
  • query – where sql query string.
  • return_cols – array of fields to return.
update_by_id(_id, data=None, return_cols=None)[source]

Update a row with id.

Parameters:
  • id – element id number.
  • data – Relevant data to update.
  • return_cols – array of fields to return.
models.base_model.db_factory_func(func)[source]

Database connection decorator. Creates a database connection and wraps it with try/expect and gives to given function

Parameters:func – function to decorate.

models.courses module

Course and Student - Course Model

class models.courses.CourseModel(init_table=False)[source]

Bases: models.base_model.BaseModel

Course CRUD operations class.

course_exists(courseid)[source]

Checks if a course exists.

class models.courses.StudentCourseModel(init_table=False)[source]

Bases: models.base_model.BaseModel

Student-Course Relation CRUD operations.

delete_student_course(studentid, courseid)[source]

Deletes a student course row with given ids.

find_student_courses(conn=None, studentid=None)[source]

Finds all the courses of student with given student id.

models.students module

Student Model

class models.students.StudentModel(init_table=False)[source]

Bases: models.base_model.BaseModel

Student CRUD operations.

remove_token(token)[source]

Removes the authentication token from the database.

validate_token(token)[source]

Finds the token and returns the user.

models.buildings module

Building and Course - Building Relation Model

class models.buildings.BuildingModel(init_table=False)[source]

Bases: models.base_model.BaseModel

Building CRUD operations for courses.

class models.buildings.CourseBuildingModel(init_table=False)[source]

Bases: models.base_model.BaseModel

Course-Building Relation CRUD operations.

models.chatGroup module

class models.chatGroup.ChatGroupsModel(init_table=False)[source]

Bases: models.base_model.BaseModel

Implements the chat feature

It just keeps chatgroups and information related to table, anything about membership is not stored in this model

checkIsAdmin(conn, data)[source]

Checks wheter a student is admin of given group

createGroup(data)[source]

Forms a Chat group.

Parameters:data – Chatgroup information
getLastGroupCreatedById(conn, data)[source]

Returns the last group created by specific student Id. Used for adding student to group that he created simultenously

Parameters:data – chatgroup_id
listGroups()[source]

Returns a groups of student

Parameters:data – Student info
removeGroup(data)[source]

Removes a group from database

updateGroup(data)[source]

Updates group’s information

class models.chatGroup.StudentsOnChatModel(init_table=False)[source]

Bases: models.base_model.BaseModel

Keeps information about chatgroups

addMember(data)[source]

Adds member to chatgroup

Parameters:data – Dictionary of chatgroup and student id
checkIfMember(data)[source]

Checking membership status by student id

listMembersOfGroup(data)[source]

Returns a dictionary that contains the members of group

removeMember(data)[source]

Removes member from chat group

showGroupsOfStudent(conn, data)[source]

Returns a dictionary of group where student is joined

Parameters:data – Chatgroup and student information

models.comments module

class models.comments.CommentsModel(init_table=False)[source]

Bases: models.base_model.BaseModel

Implements the comment model

addComment(data)[source]

Adds comment to given student

removeComment(data)[source]
showCommentsOfStudent(data)[source]

Returns a dictionary that containing comments of student

updateComment(data)[source]

models.faculties module

class models.faculties.FacultyModel(init_table=False)[source]

Bases: models.base_model.BaseModel

Faculty CRUD operations.

models.homeworks module

class models.homeworks.HomeworksModel(init_table=False)[source]

Bases: models.base_model.BaseModel

Implements the homeworks model

Keeps track of homeworks and their details but owner of homework is unknown

addHomework(data)[source]

Adds new homework test

changeHomework(hwid, data)[source]

Alters homework information by id

getLastHwCreatedById(conn, data)[source]

Returns the last homework’s id of given student. Used for simultenously adding homework to student

Parameters:data – student_id
listHomeworks(data)[source]

Returns a dictionary of homeworks by course identities

removeHomework(data)[source]

Removes homework by id

class models.homeworks.HomeworksOfStudentModel(init_table=False)[source]

Bases: models.base_model.BaseModel

Implements the homeworks of student model

Allows us to see which one has which homeworks

addHomeworkOfStudent(data)[source]
removeStudentsHomework(conn, data)[source]
showHomeworks(conn, data)[source]

Shows homeworks of specific student

Parameters:data – Student information

models.lecturers module

class models.lecturers.LecturersModel(init_table=False)[source]

Bases: models.base_model.BaseModel

Lecturer table CRUD operations.

addLecturer(data)[source]

Adds new lecturer

listAllLecturers()[source]

Returns all lecturers

listAllLecturersBySName()[source]
listLecturersOfDepartment(conn, data)[source]

Returns lecturers of specific department

removeLecturer(conn, data)[source]

Removes lecturer

showALecturer(data)[source]

Returns information of specific lecturer

updateLecturer(data)[source]

models.studygroups module

Study Group and Study Group - Student Model

class models.studygroups.StudentStudyGroup(init_table=False)[source]

Bases: models.base_model.BaseModel

Relation between student and study groups.

find_student_studygroups(studentid)[source]

Finds all the study groups created by a student.

list_studygroup_students(conn=None, studygroupid=None)[source]

Finds and joins all the student data of a study group.

list_studygroups_of_student(conn=None, studentid=None)[source]

Finds and joins all the student data of a study group.

set_student_status(studygroup, studentid, status)[source]

Changes the status of a student.

class models.studygroups.StudyGroupModel(init_table=False)[source]

Bases: models.base_model.BaseModel

Study group CRUD operations.

get_available_study_groups(conn=None, studentid='', courseids=None, date_start=None, date_end=None)[source]

Finds and returns all available study groups for a student from database.

Module contents