added api stuff to readme

This commit is contained in:
Lorenz Padberg 2022-05-23 14:35:05 +02:00
parent 56a14d2942
commit 5af863fb6c
3 changed files with 41 additions and 9 deletions

View File

@ -48,3 +48,25 @@ npm run dev
* In the .idea/vbv_lernwelt.iml file change the module type to "PYTHON_MODULE".
* Add django facet in "Project Structure".
* Run configuration with "Python -> server.py" to have async debugging support.
## Wagtail API intro
get all pages:
http://localhost:8000/api/v2/pages/
get Analyse Circle (the one with the most demo data)
http://localhost:8000/api/v2/pages/?title=Analyse
Get Circles only
http://localhost:8000/api/v2/pages/?type=learnpath.Circle
Get All Contents from that circle:
http://localhost:8000/api/v2/pages/?child_of=11

View File

@ -1,5 +1,6 @@
from django.db import models
from wagtail.core import blocks
from wagtail.api import APIField
# 'video_block'
@ -12,26 +13,35 @@ class VideoBlock(blocks.StructBlock):
class Meta:
icon = 'media'
def get_api_representation(self, value, context=None):
return {'sdfsdf': 1,
'sldkfm': 3}
# 'Web based training Block'
class WebBasedTrainingBlock(blocks.StructBlock):
RISE = 'rise'
WBT_TYPE_CHOICES = (
CONTENT_TYPE_CHOICES = (
(RISE, 'Rise'),
)
# 'Web based training Block'
class WebBasedTrainingBlock(blocks.StructBlock):
url = blocks.URLBlock()
type = models.CharField(
content_type = models.CharField(
max_length=100,
choices=WBT_TYPE_CHOICES,
choices=CONTENT_TYPE_CHOICES,
default=RISE
)
class Meta:
icon = 'media'
def get_api_representation(self, value, context=None):
return {'sdfsdf': 1,
'sldkfm': 3}
# 'Transver Task'
class TranverTaskBlock(blocks.StructBlock):
title = models.CharField(max_length=128, default="")

View File

@ -81,13 +81,13 @@ von Neukunden zu benützen
video_url = "https://www.vbv.ch/fileadmin/vbv/Videos/Statements_Externe/Janos_M/Testimonial_Janos_Mischler_PositiveEffekte.mp4"
video_title = "Ausbildung ist pflicht"
video_description = "Erfahren Sie, was für Janos Mischler die positiven Aspekte von ständiger Weiterbildung sind aus fachlicher und aus persönlicher Sicht."
video_block = VideoBlockFactory(type="video", url=video_url, title=video_title, description=video_description)
video_block = VideoBlockFactory(content_type="video", url=video_url, title=video_title, description=video_description)
learning_unit.contents.append(('video', video_block))
learning_unit.save()
learning_unit = LearningUnitFactory.create(title='** Web Based Training"', parent=circle_4, learning_package=lpck_1)
wbt_url = "web_based_trainings/rise_cmi5_test_export/scormcontent/index.html"
wbt_block = WebBasedTrainingBlockFactory(type="web_based_training", url=wbt_url)
wbt_block = WebBasedTrainingBlockFactory(content_type="web_based_training", url=wbt_url)
learning_unit.contents.append(('web_based_training', wbt_block))
learning_unit.save()