85 lines
2.1 KiB
Python
85 lines
2.1 KiB
Python
from django.db import models
|
|
from django.db.models import DateTimeField, CharField
|
|
from wagtail import blocks
|
|
from wagtail.admin.panels import FieldPanel
|
|
from wagtail.blocks import StreamBlock
|
|
from wagtail.fields import StreamField
|
|
from wagtail.models import Page
|
|
|
|
from vbv_lernwelt.files.models import UploadFile
|
|
|
|
|
|
class ExplanationBlock(blocks.CharBlock):
|
|
class Meta:
|
|
icon = "comment"
|
|
|
|
|
|
class PerformanceObjectiveBlock(blocks.CharBlock):
|
|
class Meta:
|
|
icon = "tick"
|
|
|
|
|
|
class UserTextInputBlock(blocks.StaticBlock):
|
|
class Meta:
|
|
icon = "edit"
|
|
|
|
|
|
class UserConfirmationBlock(blocks.CharBlock):
|
|
confirmation_text = blocks.BooleanBlock()
|
|
|
|
class Meta:
|
|
icon = "tick-inverse"
|
|
|
|
|
|
class TaskBlock(blocks.StructBlock):
|
|
title = blocks.CharBlock()
|
|
file_submission_required = blocks.BooleanBlock()
|
|
content = StreamBlock(
|
|
[
|
|
("explanation", ExplanationBlock()),
|
|
("user_text_input", UserTextInputBlock()),
|
|
("user_confirmation", UserConfirmationBlock()),
|
|
],
|
|
use_json_field=True,
|
|
)
|
|
|
|
class Meta:
|
|
icon = "tasks"
|
|
label = "Teilauftrag"
|
|
|
|
|
|
class Assignment(Page):
|
|
# TODO: Referenz auf durchfhrung
|
|
starting_position = CharField(max_length=1024)
|
|
due = DateTimeField() # Zwingend teil der Durchführung
|
|
performance_objectives = StreamField(
|
|
[
|
|
("performance_objective", PerformanceObjectiveBlock()),
|
|
],
|
|
use_json_field=True,
|
|
)
|
|
effort_required = CharField(max_length=255)
|
|
assessment_tool = models.OneToOneField(UploadFile, on_delete=models.PROTECT)
|
|
tasks = StreamField(
|
|
[
|
|
("task", TaskBlock()),
|
|
],
|
|
use_json_field=True,
|
|
)
|
|
|
|
content_panels = Page.content_panels + [
|
|
FieldPanel("starting_position"),
|
|
FieldPanel("due"),
|
|
FieldPanel("performance_objectives"),
|
|
FieldPanel("effort_required"),
|
|
FieldPanel("assessment_tool"),
|
|
FieldPanel("tasks"),
|
|
]
|
|
|
|
class Meta:
|
|
verbose_name = "Auftrag"
|
|
|
|
|
|
class AssignmentPage(Page):
|
|
subpage_types = ["assignment.Assignment"]
|