diff --git a/aitrainer_backoffice/aitrainer_backoffice/admin/tutorial.py b/aitrainer_backoffice/aitrainer_backoffice/admin/tutorial.py index 7c57f95..f069b54 100644 --- a/aitrainer_backoffice/aitrainer_backoffice/admin/tutorial.py +++ b/aitrainer_backoffice/aitrainer_backoffice/admin/tutorial.py @@ -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, diff --git a/aitrainer_backoffice/aitrainer_backoffice/models/exercise_plan_template.py b/aitrainer_backoffice/aitrainer_backoffice/models/exercise_plan_template.py index 03b3f32..ab85980 100644 --- a/aitrainer_backoffice/aitrainer_backoffice/models/exercise_plan_template.py +++ b/aitrainer_backoffice/aitrainer_backoffice/models/exercise_plan_template.py @@ -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' diff --git a/aitrainer_backoffice/aitrainer_backoffice/models/tutorial.py b/aitrainer_backoffice/aitrainer_backoffice/models/tutorial.py index 0fad1d7..3517803 100644 --- a/aitrainer_backoffice/aitrainer_backoffice/models/tutorial.py +++ b/aitrainer_backoffice/aitrainer_backoffice/models/tutorial.py @@ -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'