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

🎨 feat: Update course models #2

Open
wants to merge 2 commits into
base: features/courses
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions apps/courses/constants/defaults.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
HTK_APPS_COURSES_MODELS_COURSE = 'htk.course'
HTK_APPS_COURSES_MODELS_CHAPTER = 'htk.chapter'
HTK_APPS_COURSES_MODELS_LESSON = 'htk.lesson'
47 changes: 0 additions & 47 deletions apps/courses/models.py

This file was deleted.

11 changes: 11 additions & 0 deletions apps/courses/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# HTK Imports
from htk.apps.courses.models.chapter import Chapter
from htk.apps.courses.models.course import Course
from htk.apps.courses.models.lesson import Lesson


__all__ = [
'Chapter',
'Course',
'Lesson',
]
8 changes: 8 additions & 0 deletions apps/courses/models/assessment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# HTK Imports
from htk.models.classes import HtkBaseModel


class Assessment(HtkBaseModel):
"""Assessments are quizzes, exams, etc"""

pass
28 changes: 28 additions & 0 deletions apps/courses/models/chapter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Django Imports
from django.db import models

# HTK Imports
from htk.apps.courses.models.fk_fields import fk_course
from htk.models.classes import HtkBaseModel


DEFAULT_RELATED_NAME = 'chapters'


class Chapter(HtkBaseModel):
"""Chapters are an optional grouping for lessons within a course.

Chapters are analogous to "Acts" in creative works such as films, plays, and novels.

Courses that are larger might be organized into separate Chapters

Alternate names considered:
- CourseModule
- CourseSection
"""

name = models.CharField(max_length=256)
order = models.PositiveIntegerField(default=0)

# Relations
course = fk_course(DEFAULT_RELATED_NAME, required=True)
11 changes: 11 additions & 0 deletions apps/courses/models/course.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Django Imports
from django.db import models

# HTK Imports
from htk.models.classes import HtkBaseModel


class Course(HtkBaseModel):
"""Courses are the root object for a course"""

name = models.CharField(max_length=256)
24 changes: 24 additions & 0 deletions apps/courses/models/fk_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Django Imports
from django.db import models

# HTK Imports
from htk.models.fk_fields import build_kwargs
from htk.utils import htk_setting


def fk_course(related_name: str, required: bool = False) -> models.ForeignKey:
field = models.ForeignKey(
htk_setting('HTK_APPS_COURSES_MODELS_COURSE'),
related_name=related_name,
**build_kwargs(required=required),
)
return field


def fk_chapter(related_name: str, required: bool = False) -> models.ForeignKey:
field = models.ForeignKey(
htk_setting('HTK_APPS_COURSES_MODELS_CHAPTER'),
related_name=related_name,
**build_kwargs(required=required),
)
return field
27 changes: 27 additions & 0 deletions apps/courses/models/lesson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Django Imports
from django.db import models

# HTK Imports
from htk.apps.courses.models.fk_fields import (
fk_chapter,
fk_course,
)
from htk.models.classes import HtkBaseModel


DEFAULT_RELATED_NAME = 'lessons'


class Lesson(HtkBaseModel):
"""Lessons are the main component within the Courses app
that hold the bulk of the content.

Naturally, a Course is a collection of many Lessons.
"""

name = models.CharField(max_length=256)
order = models.PositiveIntegerField(default=0)

# Relations
course = fk_course(DEFAULT_RELATED_NAME, required=True)
chapter = fk_chapter(DEFAULT_RELATED_NAME, required=False)
1 change: 1 addition & 0 deletions constants/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
from htk.apps.accounts.constants.defaults import *
from htk.apps.bible.constants.defaults import *
from htk.apps.changelog.constants.defaults import *
from htk.apps.courses.constants.defaults import *
from htk.apps.cpq.constants.defaults import *
from htk.apps.file_storage.constants.defaults import *
from htk.apps.geolocations.constants.defaults import *
Expand Down