added learningpath apps and fist tests
This commit is contained in:
parent
f3a6946002
commit
3c56ba308f
|
|
@ -103,7 +103,7 @@ THIRD_PARTY_APPS = [
|
|||
LOCAL_APPS = [
|
||||
"vbv_lernwelt.core",
|
||||
"vbv_lernwelt.simpletodo",
|
||||
# Your stuff: custom apps go here
|
||||
"vbv_lernwelt.learnpath",
|
||||
]
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
|
||||
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
|
||||
|
|
|
|||
|
|
@ -3,4 +3,11 @@ from django.apps import AppConfig
|
|||
|
||||
class LearnpathConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'learnpath'
|
||||
name = 'vbv_lernwelt.learnpath'
|
||||
|
||||
def ready(self):
|
||||
try:
|
||||
# pylint: disable=unused-import,import-outside-toplevel
|
||||
import vbv_lernwelt.learnpath.signals # noqa F401
|
||||
except ImportError:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -0,0 +1,79 @@
|
|||
# Generated by Django 3.2.12 on 2022-03-29 09:21
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('wagtailcore', '0066_collection_management_permissions'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='LearnBlock',
|
||||
fields=[
|
||||
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')),
|
||||
('internal_name', models.CharField(max_length=255)),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
bases=('wagtailcore.page',),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Circle',
|
||||
fields=[
|
||||
('learnblock_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='learnpath.learnblock')),
|
||||
('description', models.TextField(default='')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
bases=('learnpath.learnblock',),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='LearnPath',
|
||||
fields=[
|
||||
('learnblock_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='learnpath.learnblock')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
bases=('learnpath.learnblock',),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='LearnSequence',
|
||||
fields=[
|
||||
('learnblock_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='learnpath.learnblock')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
bases=('learnpath.learnblock',),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='LearnUnit',
|
||||
fields=[
|
||||
('learnblock_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='learnpath.learnblock')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
bases=('learnpath.learnblock',),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Topic',
|
||||
fields=[
|
||||
('learnblock_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='learnpath.learnblock')),
|
||||
('is_visible', models.BooleanField(default=True)),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
bases=('learnpath.learnblock',),
|
||||
),
|
||||
]
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
# Generated by Django 3.2.12 on 2022-03-29 13:06
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('wagtailcore', '0066_collection_management_permissions'),
|
||||
('wagtailredirects', '0007_add_autocreate_fields'),
|
||||
('contenttypes', '0002_remove_content_type_name'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('wagtailforms', '0004_add_verbose_name_plural'),
|
||||
('learnpath', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameModel(
|
||||
old_name='LearnPath',
|
||||
new_name='LearningPath',
|
||||
),
|
||||
migrations.RenameModel(
|
||||
old_name='LearnSequence',
|
||||
new_name='LearningSequence',
|
||||
),
|
||||
migrations.RenameModel(
|
||||
old_name='LearnUnit',
|
||||
new_name='LearningUnit',
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='circle',
|
||||
options={'verbose_name': 'Circle'},
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='learningpath',
|
||||
options={'verbose_name': 'Learning Path'},
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='learningsequence',
|
||||
options={'verbose_name': 'homepage'},
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='learningunit',
|
||||
options={'verbose_name': 'Learning Unig'},
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='topic',
|
||||
options={'verbose_name': 'Topic'},
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='learnblock',
|
||||
name='internal_name',
|
||||
),
|
||||
]
|
||||
|
|
@ -1,47 +1,80 @@
|
|||
# Create your models here.
|
||||
import uuid
|
||||
|
||||
from django.db import models
|
||||
from wagtail.core.models import Page
|
||||
from wagtail.admin.edit_handlers import FieldPanel
|
||||
|
||||
#
|
||||
#
|
||||
# class LearnBlock(Page):
|
||||
# pass
|
||||
# # id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
#
|
||||
|
||||
class LearnBlock:
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
internal_name = models.CharField(max_length=255)
|
||||
title = models.CharField(max_length=255)
|
||||
class LearningPath(Page):
|
||||
content_panels = Page.content_panels + [
|
||||
FieldPanel('title', classname="full"),
|
||||
]
|
||||
|
||||
subpage_types = ['learnpath.Topic']
|
||||
|
||||
class LearnPath(LearnBlock):
|
||||
class Meta:
|
||||
verbose_name = "Learning Path"
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.title}"
|
||||
|
||||
|
||||
class Topic(LearnBlock):
|
||||
learn_path = models.ForeignKey(LearnPath, on_delete=models.CASCADE)
|
||||
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(LearnBlock):
|
||||
topic = models.ForeignKey(Topic, on_delete=models.CASCADE)
|
||||
# TODO: Ordering
|
||||
|
||||
|
||||
class Circle(Page):
|
||||
description = models.TextField(default="")
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.title}"
|
||||
parent_page_types = ['learnpath.Topic']
|
||||
subpage_types = ['learnpath.LearningSequence']
|
||||
|
||||
|
||||
class LearnSequence(LearnBlock):
|
||||
circle = models.ForeignKey(Circle, on_delete=models.CASCADE)
|
||||
class Meta:
|
||||
verbose_name = "Circle"
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.title}"
|
||||
|
||||
|
||||
class LernUnit(LearnBlock):
|
||||
learn_sequence = models.ForeignKey(LearnSequence, on_delete=models.CASCADE)
|
||||
class LearningSequence(Page):
|
||||
parent_page_types = ['learnpath.Circle']
|
||||
subpage_types = ['learnpath.LearningUnit']
|
||||
|
||||
class Meta:
|
||||
verbose_name = "homepage"
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.title}"
|
||||
|
||||
|
||||
class LearningUnit(Page):
|
||||
parent_page_types = ['learnpath.Circle']
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Learning Unig"
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.title}"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Iterativ GmbH
|
||||
# http://www.iterativ.ch/
|
||||
#
|
||||
# Copyright (c) 2015 Iterativ GmbH. All rights reserved.
|
||||
#
|
||||
# Created on 2022-03-29
|
||||
# @author: lorenz.padberg@iterativ.ch
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
from server.vbv_lernwelt.learnpath.tests.learningpath_factories import LearningPathFactory
|
||||
|
||||
|
||||
def create_default_learning_path():
|
||||
lp = LearningPathFactory(title="Versicherungsvermittler/in")
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
import factory
|
||||
|
||||
from server.vbv_lernwelt.learnpath.models import LearningPath
|
||||
|
||||
|
||||
class LearningPathFactory(factory.django.DjangoModelFactory):
|
||||
class Meta:
|
||||
model = LearningPath
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Iterativ GmbH
|
||||
# http://www.iterativ.ch/
|
||||
#
|
||||
# Copyright (c) 2015 Iterativ GmbH. All rights reserved.
|
||||
#
|
||||
# Created on 2022-03-29
|
||||
# @author: lorenz.padberg@iterativ.ch
|
||||
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from server.vbv_lernwelt.learnpath.models import LearningPath
|
||||
from server.vbv_lernwelt.learnpath.tests.creat_default_learning_path import create_default_learning_path
|
||||
|
||||
|
||||
class TestCreateDefaultLearningPaths(TestCase):
|
||||
def test_create_learning_path(self):
|
||||
create_default_learning_path()
|
||||
self.assertTrue(LearningPath.objects.filter(title="Versicherungsvermittler/in").exist())
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Iterativ GmbH
|
||||
# http://www.iterativ.ch/
|
||||
#
|
||||
# Copyright (c) 2015 Iterativ GmbH. All rights reserved.
|
||||
#
|
||||
# Created on 2022-03-29
|
||||
# @author: lorenz.padberg@iterativ.ch
|
||||
Loading…
Reference in New Issue