BO 1.13 tutorials steps condition as JSON

This commit is contained in:
Bossanyi Tibor
2021-04-30 23:01:49 +02:00
parent 311fa6071c
commit 7459dfdc2d
5 changed files with 68 additions and 17 deletions
@@ -1,5 +1,8 @@
from django.contrib import admin
from django.db import models
from django_admin_json_editor import JSONEditorWidget
from ..models.tutorial import TutorialTranslation, Tutorial, TutorialSteps
@@ -9,13 +12,66 @@ class TranslationTutorialInline(admin.TabularInline):
extra = 0
DATA_SCHEMA = {
'type': 'object',
'title': 'Control for TutorialStep',
'properties': {
'direction': {
'title': 'direction',
'type': 'string',
'enum': ['up', 'down', 'left', 'right']
},
'top': {
'title': 'Top',
'type': 'integer',
},
'left': {
'title': 'Left',
'type': 'integer',
},
'show_bubble': {
'title': 'Show Bubble',
'type': 'boolean',
},
'bubble_x': {
'title': 'Bubble X',
'type': 'integer',
},
'bubble_y': {
'title': 'Bubble Y',
'type': 'integer',
},
'bubble_width': {
'title': 'Bubble Width',
'type': 'integer',
},
'bubble_height': {
'title': 'Bubble Height',
'type': 'integer',
},
'show_check_text': {
'title': 'Show Check Text',
'type': 'boolean',
},
'parent': {
'title': 'parent',
'type': 'integer',
},
},
}
class TutorialStepsAdmin(admin.ModelAdmin):
list_display = ('tutorial_step_id', 'tutorial', 'check_text', 'step', 'direction', 'parent_id', 'branch')
list_display = ('tutorial_step_id', 'tutorial', 'check_text', 'step')
list_filter = ('tutorial__name',)
fields = ('tutorial', 'step', "tutorial_text", "check_text", "direction", "condition", 'parent_id', 'branch'
, "action")
list_editable = ('step','direction', 'parent_id','branch')
fields = ('tutorial', 'step', "tutorial_text", "check_text", "condition")
list_editable = ('step',)
ordering = ('tutorial_step_id',)
formfield_overrides = {
models.TextField: {
'widget': JSONEditorWidget(DATA_SCHEMA, collapsed=False)
},
}
def copy_attributes(self, request, queryset):
for objectAttr in reversed(queryset):