Adds objectives app to project

This commit is contained in:
Pawel Kowalski 2018-08-14 11:37:52 +02:00
parent 0c8b5553df
commit 579d54c8c5
10 changed files with 106 additions and 4 deletions

View File

@ -0,0 +1,42 @@
import logging
from django.db import models
from wagtail.admin.edit_handlers import FieldPanel, TabbedInterface, \
ObjectList
from wagtail.core.fields import RichTextField
from wagtail.core.models import Page
from wagtail.images.edit_handlers import ImageChooserPanel
from book.blocks import DEFAULT_RICH_TEXT_FEATURES
from book.models import Book
logger = logging.getLogger(__name__)
class Chapter(Page):
class Meta:
verbose_name = 'Kapitel'
verbose_name_plural = 'Kapitel'
book = models.ForeignKey(Book, blank=False, null=False, on_delete=models.CASCADE)
content_panels = [
FieldPanel('title', classname="full title"),
]
settings_panels = [
FieldPanel('slug')
]
edit_handler = TabbedInterface([
ObjectList(content_panels, heading='Content'),
ObjectList(settings_panels, heading='Settings'),
])
template = 'generic_page.html'
parent_page_types = ['book.Module']
@classmethod
def get_module_chapters(cls, module):
return cls.objects.filter(id__in=module.get_child_ids()).live()

View File

@ -22,9 +22,6 @@ class Module(Page):
max_length=255,
help_text='e.g. \'Intro\' or \'Modul 1\''
)
teaser = models.TextField()
description = RichTextField(features=DEFAULT_RICH_TEXT_FEATURES)
hero_image = models.ForeignKey(
'wagtailimages.Image',
null=True,
@ -33,12 +30,15 @@ class Module(Page):
related_name='+'
)
teaser = models.TextField()
intro = RichTextField(features=DEFAULT_RICH_TEXT_FEATURES)
content_panels = [
FieldPanel('title', classname="full title"),
FieldPanel('meta_title', classname="full title"),
ImageChooserPanel('hero_image'),
FieldPanel('teaser'),
FieldPanel('description'),
FieldPanel('intro'),
]
settings_panels = [

View File

@ -47,6 +47,8 @@ INSTALLED_APPS = [
'api',
'user',
'book',
'objectives',
'news',
'wagtail.contrib.forms',
'wagtail.contrib.redirects',

View File

View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

View File

@ -0,0 +1,5 @@
from django.apps import AppConfig
class ObjectivesConfig(AppConfig):
name = 'objectives'

View File

View File

@ -0,0 +1,44 @@
from django.contrib.auth import get_user_model
from django.db import models
# Create your models here.
from django_extensions.db.models import TitleDescriptionModel
from book.models import Module
class ObjectiveGroup(TitleDescriptionModel):
class Meta:
verbose_name = 'Lernziel Gruppe'
verbose_name_plural = 'Lernziel Gruppen'
module = models.ForeignKey(Module, blank=False, null=False, on_delete=models.CASCADE)
user = models.ForeignKey(get_user_model(), blank=True, null=True, on_delete=models.CASCADE)
# klass = models.ForeignKey(Klass, null=True, on_delete=models.CASCADE)
def __str__(self):
return 'ObjectiveGroup {}-{}-{}'.format(self.id, self.module, self.title)
class Objective(TitleDescriptionModel):
class Meta:
verbose_name = 'Lernziel'
verbose_name_plural = 'Lernziele'
# several competence entries are grouped in current focus
group = models.ForeignKey(ObjectiveGroup, blank=False, null=False, on_delete=models.CASCADE)
def __str__(self):
return 'Objective {}-{}'.format(self.id, self.title)
class ObjectiveProgressStatus(TitleDescriptionModel):
class Meta:
verbose_name = 'Lernzielstatus'
verbose_name_plural = 'Lernzielstatus'
objective = models.ForeignKey(Objective, blank=False, null=False, on_delete=models.CASCADE)
user = models.ForeignKey(get_user_model(), blank=True, null=True, on_delete=models.CASCADE)
def __str__(self):
return 'Lernzielstatus {}-{}'.format(self.objective, self.title)

View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

View File

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.