BO 1.11 tutorials action
This commit is contained in:
parent
14f1499f6e
commit
2c8fbe592e
@ -10,9 +10,21 @@ class TranslationTutorialInline(admin.TabularInline):
|
||||
|
||||
|
||||
class TutorialStepsAdmin(admin.ModelAdmin):
|
||||
list_display = ('tutorial', 'step',)
|
||||
list_filter = ('tutorial',)
|
||||
fields = ('tutorial', 'step', "tutorial_text", "error_text", "check_text","condition", "parent")
|
||||
list_display = ('tutorial_step_id', 'tutorial', 'check_text', 'step', 'parent')
|
||||
list_filter = ('tutorial__name',)
|
||||
fields = ('tutorial', 'step', "tutorial_text", "error_text", "check_text", "condition", 'get_parent_step', "action")
|
||||
list_editable = ('parent',)
|
||||
readonly_fields = ('get_parent_step',)
|
||||
|
||||
def copy_attributes(self, request, queryset):
|
||||
for objectAttr in reversed(queryset):
|
||||
objectAttr.pk = None
|
||||
objectAttr.step = objectAttr.step + 1
|
||||
objectAttr.save()
|
||||
|
||||
copy_attributes.short_description = "Clone the selected TutorialStep"
|
||||
|
||||
actions = [copy_attributes]
|
||||
|
||||
inlines = [
|
||||
TranslationTutorialInline,
|
||||
|
@ -1,6 +1,6 @@
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from froala_editor.fields import FroalaField
|
||||
from ckeditor.fields import RichTextField
|
||||
|
||||
from .enums import LanguageTypes
|
||||
from .exercise_type import ExerciseType
|
||||
@ -14,8 +14,7 @@ class TemplateTypes(models.TextChoices):
|
||||
class ExercisePlanTemplate(models.Model):
|
||||
exercise_plan_template_id = models.AutoField(primary_key=True)
|
||||
name = models.CharField(max_length=100, help_text='The name should be in English here')
|
||||
#description = models.TextField(max_length=1000, blank=True, null=True, help_text='The description should be in English here')
|
||||
description = FroalaField()
|
||||
description = RichTextField()
|
||||
template_type = models.CharField(max_length=20, choices=TemplateTypes.choices, default=TemplateTypes.SPECIAL)
|
||||
|
||||
class Meta:
|
||||
@ -32,8 +31,7 @@ class ExercisePlanTemplateTranslation(models.Model):
|
||||
exercise_plan_template = models.ForeignKey(ExercisePlanTemplate, on_delete=models.CASCADE)
|
||||
language_code = models.CharField(max_length=2, choices=LanguageTypes.choices, default=LanguageTypes.HU)
|
||||
name = models.CharField(max_length=100)
|
||||
#description = models.TextField(max_length=1000, blank=True, null=True)
|
||||
description = FroalaField(blank=True, null=True)
|
||||
description = RichTextField(blank=True, null=True)
|
||||
|
||||
class Meta:
|
||||
db_table = 'exercise_plan_template_translation'
|
||||
|
@ -27,7 +27,14 @@ class TutorialSteps(models.Model):
|
||||
error_text = RichTextField(blank=True, null=True)
|
||||
check_text = models.TextField(max_length=50, blank=True, null=True, help_text="Only for programmers!")
|
||||
condition = models.TextField(max_length=50, blank=True, null=True, help_text="Only for programmers!")
|
||||
parent = models.IntegerField(help_text="Tutorial Step Parent. If not defined, then the parent is step-1")
|
||||
##parent = models.IntegerField(help_text="Tutorial Step Parent. If not defined, then the parent is step-1")
|
||||
parent = models.ForeignKey('self', blank=True, null=True, related_name='parents', on_delete=models.CASCADE)
|
||||
action = models.BooleanField(default=0, blank=True, null=True, help_text="Tap, select menu, etc")
|
||||
|
||||
def get_parent_step(self):
|
||||
return self.parent.step
|
||||
get_parent_step.admin_order_field = 'self__step'
|
||||
get_parent_step.short_description = "parent_step"
|
||||
|
||||
class Meta:
|
||||
db_table = 'tutorial_steps'
|
||||
|
Loading…
Reference in New Issue
Block a user