111 lines
2.6 KiB
Python
111 lines
2.6 KiB
Python
# Create your models here.
|
|
|
|
from django.db import models
|
|
from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel
|
|
from wagtail.core.blocks import StreamBlock
|
|
from wagtail.core.fields import StreamField
|
|
from wagtail.core.models import Page
|
|
|
|
from vbv_lernwelt.learnpath.models_learning_unit_content import WebBasedTrainingBlock, VideoBlock
|
|
|
|
|
|
class LearningPath(Page):
|
|
content_panels = Page.content_panels + [
|
|
FieldPanel('title', classname="full"),
|
|
]
|
|
|
|
subpage_types = ['learnpath.Topic']
|
|
|
|
class Meta:
|
|
verbose_name = "Learning Path"
|
|
|
|
def __str__(self):
|
|
return f"{self.title}"
|
|
|
|
|
|
class Topic(Page):
|
|
is_visible = models.BooleanField(default=True)
|
|
|
|
content_panels = Page.content_panels + [
|
|
FieldPanel('is_visible', classname="full"),
|
|
]
|
|
|
|
parent_page_types = ['learnpath.LearningPath']
|
|
subpage_types = ['learnpath.Circle']
|
|
|
|
class Meta:
|
|
verbose_name = "Topic"
|
|
|
|
def __str__(self):
|
|
return f"{self.title}"
|
|
|
|
|
|
class Circle(Page):
|
|
description = models.TextField(default="", blank=True)
|
|
goals = models.TextField(default="", blank=True)
|
|
|
|
parent_page_types = ['learnpath.Topic']
|
|
subpage_types = ['learnpath.LearningSequence']
|
|
|
|
content_panels = Page.content_panels + [
|
|
FieldPanel('description'),
|
|
FieldPanel('goals'),
|
|
]
|
|
|
|
class Meta:
|
|
verbose_name = "Circle"
|
|
|
|
def __str__(self):
|
|
return f"{self.title}"
|
|
|
|
|
|
IN_CIRCLE = 'INCIRCLE'
|
|
START = 'START'
|
|
END = 'END'
|
|
|
|
LEARNING_SEQUENCE_CATEGORIES = [
|
|
(IN_CIRCLE, 'In Circle'),
|
|
(START, 'Start'),
|
|
(END, 'End')
|
|
]
|
|
|
|
|
|
class LearningSequence(Page):
|
|
# TODO: How to do a icon choice field?
|
|
category = models.CharField(max_length=16, choices=LEARNING_SEQUENCE_CATEGORIES, default=IN_CIRCLE)
|
|
|
|
parent_page_types = ['learnpath.Circle']
|
|
subpage_types = ['learnpath.LearningUnit']
|
|
|
|
class Meta:
|
|
verbose_name = "Learning Sequence"
|
|
|
|
def __str__(self):
|
|
return f"{self.title}"
|
|
|
|
|
|
class LearningUnit(Page):
|
|
# TODO: Review model architecture, is the stream fiel the right thing here?
|
|
parent_page_types = ['learnpath.LearningSequence']
|
|
|
|
content_blocks = [
|
|
('web_based_training', WebBasedTrainingBlock()),
|
|
('video', VideoBlock()),
|
|
]
|
|
|
|
contents = StreamField(StreamBlock(content_blocks),
|
|
null=True, blank=True, min_num=1, max_num=1)
|
|
|
|
content_panels = [
|
|
FieldPanel('title', classname="full title"),
|
|
StreamFieldPanel('contents')
|
|
]
|
|
|
|
subpage_types = []
|
|
|
|
class Meta:
|
|
verbose_name = "Learning Unit"
|
|
|
|
def __str__(self):
|
|
return f"{self.title}"
|